Example #1
0
    def test_long_running_post_delete(self):

        # Test throw on non LRO related status code
        response = TestLongRunningOperation.mock_send('POST', 201, {})
        op = LongRunningOperation(response(), lambda x:None)
        with self.assertRaises(BadStatus):
            op.get_initial_status(response())
        with self.assertRaises(CloudError):
            AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()

        # Test polling from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'azure-asyncoperation': ASYNC_URL},
            body={'properties':{'provisioningState': 'Succeeded'}})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        poll.wait()
        #self.assertIsNone(poll.result())
        self.assertIsNone(poll._response.randomFieldFromPollAsyncOpHeader)

        # Test polling from location header
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'location': LOCATION_URL},
            body={'properties':{'provisioningState': 'Succeeded'}})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        self.assertEqual(poll.result().name, TEST_NAME)
        self.assertIsNone(poll._response.randomFieldFromPollLocationHeader)

        # Test fail to poll from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'azure-asyncoperation': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()

        # Test fail to poll from location header
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'location': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()
Example #2
0
    def test_long_running_negative(self):
        global LOCATION_BODY
        global POLLING_STATUS

        # Test LRO PUT throws for invalid json
        LOCATION_BODY = '{'
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'location': LOCATION_URL})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        with self.assertRaises(DeserializationError):
            poll.wait()

        LOCATION_BODY = '{\'"}'
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'location': LOCATION_URL})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        with self.assertRaises(DeserializationError):
            poll.wait()

        LOCATION_BODY = '{'
        POLLING_STATUS = 203
        response = TestLongRunningOperation.mock_send(
            'POST', 202,
            {'location': LOCATION_URL})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        with self.assertRaises(CloudError): # TODO: Node.js raises on deserialization
            poll.wait()

        LOCATION_BODY = json.dumps({ 'name': TEST_NAME })
        POLLING_STATUS = 200
Example #3
0
    def test_long_running_put(self):
        #TODO: Test custom header field

        # Test throw on non LRO related status code
        response = TestLongRunningOperation.mock_send('PUT', 1000, {})
        op = LongRunningOperation(response(), lambda x:None)
        with self.assertRaises(BadStatus):
            op.get_initial_status(response())
        with self.assertRaises(CloudError):
            AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()

        # Test polling from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'PUT', 201,
            {'azure-asyncoperation': ASYNC_URL})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        self.assertEqual(poll.result().name, TEST_NAME)
        self.assertFalse(hasattr(poll._response, 'randomFieldFromPollAsyncOpHeader'))

        # Test polling location header
        response = TestLongRunningOperation.mock_send(
            'PUT', 201,
            {'location': LOCATION_URL})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        self.assertEqual(poll.result().name, TEST_NAME)
        self.assertIsNone(poll._response.randomFieldFromPollLocationHeader)

        # Test fail to poll from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'PUT', 201,
            {'azure-asyncoperation': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()

        # Test fail to poll from location header
        response = TestLongRunningOperation.mock_send(
            'PUT', 201,
            {'location': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()
Example #4
0
    def test_long_running_patch(self):

        # Test polling from location header
        response = TestLongRunningOperation.mock_send(
            'PATCH', 202,
            {'location': LOCATION_URL},
            body={'properties':{'provisioningState': 'Succeeded'}})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        self.assertEqual(poll.result().name, TEST_NAME)
        self.assertIsNone(poll._response.randomFieldFromPollLocationHeader)

        # Test polling from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'PATCH', 202,
            {'azure-asyncoperation': ASYNC_URL},
            body={'properties':{'provisioningState': 'Succeeded'}})
        poll = AzureOperationPoller(response,
            TestLongRunningOperation.mock_outputs,
            TestLongRunningOperation.mock_update, 0)
        self.assertEqual(poll.result().name, TEST_NAME)
        self.assertFalse(hasattr(poll._response, 'randomFieldFromPollAsyncOpHeader'))

        # Test fail to poll from azure-asyncoperation header
        response = TestLongRunningOperation.mock_send(
            'PATCH', 202,
            {'azure-asyncoperation': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()

        # Test fail to poll from location header
        response = TestLongRunningOperation.mock_send(
            'PATCH', 202,
            {'location': ERROR})
        with self.assertRaises(BadEndpointError):
            poll = AzureOperationPoller(response,
                TestLongRunningOperation.mock_outputs,
                TestLongRunningOperation.mock_update, 0).result()
    def delete(self,
               resource_group_name,
               vm_name,
               vm_extension_name,
               custom_headers=None,
               raw=False,
               **operation_config):
        """The operation to delete the extension.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param vm_name: The name of the virtual machine where the extension
         should be deleted.
        :type vm_name: str
        :param vm_extension_name: The name of the virtual machine extension.
        :type vm_extension_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns
         OperationStatusResponse or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._delete_initial(
            resource_group_name=resource_group_name,
            vm_name=vm_name,
            vm_extension_name=vm_extension_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config)
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters[
                'x-ms-client-request-id'] = raw_result.response.request.headers[
                    'x-ms-client-request-id']
            return self._client.send(request,
                                     header_parameters,
                                     stream=False,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202, 204]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = self._deserialize('OperationStatusResponse',
                                             response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #6
0
    def create_or_update(self,
                         resource_group_name,
                         circuit_name,
                         peering_name,
                         peering_parameters,
                         custom_headers=None,
                         raw=False,
                         **operation_config):
        """
        The Put Pering operation creates/updates an peering in the specified
        ExpressRouteCircuits

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param circuit_name: The name of the express route circuit.
        :type circuit_name: str
        :param peering_name: The name of the peering.
        :type peering_name: str
        :param peering_parameters: Parameters supplied to the create/update
         ExpressRouteCircuit Peering operation
        :type peering_parameters: :class:`ExpressRouteCircuitPeering
         <azure.mgmt.network.models.ExpressRouteCircuitPeering>`
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`ExpressRouteCircuitPeering
         <azure.mgmt.network.models.ExpressRouteCircuitPeering>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'circuitName':
            self._serialize.url("circuit_name", circuit_name, 'str'),
            'peeringName':
            self._serialize.url("peering_name", peering_name, 'str'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct body
        body_content = self._serialize.body(peering_parameters,
                                            'ExpressRouteCircuitPeering')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(request, header_parameters, body_content,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('ExpressRouteCircuitPeering',
                                                 response)
            if response.status_code == 201:
                deserialized = self._deserialize('ExpressRouteCircuitPeering',
                                                 response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def update(
            self, resource_group_name, route_filter_name, rule_name, route_filter_rule_parameters, custom_headers=None, raw=False, **operation_config):
        """Updates a route in the specified route filter.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param route_filter_name: The name of the route filter.
        :type route_filter_name: str
        :param rule_name: The name of the route filter rule.
        :type rule_name: str
        :param route_filter_rule_parameters: Parameters supplied to the update
         route filter rule operation.
        :type route_filter_rule_parameters:
         ~azure.mgmt.network.v2017_03_01.models.PatchRouteFilterRule
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns
         RouteFilterRule or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.network.v2017_03_01.models.RouteFilterRule]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._update_initial(
            resource_group_name=resource_group_name,
            route_filter_name=route_filter_name,
            rule_name=rule_name,
            route_filter_rule_parameters=route_filter_rule_parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id']
            return self._client.send(
                request, header_parameters, stream=False, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = self._deserialize('RouteFilterRule', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
Example #8
0
    def create_or_update(self,
                         resource_group_name,
                         deployment_name,
                         virtual_network_name,
                         content_version=None,
                         dns_servers=None,
                         location=None,
                         subnet_name="Subnet1",
                         subnet_prefix="10.0.0.0/24",
                         tags=None,
                         virtual_network_prefix="10.0.0.0/16",
                         custom_headers=None,
                         raw=False,
                         **operation_config):
        """
        Create or update a virtual machine.

        :param resource_group_name: The name of the resource group. The name
         is case insensitive.
        :type resource_group_name: str
        :param deployment_name: The name of the deployment.
        :type deployment_name: str
        :param virtual_network_name: Name of the virtual network.
        :type virtual_network_name: str
        :param content_version: If included it must match the ContentVersion
         in the template.
        :type content_version: str
        :param dns_servers: List of DNS server IP addresses.
        :type dns_servers: list of object
        :param location: Virtual network location.
        :type location: str
        :param subnet_name: Name of the subnet.
        :type subnet_name: str
        :param subnet_prefix: IP address for the subnet.
        :type subnet_prefix: str
        :param tags: Tags object.
        :type tags: object
        :param virtual_network_prefix: IP address prefix for the virtual
         network.
        :type virtual_network_prefix: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`DeploymentExtended
         <default.models.DeploymentExtended>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        parameters = models.DeploymentVnet(
            content_version=content_version,
            dns_servers=dns_servers,
            location=location,
            subnet_name=subnet_name,
            subnet_prefix=subnet_prefix,
            tags=tags,
            virtual_network_name=virtual_network_name,
            virtual_network_prefix=virtual_network_prefix)

        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name",
                                resource_group_name,
                                'str',
                                max_length=64,
                                min_length=1,
                                pattern='^[-\w\._]+$'),
            'deploymentName':
            self._serialize.url("deployment_name",
                                deployment_name,
                                'str',
                                max_length=64,
                                min_length=1,
                                pattern='^[-\w\._]+$'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct body
        body_content = self._serialize.body(parameters, 'DeploymentVnet')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(request, header_parameters, body_content,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('DeploymentExtended',
                                                 response)
            if response.status_code == 201:
                deserialized = self._deserialize('DeploymentExtended',
                                                 response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #9
0
    def delete(self,
               resource_group_name,
               virtual_network_name,
               subnet_name,
               custom_headers={},
               raw=False,
               **operation_config):
        """
        The delete subnet operation deletes the specified subnet.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param virtual_network_name: The name of the virtual network.
        :type virtual_network_name: str
        :param subnet_name: The name of the subnet.
        :type subnet_name: str
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: None
        :rtype: msrest.pipeline.ClientRawResponse if raw=True
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}/subnets/{subnetName}'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'virtualNetworkName':
            self._serialize.url("virtual_network_name", virtual_network_name,
                                'str'),
            'subnetName':
            self._serialize.url("subnet_name", subnet_name, 'str'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct and send request
        def long_running_send():

            request = self._client.delete(url, query_parameters)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_status(status_link, headers={}):

            request = self._client.get(status_link)
            request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 204, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #10
0
    def create_or_update(
            self, resource_group_name, route_table_name, parameters, custom_headers={}, raw=False, **operation_config):
        """
        The Put RouteTable operation creates/updates a route tablein the
        specified resource group.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param route_table_name: The name of the route table.
        :type route_table_name: str
        :param parameters: Parameters supplied to the create/update Route
         Table operation
        :type parameters: RouteTable
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: RouteTable
        :rtype: msrest.pipeline.ClientRawResponse if raw=True
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'routeTableName': self._serialize.url("route_table_name", route_table_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(parameters, 'RouteTable')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(
                request, header_parameters, body_content, **operation_config)

        def get_long_running_status(status_link, headers={}):

            request = self._client.get(status_link)
            request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('RouteTable', response)
            if response.status_code == 201:
                deserialized = self._deserialize('RouteTable', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
Example #11
0
    def failover_allow_data_loss(self,
                                 resource_group_name,
                                 server_name,
                                 database_name,
                                 link_id,
                                 custom_headers=None,
                                 raw=False,
                                 **operation_config):
        """Sets which replica database is primary by failing over from the current
        primary replica database. This operation might result in data loss.

        :param resource_group_name: The name of the resource group that
         contains the resource. You can obtain this value from the Azure
         Resource Manager API or the portal.
        :type resource_group_name: str
        :param server_name: The name of the server.
        :type server_name: str
        :param database_name: The name of the database that has the
         replication link to be failed over.
        :type database_name: str
        :param link_id: The ID of the replication link to be failed over.
        :type link_id: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns None or
         ClientRawResponse if raw=true
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str'),
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'serverName':
            self._serialize.url("server_name", server_name, 'str'),
            'databaseName':
            self._serialize.url("database_name", database_name, 'str'),
            'linkId':
            self._serialize.url("link_id", link_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct and send request
        def long_running_send():

            request = self._client.post(url, query_parameters)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [202, 204]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def create(
            self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config):
        """
        Asynchronously creates a new storage account with the specified
        parameters. Existing accounts cannot be updated with this API and
        should instead use the Update Storage Account API. If an account is
        already created and subsequent PUT request is issued with exact same
        set of properties, then HTTP 200 would be returned.

        :param resource_group_name: The name of the resource group within the
         user’s subscription.
        :type resource_group_name: str
        :param account_name: The name of the storage account within the
         specified resource group. Storage account names must be between 3
         and 24 characters in length and use numbers and lower-case letters
         only.
        :type account_name: str
        :param parameters: The parameters to provide for the created account.
        :type parameters: :class:`StorageAccountCreateParameters
         <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountCreateParameters>`
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
        :return: A poller object which can return :class:`StorageAccount
         <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccount>`
         or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'accountName': self._serialize.url("account_name", account_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(parameters, 'StorageAccountCreateParameters')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(
                request, header_parameters, body_content, **operation_config)

        def get_long_running_status(status_link, headers={}):

            request = self._client.get(status_link)
            request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('StorageAccount', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
Example #13
0
    def revoke_access(self,
                      resource_group_name,
                      snapshot_name,
                      custom_headers=None,
                      raw=False,
                      **operation_config):
        """Revokes access to a snapshot.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param snapshot_name: The name of the snapshot within the given
         subscription and resource group.
        :type snapshot_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns
         OperationStatusResponse or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess'
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str'),
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'snapshotName':
            self._serialize.url("snapshot_name", snapshot_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct and send request
        def long_running_send():

            request = self._client.post(url, query_parameters)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('OperationStatusResponse',
                                                 response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def create_or_update(self,
                         resource_group_name,
                         server_name,
                         communication_link_name,
                         partner_server,
                         custom_headers=None,
                         raw=False,
                         **operation_config):
        """Creates a server communication link.

        :param resource_group_name: The name of the resource group that
         contains the resource. You can obtain this value from the Azure
         Resource Manager API or the portal.
        :type resource_group_name: str
        :param server_name: The name of the server.
        :type server_name: str
        :param communication_link_name: The name of the server communication
         link.
        :type communication_link_name: str
        :param partner_server: The name of the partner server.
        :type partner_server: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`ServerCommunicationLink
         <azure.mgmt.sql.models.ServerCommunicationLink>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        parameters = models.ServerCommunicationLink(
            partner_server=partner_server)

        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}'
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str'),
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'serverName':
            self._serialize.url("server_name", server_name, 'str'),
            'communicationLinkName':
            self._serialize.url("communication_link_name",
                                communication_link_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct body
        body_content = self._serialize.body(parameters,
                                            'ServerCommunicationLink')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(request, header_parameters, body_content,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [201, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 201:
                deserialized = self._deserialize('ServerCommunicationLink',
                                                 response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def create(self,
               resource_group_name,
               account_name,
               parameters,
               custom_headers=None,
               raw=False,
               **operation_config):
        """Asynchronously creates a new storage account with the specified
        parameters. If an account is already created and a subsequent create
        request is issued with different properties, the account properties
        will be updated. If an account is already created and a subsequent
        create or update request is issued with the exact same set of
        properties, the request will succeed.

        :param resource_group_name: The name of the resource group within the
         user's subscription. The name is case insensitive.
        :type resource_group_name: str
        :param account_name: The name of the storage account within the
         specified resource group. Storage account names must be between 3 and
         24 characters in length and use numbers and lower-case letters only.
        :type account_name: str
        :param parameters: The parameters to provide for the created account.
        :type parameters:
         ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns
         StorageAccount or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._create_initial(
            resource_group_name=resource_group_name,
            account_name=account_name,
            parameters=parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config)
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters[
                'x-ms-client-request-id'] = raw_result.response.request.headers[
                    'x-ms-client-request-id']
            return self._client.send(request,
                                     header_parameters,
                                     stream=False,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = self._deserialize('StorageAccount', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #16
0
    def create_or_update(self,
                         resource_group_name,
                         web_service_name,
                         create_or_update_payload,
                         custom_headers=None,
                         raw=False,
                         **operation_config):
        """Create or update a web service. This call will overwrite an existing
        web service. Note that there is no warning or confirmation. This is a
        nonrecoverable operation. If your intent is to create a new web
        service, call the Get operation first to verify that it does not exist.

        :param resource_group_name: Name of the resource group in which the
         web service is located.
        :type resource_group_name: str
        :param web_service_name: The name of the web service.
        :type web_service_name: str
        :param create_or_update_payload: The payload that is used to create or
         update the web service.
        :type create_or_update_payload: :class:`WebService
         <azure.mgmt.machinelearning.models.WebService>`
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`WebService
         <azure.mgmt.machinelearning.models.WebService>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearning/webServices/{webServiceName}'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'webServiceName':
            self._serialize.url("web_service_name", web_service_name, 'str'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct body
        body_content = self._serialize.body(create_or_update_payload,
                                            'WebService')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(request, header_parameters, body_content,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('WebService', response)
            if response.status_code == 201:
                deserialized = self._deserialize('WebService', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def delete_managed_hosting_environment(
            self, resource_group_name, name, force_delete=None, custom_headers={}, raw=False, **operation_config):
        """
        Delete a managed hosting environment.

        :param resource_group_name: Name of resource group
        :type resource_group_name: str
        :param name: Name of managed hosting environment
        :type name: str
        :param force_delete: Delete even if the managed hosting environment
         contains resources
        :type force_delete: bool
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: object
        :rtype: msrest.pipeline.ClientRawResponse if raw=True
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/managedHostingEnvironments/{name}'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'name': self._serialize.url("name", name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = url.format(**path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if force_delete is not None:
            query_parameters['forceDelete'] = self._serialize.query("force_delete", force_delete, 'bool')
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        def long_running_send():

            request = self._client.delete(url, query_parameters)
            return self._client.send(request, header_parameters, **operation_config)

        def get_long_running_status(status_link, headers={}):

            request = self._client.get(status_link)
            request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [202, 400, 404, 409]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 202:
                deserialized = self._deserialize('object', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
Example #18
0
    def create_or_update(self,
                         resource_group_name,
                         circuit_name,
                         peering_name,
                         peering_parameters,
                         custom_headers=None,
                         raw=False,
                         **operation_config):
        """Creates or updates a peering in the specified express route circuits.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param circuit_name: The name of the express route circuit.
        :type circuit_name: str
        :param peering_name: The name of the peering.
        :type peering_name: str
        :param peering_parameters: Parameters supplied to the create or update
         express route circuit peering operation.
        :type peering_parameters:
         ~azure.mgmt.network.v2015_06_15.models.ExpressRouteCircuitPeering
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns
         ExpressRouteCircuitPeering or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.network.v2015_06_15.models.ExpressRouteCircuitPeering]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._create_or_update_initial(
            resource_group_name=resource_group_name,
            circuit_name=circuit_name,
            peering_name=peering_name,
            peering_parameters=peering_parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config)
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters[
                'x-ms-client-request-id'] = raw_result.response.request.headers[
                    'x-ms-client-request-id']
            return self._client.send(request,
                                     header_parameters,
                                     stream=False,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = self._deserialize('ExpressRouteCircuitPeering',
                                             response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #19
0
    def update(self,
               resource_group_name,
               route_filter_name,
               route_filter_parameters,
               custom_headers=None,
               raw=False,
               **operation_config):
        """Updates a route filter in a specified resource group.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param route_filter_name: The name of the route filter.
        :type route_filter_name: str
        :param route_filter_parameters: Parameters supplied to the update
         route filter operation.
        :type route_filter_parameters:
         ~azure.mgmt.network.v2017_06_01.models.PatchRouteFilter
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns RouteFilter
         or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.network.v2017_06_01.models.RouteFilter]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'routeFilterName':
            self._serialize.url("route_filter_name", route_filter_name, 'str'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct body
        body_content = self._serialize.body(route_filter_parameters,
                                            'PatchRouteFilter')

        # Construct and send request
        def long_running_send():

            request = self._client.patch(url, query_parameters)
            return self._client.send(request, header_parameters, body_content,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('RouteFilter', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def get_status(self,
                   resource_group_name,
                   network_watcher_name,
                   packet_capture_name,
                   custom_headers=None,
                   raw=False,
                   **operation_config):
        """Query the status of a running packet capture session.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param network_watcher_name: The name of the Network Watcher resource.
        :type network_watcher_name: str
        :param packet_capture_name: The name given to the packet capture
         session.
        :type packet_capture_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`PacketCaptureQueryStatusResult
         <azure.mgmt.network.v2016_12_01.models.PacketCaptureQueryStatusResult>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/queryStatus'
        path_format_arguments = {
            'resourceGroupName':
            self._serialize.url("resource_group_name", resource_group_name,
                                'str'),
            'networkWatcherName':
            self._serialize.url("network_watcher_name", network_watcher_name,
                                'str'),
            'packetCaptureName':
            self._serialize.url("packet_capture_name", packet_capture_name,
                                'str'),
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

        # Construct and send request
        def long_running_send():

            request = self._client.post(url, query_parameters)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(request, header_parameters,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize(
                    'PacketCaptureQueryStatusResult', response)
            if response.status_code == 202:
                deserialized = self._deserialize(
                    'PacketCaptureQueryStatusResult', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def get_advertised_routes(
            self, resource_group_name, virtual_network_gateway_name, peer, custom_headers=None, raw=False, **operation_config):
        """This operation retrieves a list of routes the virtual network gateway
        is advertising to the specified peer.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param virtual_network_gateway_name: The name of the virtual network
         gateway.
        :type virtual_network_gateway_name: str
        :param peer: The IP address of the peer
        :type peer: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`GatewayRouteListResult
         <azure.mgmt.network.v2017_08_01.models.GatewayRouteListResult>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'virtualNetworkGatewayName': self._serialize.url("virtual_network_gateway_name", virtual_network_gateway_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['peer'] = self._serialize.query("peer", peer, 'str')
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        def long_running_send():

            request = self._client.post(url, query_parameters)
            return self._client.send(request, header_parameters, **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('GatewayRouteListResult', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
    def execute(
            self, resource_group_name, lab_name, virtual_machine_name, name, custom_headers=None, raw=False, **operation_config):
        """Execute a schedule. This operation can take a while to complete.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param lab_name: The name of the lab.
        :type lab_name: str
        :param virtual_machine_name: The name of the virtual machine.
        :type virtual_machine_name: str
        :param name: The name of the schedule.
        :type name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns None or
         ClientRawResponse if raw=true
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{virtualMachineName}/schedules/{name}/execute'
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'labName': self._serialize.url("lab_name", lab_name, 'str'),
            'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'),
            'name': self._serialize.url("name", name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        def long_running_send():

            request = self._client.post(url, query_parameters)
            return self._client.send(request, header_parameters, **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
Example #23
0
    def create(self,
               resource_group_name,
               account_name,
               parameters,
               custom_headers=None,
               raw=False,
               **operation_config):
        """Creates a new Batch account with the specified parameters. Existing
        accounts cannot be updated with this API and should instead be updated
        with the Update Batch Account API.

        :param resource_group_name: The name of the resource group that
         contains the Batch account.
        :type resource_group_name: str
        :param account_name: A name for the Batch account which must be unique
         within the region. Batch account names must be between 3 and 24
         characters in length and must use only numbers and lowercase letters.
         This name is used as part of the DNS name that is used to access the
         Batch service in the region in which the account is created. For
         example: http://accountname.region.batch.azure.com/.
        :type account_name: str
        :param parameters: Additional parameters for account creation.
        :type parameters:
         ~azure.mgmt.batch.models.BatchAccountCreateParameters
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns BatchAccount
         or ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.batch.models.BatchAccount]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._create_initial(
            resource_group_name=resource_group_name,
            account_name=account_name,
            parameters=parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config)
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters[
                'x-ms-client-request-id'] = raw_result.response.request.headers[
                    'x-ms-client-request-id']
            return self._client.send(request,
                                     header_parameters,
                                     stream=False,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            header_dict = {
                'Location': 'str',
                'Retry-After': 'int',
            }
            deserialized = self._deserialize('BatchAccount', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                client_raw_response.add_headers(header_dict)
                return client_raw_response

            return deserialized

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
Example #24
0
    def retarget(self,
                 resource_group_name,
                 name,
                 current_resource_id=None,
                 target_resource_id=None,
                 custom_headers=None,
                 raw=False,
                 **operation_config):
        """Updates a schedule's target resource Id. This operation can take a
        while to complete.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param name: The name of the schedule.
        :type name: str
        :param current_resource_id: The resource Id of the virtual machine on
         which the schedule operates
        :type current_resource_id: str
        :param target_resource_id: The resource Id of the virtual machine that
         the schedule should be retargeted to
        :type target_resource_id: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns None or
         ClientRawResponse if raw=true
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._retarget_initial(
            resource_group_name=resource_group_name,
            name=name,
            current_resource_id=current_resource_id,
            target_resource_id=target_resource_id,
            custom_headers=custom_headers,
            raw=True,
            **operation_config)
        if raw:
            return raw_result

        # Construct and send request
        def long_running_send():
            return raw_result.response

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            header_parameters = {}
            header_parameters[
                'x-ms-client-request-id'] = raw_result.response.request.headers[
                    'x-ms-client-request-id']
            return self._client.send(request,
                                     header_parameters,
                                     stream=False,
                                     **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 202]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(long_running_send, get_long_running_output,
                                    get_long_running_status,
                                    long_running_operation_timeout)
    def create_or_update(
            self, resource_group_name, lab_name, name, formula, custom_headers=None, raw=False, **operation_config):
        """Create or replace an existing Formula. This operation can take a while
        to complete.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param lab_name: The name of the lab.
        :type lab_name: str
        :param name: The name of the formula.
        :type name: str
        :param formula: A formula for creating a VM, specifying an image base
         and other parameters
        :type formula: ~azure.mgmt.devtestlabs.models.Formula
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return: An instance of AzureOperationPoller that returns Formula or
         ClientRawResponse if raw=true
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.devtestlabs.models.Formula]
         or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/formulas/{name}'
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'labName': self._serialize.url("lab_name", lab_name, 'str'),
            'name': self._serialize.url("name", name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(formula, 'Formula')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(
                request, header_parameters, body_content, **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [200, 201]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 200:
                deserialized = self._deserialize('Formula', response)
            if response.status_code == 201:
                deserialized = self._deserialize('Formula', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)
    def create_or_update(
            self, resource_group_name, domain_name, domain, custom_headers=None, raw=False, **operation_config):
        """Creates or updates a domain.

        Creates or updates a domain.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param domain_name: Name of the domain.
        :type domain_name: str
        :param domain: Domain registration information.
        :type domain: :class:`Domain <azure.mgmt.web.models.Domain>`
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :return:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         instance that returns :class:`Domain <azure.mgmt.web.models.Domain>`
         or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype:
         :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>`
         or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DomainRegistration/domains/{domainName}'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
            'domainName': self._serialize.url("domain_name", domain_name, 'str', pattern=r'[a-zA-Z0-9][a-zA-Z0-9\.-]+'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(domain, 'Domain')

        # Construct and send request
        def long_running_send():

            request = self._client.put(url, query_parameters)
            return self._client.send(
                request, header_parameters, body_content, **operation_config)

        def get_long_running_status(status_link, headers=None):

            request = self._client.get(status_link)
            if headers:
                request.headers.update(headers)
            return self._client.send(
                request, header_parameters, **operation_config)

        def get_long_running_output(response):

            if response.status_code not in [202, 200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            deserialized = None

            if response.status_code == 202:
                deserialized = self._deserialize('Domain', response)
            if response.status_code == 200:
                deserialized = self._deserialize('Domain', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                return client_raw_response

            return deserialized

        if raw:
            response = long_running_send()
            return get_long_running_output(response)

        long_running_operation_timeout = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        return AzureOperationPoller(
            long_running_send, get_long_running_output,
            get_long_running_status, long_running_operation_timeout)