def get_sender(self, message_timeout=0, session=None, **kwargs):
        """Get a Sender for the Service Bus endpoint.

        A Sender represents a single open connection within which multiple send operations can be made.

        :param message_timeout: The period in seconds during which messages sent with
         this Sender must be sent. If the send is not completed in this time it will fail.
        :type message_timeout: int
        :param session: An optional session ID. If supplied this session ID will be
         applied to every outgoing message sent with this Sender.
         If an individual message already has a session ID, that will be
         used instead. If no session ID is supplied here, nor set on an outgoing
         message, a ValueError will be raised if the entity is sessionful.
        :type session: str or ~uuid.Guid
        :returns: A Sender instance with an unopened connection.
        :rtype: ~azure.servicebus.aio.async_send_handler.Sender

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START open_close_sender_context]
                :end-before: [END open_close_sender_context]
                :language: python
                :dedent: 4
                :caption: Send multiple messages with a Sender.

        """
        handler_id = str(uuid.uuid4())
        if self.entity and self.requires_session:
            return SessionSender(
                handler_id,
                self.entity_uri,
                self.auth_config,
                session=session,
                loop=self.loop,
                debug=self.debug,
                msg_timeout=message_timeout,
                **kwargs)
        return Sender(
            handler_id,
            self.entity_uri,
            self.auth_config,
            session=session,
            loop=self.loop,
            debug=self.debug,
            msg_timeout=message_timeout,
            **kwargs)

def get_sender ( self , message_timeout = 0 , session = None , * * kwargs ) : handler_id = str ( uuid . uuid4 ( ) ) if self . entity and self . requires_session : return SessionSender ( handler_id , self . entity_uri , self . auth_config , session = session , loop = self . loop , debug = self . debug , msg_timeout = message_timeout , * * kwargs ) return Sender ( handler_id , self . entity_uri , self . auth_config , session = session , loop = self . loop , debug = self . debug , msg_timeout = message_timeout , * * kwargs )

Get a Sender for the Service Bus endpoint .


def get_receiver(self, session=None, prefetch=0, mode=ReceiveSettleMode.PeekLock, idle_timeout=0, **kwargs):
        """Get a Receiver for the Service Bus endpoint.

        A Receiver represents a single open connection with which multiple receive operations can be made.

        :param session: A specific session from which to receive. This must be specified for a
         sessionful entity, otherwise it must be None. In order to receive the next available
         session, set this to NEXT_AVAILABLE.
        :type session: str or ~azure.servicebus.common.constants.NEXT_AVAILABLE
        :param prefetch: The maximum number of messages to cache with each request to the service.
         The default value is 0, meaning messages will be received from the service and processed
         one at a time. Increasing this value will improve message throughput performance but increase
         the chance that messages will expire while they are cached if they're not processed fast enough.
        :type prefetch: int
        :param mode: The mode with which messages will be retrieved from the entity. The two options
         are PeekLock and ReceiveAndDelete. Messages received with PeekLock must be settled within a given
         lock period before they will be removed from the queue. Messages received with ReceiveAndDelete
         will be immediately removed from the queue, and cannot be subsequently rejected or re-received if
         the client fails to process the message. The default mode is PeekLock.
        :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode
        :param idle_timeout: The timeout in seconds between received messages after which the receiver will
         automatically shutdown. The default value is 0, meaning no timeout.
        :type idle_timeout: int
        :returns: A Receiver instance with an unopened connection.
        :rtype: ~azure.servicebus.aio.async_receive_handler.Receiver

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START open_close_receiver_context]
                :end-before: [END open_close_receiver_context]
                :language: python
                :dedent: 4
                :caption: Receive messages with a Receiver.

        """
        if self.entity and not self.requires_session and session:
            raise ValueError("A session cannot be used with a non-sessionful entitiy.")
        if self.entity and self.requires_session and not session:
            raise ValueError("This entity requires a session.")
        if int(prefetch) < 0 or int(prefetch) > 50000:
            raise ValueError("Prefetch must be an integer between 0 and 50000 inclusive.")

        prefetch += 1
        handler_id = str(uuid.uuid4())
        if session:
            return SessionReceiver(
                handler_id,
                self.entity_uri,
                self.auth_config,
                session=session,
                loop=self.loop,
                debug=self.debug,
                timeout=int(idle_timeout * 1000),
                prefetch=prefetch,
                mode=mode,
                **kwargs)
        return Receiver(
            handler_id,
            self.entity_uri,
            self.auth_config,
            loop=self.loop,
            debug=self.debug,
            timeout=int(idle_timeout * 1000),
            prefetch=prefetch,
            mode=mode,
            **kwargs)

Get a Receiver for the Service Bus endpoint .


def get_deadletter_receiver(
            self, transfer_deadletter=False, prefetch=0,
            mode=ReceiveSettleMode.PeekLock, idle_timeout=0, **kwargs):
        """Get a Receiver for the deadletter endpoint of the entity.

        A Receiver represents a single open connection with which multiple receive operations can be made.

        :param transfer_deadletter: Whether to connect to the transfer deadletter queue, or the standard
         deadletter queue. Default is False, using the standard deadletter endpoint.
        :type transfer_deadletter: bool
        :param prefetch: The maximum number of messages to cache with each request to the service.
         The default value is 0, meaning messages will be received from the service and processed
         one at a time. Increasing this value will improve message throughput performance but increase
         the change that messages will expire while they are cached if they're not processed fast enough.
        :type prefetch: int
        :param mode: The mode with which messages will be retrieved from the entity. The two options
         are PeekLock and ReceiveAndDelete. Messages received with PeekLock must be settled within a given
         lock period before they will be removed from the queue. Messages received with ReceiveAndDelete
         will be immediately removed from the queue, and cannot be subsequently rejected or re-received if
         the client fails to process the message. The default mode is PeekLock.
        :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode
        :param idle_timeout: The timeout in seconds between received messages after which the receiver will
         automatically shutdown. The default value is 0, meaning no timeout.
        :type idle_timeout: int
        :returns: A Receiver instance with an unopened Connection.
        :rtype: ~azure.servicebus.aio.async_receive_handler.Receiver

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START receiver_deadletter_messages]
                :end-before: [END receiver_deadletter_messages]
                :language: python
                :dedent: 4
                :caption: Receive dead-lettered messages.

        """
        if int(prefetch) < 0 or int(prefetch) > 50000:
            raise ValueError("Prefetch must be an integer between 0 and 50000 inclusive.")

        prefetch += 1
        handler_id = str(uuid.uuid4())
        if transfer_deadletter:
            entity_uri = self.mgmt_client.format_transfer_dead_letter_queue_name(self.entity_uri)
        else:
            entity_uri = self.mgmt_client.format_dead_letter_queue_name(self.entity_uri)
        return Receiver(
            handler_id,
            entity_uri,
            self.auth_config,
            loop=self.loop,
            debug=self.debug,
            timeout=int(idle_timeout * 1000),
            prefetch=prefetch,
            mode=mode,
            **kwargs)

Get a Receiver for the deadletter endpoint of the entity .


def parse_response_for_async_op(response):
    ''' Extracts request id from response header. '''

    if response is None:
        return None

    result = AsynchronousOperationResult()
    if response.headers:
        for name, value in response.headers:
            if name.lower() == 'x-ms-request-id':
                result.request_id = value

    return result

def parse_response_for_async_op ( response ) : if response is None : return None result = AsynchronousOperationResult ( ) if response . headers : for name , value in response . headers : if name . lower ( ) == 'x-ms-request-id' : result . request_id = value return result

Extracts request id from response header .


def perform_get(self, path, x_ms_version=None):
        '''
        Performs a GET request and returns the response.

        path:
            Path to the resource.
            Ex: '/<subscription-id>/services/hostedservices/<service-name>'
        x_ms_version:
            If specified, this is used for the x-ms-version header.
            Otherwise, self.x_ms_version is used.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.host
        request.path = path
        request.path, request.query = self._httpclient._update_request_uri_query(request)
        request.headers = self._update_management_header(request, x_ms_version)
        response = self._perform_request(request)

        return response

def perform_get ( self , path , x_ms_version = None ) : request = HTTPRequest ( ) request . method = 'GET' request . host = self . host request . path = path request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers = self . _update_management_header ( request , x_ms_version ) response = self . _perform_request ( request ) return response

Performs a GET request and returns the response .


def perform_put(self, path, body, x_ms_version=None):
        '''
        Performs a PUT request and returns the response.

        path:
            Path to the resource.
            Ex: '/<subscription-id>/services/hostedservices/<service-name>'
        body:
            Body for the PUT request.
        x_ms_version:
            If specified, this is used for the x-ms-version header.
            Otherwise, self.x_ms_version is used.
        '''
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self.host
        request.path = path
        request.body = _get_request_body(body)
        request.path, request.query = self._httpclient._update_request_uri_query(request)
        request.headers = self._update_management_header(request, x_ms_version)
        response = self._perform_request(request)

        return response

def perform_put ( self , path , body , x_ms_version = None ) : request = HTTPRequest ( ) request . method = 'PUT' request . host = self . host request . path = path request . body = _get_request_body ( body ) request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers = self . _update_management_header ( request , x_ms_version ) response = self . _perform_request ( request ) return response

Performs a PUT request and returns the response .


def wait_for_operation_status(self,
        request_id, wait_for_status='Succeeded', timeout=30, sleep_interval=5,
        progress_callback=wait_for_operation_status_progress_default_callback,
        success_callback=wait_for_operation_status_success_default_callback,
        failure_callback=wait_for_operation_status_failure_default_callback):
        '''
        Waits for an asynchronous operation to complete.

        This calls get_operation_status in a loop and returns when the expected
        status is reached. The result of get_operation_status is returned. By
        default, an exception is raised on timeout or error status.

        request_id:
            The request ID for the request you wish to track.
        wait_for_status:
            Status to wait for. Default is 'Succeeded'.
        timeout:
            Total timeout in seconds. Default is 30s.
        sleep_interval:
            Sleep time in seconds for each iteration. Default is 5s.
        progress_callback:
            Callback for each iteration.
            Default prints '.'.
            Set it to None for no progress notification.
        success_callback:
            Callback on success. Default prints newline.
            Set it to None for no success notification.
        failure_callback:
            Callback on failure. Default prints newline+error details then
            raises exception.
            Set it to None for no failure notification.
        '''
        loops = timeout // sleep_interval + 1
        start_time = time.time()
        for _ in range(int(loops)):
            result = self.get_operation_status(request_id)
            elapsed = time.time() - start_time
            if result.status == wait_for_status:
                if success_callback is not None:
                    success_callback(elapsed)
                return result
            elif result.error:
                if failure_callback is not None:
                    ex = AzureAsyncOperationHttpError(_ERROR_ASYNC_OP_FAILURE, result.status, result)
                    failure_callback(elapsed, ex)
                return result
            else:
                if progress_callback is not None:
                    progress_callback(elapsed)
                time.sleep(sleep_interval)

        if failure_callback is not None:
            ex = AzureAsyncOperationHttpError(_ERROR_ASYNC_OP_TIMEOUT, result.status, result)
            failure_callback(elapsed, ex)
        return result

Waits for an asynchronous operation to complete .


def get_operation_status(self, request_id):
        '''
        Returns the status of the specified operation. After calling an
        asynchronous operation, you can call Get Operation Status to determine
        whether the operation has succeeded, failed, or is still in progress.

        request_id:
            The request ID for the request you wish to track.
        '''
        _validate_not_none('request_id', request_id)
        return self._perform_get(
            '/' + self.subscription_id + '/operations/' + _str(request_id),
            Operation)

def get_operation_status ( self , request_id ) : _validate_not_none ( 'request_id' , request_id ) return self . _perform_get ( '/' + self . subscription_id + '/operations/' + _str ( request_id ) , Operation )

Returns the status of the specified operation . After calling an asynchronous operation you can call Get Operation Status to determine whether the operation has succeeded failed or is still in progress .


def _update_management_header(self, request, x_ms_version):
        ''' Add additional headers for management. '''

        if request.method in ['PUT', 'POST', 'MERGE', 'DELETE']:
            request.headers.append(('Content-Length', str(len(request.body))))

        # append additional headers base on the service
        request.headers.append(('x-ms-version', x_ms_version or self.x_ms_version))

        # if it is not GET or HEAD request, must set content-type.
        if not request.method in ['GET', 'HEAD']:
            for name, _ in request.headers:
                if 'content-type' == name.lower():
                    break
            else:
                request.headers.append(
                    ('Content-Type',
                     self.content_type))

        return request.headers


def travis_build_package():
    """Assumed called on Travis, to prepare a package to be deployed

    This method prints on stdout for Travis.
    Return is obj to pass to sys.exit() directly
    """

    travis_tag = os.environ.get('TRAVIS_TAG')
    if not travis_tag:
        print("TRAVIS_TAG environment variable is not present")
        return "TRAVIS_TAG environment variable is not present"

    try:
        name, version = travis_tag.split("_")
    except ValueError:
        print("TRAVIS_TAG is not '<package_name>_<version>' (tag is: {})".format(travis_tag))
        return "TRAVIS_TAG is not '<package_name>_<version>' (tag is: {})".format(travis_tag)

    try:
        version = Version(version)
    except InvalidVersion:
        print("Version must be a valid PEP440 version (version is: {})".format(version))
        return "Version must be a valid PEP440 version (version is: {})".format(version)

    if name.lower() in OMITTED_RELEASE_PACKAGES:
        print("The input package {} has been disabled for release from Travis.CI.".format(name))
        return

    abs_dist_path = Path(os.environ['TRAVIS_BUILD_DIR'], 'dist')
    create_package(name, str(abs_dist_path))

    print("Produced:\n{}".format(list(abs_dist_path.glob('*'))))

    pattern = "*{}*".format(version)
    packages = list(abs_dist_path.glob(pattern))
    if not packages:
        return "Package version does not match tag {}, abort".format(version)
    pypi_server = os.environ.get("PYPI_SERVER", "default PyPI server")
    print("Package created as expected and will be pushed to {}".format(pypi_server))

Assumed called on Travis to prepare a package to be deployed


def get_certificates(
            self, vault_base_url, maxresults=None, include_pending=None, custom_headers=None, raw=False, **operation_config):
        """List certificates in a specified key vault.

        The GetCertificates operation returns the set of certificates resources
        in the specified key vault. This operation requires the
        certificates/list permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param maxresults: Maximum number of results to return in a page. If
         not specified the service will return up to 25 results.
        :type maxresults: int
        :param include_pending: Specifies whether to include certificates
         which are not completely provisioned.
        :type include_pending: bool
        :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>`.
        :return: An iterator like instance of CertificateItem
        :rtype:
         ~azure.keyvault.v7_0.models.CertificateItemPaged[~azure.keyvault.v7_0.models.CertificateItem]
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v7_0.models.KeyVaultErrorException>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = self.get_certificates.metadata['url']
                path_format_arguments = {
                    'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True)
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                if maxresults is not None:
                    query_parameters['maxresults'] = self._serialize.query("maxresults", maxresults, 'int', maximum=25, minimum=1)
                if include_pending is not None:
                    query_parameters['includePending'] = self._serialize.query("include_pending", include_pending, 'bool')
                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

            else:
                url = next_link
                query_parameters = {}

            # 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
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, stream=False, **operation_config)

            if response.status_code not in [200]:
                raise models.KeyVaultErrorException(self._deserialize, response)

            return response

        # Deserialize response
        deserialized = models.CertificateItemPaged(internal_paging, self._deserialize.dependencies)

        if raw:
            header_dict = {}
            client_raw_response = models.CertificateItemPaged(internal_paging, self._deserialize.dependencies, header_dict)
            return client_raw_response

        return deserialized

def
get_certificates
(
self
,
vault_base_url
,
maxresults
=
,
include_pending
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
# Construct URL
url
=
self
.
get_certificates
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
if
maxresults
is
not
:
query_parameters
[
'maxresults'
]
=
self
.
_serialize
.
query
(
"maxresults"
,
maxresults
,
'int'
,
maximum
=
25
,
minimum
=
1
)
if
include_pending
is
not
:
query_parameters
[
'includePending'
]
=
self
.
_serialize
.
query
(
"include_pending"
,
include_pending
,
'bool'
)
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
# 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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct and send request
request
=
self
.
_client
.
get
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
return
response
# Deserialize response
deserialized
=
models
.
CertificateItemPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
CertificateItemPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

List certificates in a specified key vault .


def get_regions(self):
        '''
        Get list of available service bus regions.
        '''
        response = self._perform_get(
            self._get_path('services/serviceBus/Regions/', None),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            _ServiceBusManagementXmlSerializer.xml_to_region)

def get_regions ( self ) : response = self . _perform_get ( self . _get_path ( 'services/serviceBus/Regions/' , None ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , _ServiceBusManagementXmlSerializer . xml_to_region )

Get list of available service bus regions .


def list_namespaces(self):
        '''
        List the service bus namespaces defined on the account.
        '''
        response = self._perform_get(
            self._get_path('services/serviceBus/Namespaces/', None),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            _ServiceBusManagementXmlSerializer.xml_to_namespace)

def list_namespaces ( self ) : response = self . _perform_get ( self . _get_path ( 'services/serviceBus/Namespaces/' , None ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , _ServiceBusManagementXmlSerializer . xml_to_namespace )

List the service bus namespaces defined on the account .


def get_namespace(self, name):
        '''
        Get details about a specific namespace.

        name:
            Name of the service bus namespace.
        '''
        response = self._perform_get(
            self._get_path('services/serviceBus/Namespaces', name),
            None)

        return _ServiceBusManagementXmlSerializer.xml_to_namespace(
            response.body)

def get_namespace ( self , name ) : response = self . _perform_get ( self . _get_path ( 'services/serviceBus/Namespaces' , name ) , None ) return _ServiceBusManagementXmlSerializer . xml_to_namespace ( response . body )

Get details about a specific namespace .


def create_namespace(self, name, region):
        '''
        Create a new service bus namespace.

        name:
            Name of the service bus namespace to create.
        region:
            Region to create the namespace in.
        '''
        _validate_not_none('name', name)

        return self._perform_put(
            self._get_path('services/serviceBus/Namespaces', name),
            _ServiceBusManagementXmlSerializer.namespace_to_xml(region))

def create_namespace ( self , name , region ) : _validate_not_none ( 'name' , name ) return self . _perform_put ( self . _get_path ( 'services/serviceBus/Namespaces' , name ) , _ServiceBusManagementXmlSerializer . namespace_to_xml ( region ) )


def delete_namespace(self, name):
        '''
        Delete a service bus namespace.

        name:
            Name of the service bus namespace to delete.
        '''
        _validate_not_none('name', name)

        return self._perform_delete(
            self._get_path('services/serviceBus/Namespaces', name),
            None)

def delete_namespace ( self , name ) : _validate_not_none ( 'name' , name ) return self . _perform_delete ( self . _get_path ( 'services/serviceBus/Namespaces' , name ) , None )


def check_namespace_availability(self, name):
        '''
        Checks to see if the specified service bus namespace is available, or
        if it has already been taken.

        name:
            Name of the service bus namespace to validate.
        '''
        _validate_not_none('name', name)

        response = self._perform_get(
            self._get_path('services/serviceBus/CheckNamespaceAvailability',
                           None) + '/?namespace=' + _str(name), None)

        return _ServiceBusManagementXmlSerializer.xml_to_namespace_availability(
            response.body)

Checks to see if the specified service bus namespace is available or if it has already been taken .


def list_topics(self, name):
        '''
        Retrieves the topics in the service namespace.

        name:
            Name of the service bus namespace.
        '''
        response = self._perform_get(
            self._get_list_topics_path(name),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _MinidomXmlToObject.convert_xml_to_azure_object,
                azure_type=TopicDescription
            )
        )

def list_topics ( self , name ) : response = self . _perform_get ( self . _get_list_topics_path ( name ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _MinidomXmlToObject . convert_xml_to_azure_object , azure_type = TopicDescription ) )

Retrieves the topics in the service namespace .


def list_notification_hubs(self, name):
        '''
        Retrieves the notification hubs in the service namespace.

        name:
            Name of the service bus namespace.
        '''
        response = self._perform_get(
            self._get_list_notification_hubs_path(name),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _MinidomXmlToObject.convert_xml_to_azure_object,
                azure_type=NotificationHubDescription
            )
        )

def list_notification_hubs ( self , name ) : response = self . _perform_get ( self . _get_list_notification_hubs_path ( name ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _MinidomXmlToObject . convert_xml_to_azure_object , azure_type = NotificationHubDescription ) )

Retrieves the notification hubs in the service namespace .


def list_relays(self, name):
        '''
        Retrieves the relays in the service namespace.

        name:
            Name of the service bus namespace.
        '''
        response = self._perform_get(
            self._get_list_relays_path(name),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _MinidomXmlToObject.convert_xml_to_azure_object,
                azure_type=RelayDescription
            )
        )

def list_relays ( self , name ) : response = self . _perform_get ( self . _get_list_relays_path ( name ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _MinidomXmlToObject . convert_xml_to_azure_object , azure_type = RelayDescription ) )

Retrieves the relays in the service namespace .


def get_metrics_rollups_queue(self, name, queue_name, metric):
        '''
        This operation gets rollup data for Service Bus metrics queue.
        Rollup data includes the time granularity for the telemetry aggregation as well as
        the retention settings for each time granularity.

        name:
            Name of the service bus namespace.
        queue_name:
            Name of the service bus queue in this namespace.
        metric:
            name of a supported metric
        '''
        response = self._perform_get(
            self._get_get_metrics_rollup_queue_path(name, queue_name, metric),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _ServiceBusManagementXmlSerializer.xml_to_metrics,
                object_type=MetricRollups
            )
        )

def get_metrics_rollups_queue ( self , name , queue_name , metric ) : response = self . _perform_get ( self . _get_get_metrics_rollup_queue_path ( name , queue_name , metric ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _ServiceBusManagementXmlSerializer . xml_to_metrics , object_type = MetricRollups ) )

This operation gets rollup data for Service Bus metrics queue . Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity .


def get_metrics_rollups_topic(self, name, topic_name, metric):
        '''
        This operation gets rollup data for Service Bus metrics topic.
        Rollup data includes the time granularity for the telemetry aggregation as well as
        the retention settings for each time granularity.

        name:
            Name of the service bus namespace.
        topic_name:
            Name of the service bus queue in this namespace.
        metric:
            name of a supported metric
        '''
        response = self._perform_get(
            self._get_get_metrics_rollup_topic_path(name, topic_name, metric),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _ServiceBusManagementXmlSerializer.xml_to_metrics,
                object_type=MetricRollups
            )
        )

def get_metrics_rollups_topic ( self , name , topic_name , metric ) : response = self . _perform_get ( self . _get_get_metrics_rollup_topic_path ( name , topic_name , metric ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _ServiceBusManagementXmlSerializer . xml_to_metrics , object_type = MetricRollups ) )

This operation gets rollup data for Service Bus metrics topic . Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity .


def get_metrics_rollups_notification_hub(self, name, hub_name, metric):
        '''
        This operation gets rollup data for Service Bus metrics notification hub.
        Rollup data includes the time granularity for the telemetry aggregation as well as
        the retention settings for each time granularity.

        name:
            Name of the service bus namespace.
        hub_name:
            Name of the service bus notification hub in this namespace.
        metric:
            name of a supported metric
        '''
        response = self._perform_get(
            self._get_get_metrics_rollup_hub_path(name, hub_name, metric),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _ServiceBusManagementXmlSerializer.xml_to_metrics,
                object_type=MetricRollups
            )
        )

def get_metrics_rollups_notification_hub ( self , name , hub_name , metric ) : response = self . _perform_get ( self . _get_get_metrics_rollup_hub_path ( name , hub_name , metric ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _ServiceBusManagementXmlSerializer . xml_to_metrics , object_type = MetricRollups ) )

This operation gets rollup data for Service Bus metrics notification hub . Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity .


def get_metrics_rollups_relay(self, name, relay_name, metric):
        '''
        This operation gets rollup data for Service Bus metrics relay.
        Rollup data includes the time granularity for the telemetry aggregation as well as
        the retention settings for each time granularity.

        name:
            Name of the service bus namespace.
        relay_name:
            Name of the service bus relay in this namespace.
        metric:
            name of a supported metric
        '''
        response = self._perform_get(
            self._get_get_metrics_rollup_relay_path(name, relay_name, metric),
            None)

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            partial(
                _ServiceBusManagementXmlSerializer.xml_to_metrics,
                object_type=MetricRollups
            )
        )

def get_metrics_rollups_relay ( self , name , relay_name , metric ) : response = self . _perform_get ( self . _get_get_metrics_rollup_relay_path ( name , relay_name , metric ) , None ) return _MinidomXmlToObject . convert_response_to_feeds ( response , partial ( _ServiceBusManagementXmlSerializer . xml_to_metrics , object_type = MetricRollups ) )

This operation gets rollup data for Service Bus metrics relay . Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity .


def create(env_dir, system_site_packages=False, clear=False,
                    symlinks=False, with_pip=False, prompt=None):
    """Create a virtual environment in a directory."""
    builder = ExtendedEnvBuilder(system_site_packages=system_site_packages,
                                 clear=clear, symlinks=symlinks, with_pip=with_pip,
                                 prompt=prompt)
    builder.create(env_dir)
    return builder.context

def create ( env_dir , system_site_packages = False , clear = False , symlinks = False , with_pip = False , prompt = None ) : builder = ExtendedEnvBuilder ( system_site_packages = system_site_packages , clear = clear , symlinks = symlinks , with_pip = with_pip , prompt = prompt ) builder . create ( env_dir ) return builder . context

Create a virtual environment in a directory .


def create_venv_with_package(packages):
    """Create a venv with these packages in a temp dir and yielf the env.

    packages should be an iterable of pip version instructio (e.g. package~=1.2.3)
    """
    with tempfile.TemporaryDirectory() as tempdir:
        myenv = create(tempdir, with_pip=True)
        pip_call = [
            myenv.env_exe,
            "-m",
            "pip",
            "install",
        ]
        subprocess.check_call(pip_call + ['-U', 'pip'])
        if packages:
            subprocess.check_call(pip_call + packages)
        yield myenv

def create_venv_with_package ( packages ) : with tempfile . TemporaryDirectory ( ) as tempdir : myenv = create ( tempdir , with_pip = True ) pip_call = [ myenv . env_exe , "-m" , "pip" , "install" , ] subprocess . check_call ( pip_call + [ '-U' , 'pip' ] ) if packages : subprocess . check_call ( pip_call + packages ) yield myenv

Create a venv with these packages in a temp dir and yielf the env .


def create_server(self, admin_login, admin_password, location):
        '''
        Create a new Azure SQL Database server.

        admin_login:
            The administrator login name for the new server.
        admin_password:
            The administrator login password for the new server.
        location:
            The region to deploy the new server.
        '''
        _validate_not_none('admin_login', admin_login)
        _validate_not_none('admin_password', admin_password)
        _validate_not_none('location', location)
        response = self.perform_post(
            self._get_servers_path(),
            _SqlManagementXmlSerializer.create_server_to_xml(
                admin_login,
                admin_password,
                location
            )
        )

        return _SqlManagementXmlSerializer.xml_to_create_server_response(
            response.body)

def create_server ( self , admin_login , admin_password , location ) : _validate_not_none ( 'admin_login' , admin_login ) _validate_not_none ( 'admin_password' , admin_password ) _validate_not_none ( 'location' , location ) response = self . perform_post ( self . _get_servers_path ( ) , _SqlManagementXmlSerializer . create_server_to_xml ( admin_login , admin_password , location ) ) return _SqlManagementXmlSerializer . xml_to_create_server_response ( response . body )

Create a new Azure SQL Database server .


def set_server_admin_password(self, server_name, admin_password):
        '''
        Reset the administrator password for a server.

        server_name:
            Name of the server to change the password.
        admin_password:
            The new administrator password for the server.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('admin_password', admin_password)
        return self._perform_post(
            self._get_servers_path(server_name) + '?op=ResetPassword',
            _SqlManagementXmlSerializer.set_server_admin_password_to_xml(
                admin_password
            )
        )

Reset the administrator password for a server .


def list_quotas(self, server_name):
        '''
        Gets quotas for an Azure SQL Database Server.

        server_name:
            Name of the server.
        '''
        _validate_not_none('server_name', server_name)
        response = self._perform_get(self._get_quotas_path(server_name),
                                     None)
        return _MinidomXmlToObject.parse_service_resources_response(
            response, ServerQuota)

def list_quotas ( self , server_name ) : _validate_not_none ( 'server_name' , server_name ) response = self . _perform_get ( self . _get_quotas_path ( server_name ) , None ) return _MinidomXmlToObject . parse_service_resources_response ( response , ServerQuota )

Gets quotas for an Azure SQL Database Server .


def get_server_event_logs(self, server_name, start_date,
                              interval_size_in_minutes, event_types=''):
        '''
        Gets the event logs for an Azure SQL Database Server.

        server_name:
            Name of the server to retrieve the event logs from.
        start_date:
            The starting date and time of the events to retrieve in UTC format,
            for example '2011-09-28 16:05:00'.
        interval_size_in_minutes:
            Size of the event logs to retrieve (in minutes).
            Valid values are: 5, 60, or 1440.
        event_types:
            The event type of the log entries you want to retrieve.
            Valid values are:
                - connection_successful
                - connection_failed
                - connection_terminated
                - deadlock
                - throttling
                - throttling_long_transaction
            To return all event types pass in an empty string.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('start_date', start_date)
        _validate_not_none('interval_size_in_minutes', interval_size_in_minutes)
        _validate_not_none('event_types', event_types)
        path = self._get_server_event_logs_path(server_name) + \
               '?startDate={0}&intervalSizeInMinutes={1}&eventTypes={2}'.format(
            start_date, interval_size_in_minutes, event_types)
        response = self._perform_get(path, None)
        return _MinidomXmlToObject.parse_service_resources_response(
            response, EventLog)

Gets the event logs for an Azure SQL Database Server .


def create_firewall_rule(self, server_name, name, start_ip_address,
                             end_ip_address):
        '''
        Creates an Azure SQL Database server firewall rule.

        server_name:
            Name of the server to set the firewall rule on.
        name:
            The name of the new firewall rule.
        start_ip_address:
            The lowest IP address in the range of the server-level firewall
            setting. IP addresses equal to or greater than this can attempt to
            connect to the server. The lowest possible IP address is 0.0.0.0.
        end_ip_address:
            The highest IP address in the range of the server-level firewall
            setting. IP addresses equal to or less than this can attempt to
            connect to the server. The highest possible IP address is
            255.255.255.255.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('name', name)
        _validate_not_none('start_ip_address', start_ip_address)
        _validate_not_none('end_ip_address', end_ip_address)
        return self._perform_post(
            self._get_firewall_rules_path(server_name),
            _SqlManagementXmlSerializer.create_firewall_rule_to_xml(
                name, start_ip_address, end_ip_address
            )
        )

Creates an Azure SQL Database server firewall rule .


def update_firewall_rule(self, server_name, name, start_ip_address,
                             end_ip_address):
        '''
        Update a firewall rule for an Azure SQL Database server.

        server_name:
            Name of the server to set the firewall rule on.
        name:
            The name of the firewall rule to update.
        start_ip_address:
            The lowest IP address in the range of the server-level firewall
            setting. IP addresses equal to or greater than this can attempt to
            connect to the server. The lowest possible IP address is 0.0.0.0.
        end_ip_address:
            The highest IP address in the range of the server-level firewall
            setting. IP addresses equal to or less than this can attempt to
            connect to the server. The highest possible IP address is
            255.255.255.255.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('name', name)
        _validate_not_none('start_ip_address', start_ip_address)
        _validate_not_none('end_ip_address', end_ip_address)
        return self._perform_put(
            self._get_firewall_rules_path(server_name, name),
            _SqlManagementXmlSerializer.update_firewall_rule_to_xml(
                name, start_ip_address, end_ip_address
            )
        )

def update_firewall_rule ( self , server_name , name , start_ip_address , end_ip_address ) : _validate_not_none ( 'server_name' , server_name ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'start_ip_address' , start_ip_address ) _validate_not_none ( 'end_ip_address' , end_ip_address ) return self . _perform_put ( self . _get_firewall_rules_path ( server_name , name ) , _SqlManagementXmlSerializer . update_firewall_rule_to_xml ( name , start_ip_address , end_ip_address ) )

Update a firewall rule for an Azure SQL Database server .


def delete_firewall_rule(self, server_name, name):
        '''
        Deletes an Azure SQL Database server firewall rule.

        server_name:
            Name of the server with the firewall rule you want to delete.
        name:
            Name of the firewall rule you want to delete.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('name', name)
        return self._perform_delete(
            self._get_firewall_rules_path(server_name, name))

def delete_firewall_rule ( self , server_name , name ) : _validate_not_none ( 'server_name' , server_name ) _validate_not_none ( 'name' , name ) return self . _perform_delete ( self . _get_firewall_rules_path ( server_name , name ) )

Deletes an Azure SQL Database server firewall rule .


def list_firewall_rules(self, server_name):
        '''
        Retrieves the set of firewall rules for an Azure SQL Database Server.

        server_name:
            Name of the server.
        '''
        _validate_not_none('server_name', server_name)
        response = self._perform_get(self._get_firewall_rules_path(server_name),
                                     None)
        return _MinidomXmlToObject.parse_service_resources_response(
            response, FirewallRule)

def list_firewall_rules ( self , server_name ) : _validate_not_none ( 'server_name' , server_name ) response = self . _perform_get ( self . _get_firewall_rules_path ( server_name ) , None ) return _MinidomXmlToObject . parse_service_resources_response ( response , FirewallRule )

Retrieves the set of firewall rules for an Azure SQL Database Server .


def list_service_level_objectives(self, server_name):
        '''
        Gets the service level objectives for an Azure SQL Database server.

        server_name:
            Name of the server.
        '''
        _validate_not_none('server_name', server_name)
        response = self._perform_get(
            self._get_service_objectives_path(server_name), None)
        return _MinidomXmlToObject.parse_service_resources_response(
            response, ServiceObjective)

def list_service_level_objectives ( self , server_name ) : _validate_not_none ( 'server_name' , server_name ) response = self . _perform_get ( self . _get_service_objectives_path ( server_name ) , None ) return _MinidomXmlToObject . parse_service_resources_response ( response , ServiceObjective )

Gets the service level objectives for an Azure SQL Database server .


def create_database(self, server_name, name, service_objective_id,
                        edition=None, collation_name=None,
                        max_size_bytes=None):
        '''
        Creates a new Azure SQL Database.

        server_name:
            Name of the server to contain the new database.
        name:
            Required. The name for the new database. See Naming Requirements
            in Azure SQL Database General Guidelines and Limitations and
            Database Identifiers for more information.
        service_objective_id:
            Required. The GUID corresponding to the performance level for
            Edition. See List Service Level Objectives for current values.
        edition:
            Optional. The Service Tier (Edition) for the new database. If
            omitted, the default is Web. Valid values are Web, Business,
            Basic, Standard, and Premium. See Azure SQL Database Service Tiers
            (Editions) and Web and Business Edition Sunset FAQ for more
            information.
        collation_name:
            Optional. The database collation. This can be any collation
            supported by SQL. If omitted, the default collation is used. See
            SQL Server Collation Support in Azure SQL Database General
            Guidelines and Limitations for more information.
        max_size_bytes:
            Optional. Sets the maximum size, in bytes, for the database. This
            value must be within the range of allowed values for Edition. If
            omitted, the default value for the edition is used. See Azure SQL
            Database Service Tiers (Editions) for current maximum databases
            sizes. Convert MB or GB values to bytes.
            1 MB = 1048576 bytes. 1 GB = 1073741824 bytes.
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('name', name)
        _validate_not_none('service_objective_id', service_objective_id)
        return self._perform_post(
            self._get_databases_path(server_name),
            _SqlManagementXmlSerializer.create_database_to_xml(
                name, service_objective_id, edition, collation_name,
                max_size_bytes
            )
        )

def create_database ( self , server_name , name , service_objective_id , edition = None , collation_name = None , max_size_bytes = None ) : _validate_not_none ( 'server_name' , server_name ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'service_objective_id' , service_objective_id ) return self . _perform_post ( self . _get_databases_path ( server_name ) , _SqlManagementXmlSerializer . create_database_to_xml ( name , service_objective_id , edition , collation_name , max_size_bytes ) )


def update_database(self, server_name, name, new_database_name=None,
                        service_objective_id=None, edition=None,
                        max_size_bytes=None):
        '''
        Updates existing database details.

        server_name:
            Name of the server to contain the new database.
        name:
            Required. The name for the new database. See Naming Requirements
            in Azure SQL Database General Guidelines and Limitations and
            Database Identifiers for more information.
        new_database_name:
            Optional. The new name for the new database.
        service_objective_id:
            Optional. The new service level to apply to the database. For more
            information about service levels, see Azure SQL Database Service
            Tiers and Performance Levels. Use List Service Level Objectives to
            get the correct ID for the desired service objective.
        edition:
            Optional. The new edition for the new database.
        max_size_bytes:
            Optional. The new size of the database in bytes. For information on
            available sizes for each edition, see Azure SQL Database Service
            Tiers (Editions).
        '''
        _validate_not_none('server_name', server_name)
        _validate_not_none('name', name)
        return self._perform_put(
            self._get_databases_path(server_name, name),
            _SqlManagementXmlSerializer.update_database_to_xml(
                new_database_name, service_objective_id, edition,
                max_size_bytes
            )
        )

def update_database ( self , server_name , name , new_database_name = None , service_objective_id = None , edition = None , max_size_bytes = None ) : _validate_not_none ( 'server_name' , server_name ) _validate_not_none ( 'name' , name ) return self . _perform_put ( self . _get_databases_path ( server_name , name ) , _SqlManagementXmlSerializer . update_database_to_xml ( new_database_name , service_objective_id , edition , max_size_bytes ) )


def delete_database(self, server_name, name):
        '''
        Deletes an Azure SQL Database.

        server_name:
            Name of the server where the database is located.
        name:
            Name of the database to delete.
        '''
        return self._perform_delete(self._get_databases_path(server_name, name))

def delete_database ( self , server_name , name ) : return self . _perform_delete ( self . _get_databases_path ( server_name , name ) )


def list_databases(self, name):
        '''
        List the SQL databases defined on the specified server name
        '''
        response = self._perform_get(self._get_list_databases_path(name),
                                     None)
        return _MinidomXmlToObject.parse_service_resources_response(
            response, Database)

def list_databases ( self , name ) : response = self . _perform_get ( self . _get_list_databases_path ( name ) , None ) return _MinidomXmlToObject . parse_service_resources_response ( response , Database )


def list_agreements(
            self, name, include_privacy=None, for_transfer=None, custom_headers=None, raw=False, **operation_config):
        """Gets all legal agreements that user needs to accept before purchasing a
        domain.

        Gets all legal agreements that user needs to accept before purchasing a
        domain.

        :param name: Name of the top-level domain.
        :type name: str
        :param include_privacy: If true, then the list of
         agreements will include agreements for domain privacy as well;
         otherwise, false.
        :type include_privacy: bool
        :param for_transfer: If true, then the list of agreements
         will include agreements for domain transfer as well; otherwise,
         false.
        :type for_transfer: bool
        :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>`.
        :return: An iterator like instance of TldLegalAgreement
        :rtype:
         ~azure.mgmt.web.models.TldLegalAgreementPaged[~azure.mgmt.web.models.TldLegalAgreement]
        :raises:
         :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
        """
        agreement_option = models.TopLevelDomainAgreementOption(include_privacy=include_privacy, for_transfer=for_transfer)

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = self.list_agreements.metadata['url']
                path_format_arguments = {
                    'name': self._serialize.url("name", 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')

            else:
                url = next_link
                query_parameters = {}

            # Construct headers
            header_parameters = {}
            header_parameters['Accept'] = 'application/json'
            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(agreement_option, 'TopLevelDomainAgreementOption')

            # Construct and send request
            request = self._client.post(url, query_parameters, header_parameters, body_content)
            response = self._client.send(request, stream=False, **operation_config)

            if response.status_code not in [200]:
                raise models.DefaultErrorResponseException(self._deserialize, response)

            return response

        # Deserialize response
        deserialized = models.TldLegalAgreementPaged(internal_paging, self._deserialize.dependencies)

        if raw:
            header_dict = {}
            client_raw_response = models.TldLegalAgreementPaged(internal_paging, self._deserialize.dependencies, header_dict)
            return client_raw_response

        return deserialized

def
list_agreements
(
self
,
name
,
include_privacy
=
,
for_transfer
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
agreement_option
=
models
.
TopLevelDomainAgreementOption
(
include_privacy
=
include_privacy
,
for_transfer
=
for_transfer
)
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
# Construct URL
url
=
self
.
list_agreements
.
metadata
[
'url'
]
path_format_arguments
=
{
'name'
:
self
.
_serialize
.
url
(
"name"
,
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'
)
else
:
url
=
next_link
query_parameters
=
{
}
# Construct headers
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
agreement_option
,
'TopLevelDomainAgreementOption'
)
# Construct and send request
request
=
self
.
_client
.
post
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
DefaultErrorResponseException
(
self
.
_deserialize
,
response
)
return
response
# Deserialize response
deserialized
=
models
.
TldLegalAgreementPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
TldLegalAgreementPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

Gets all legal agreements that user needs to accept before purchasing a domain .


async def close(self, exception=None):
        """Close down the handler connection.

        If the handler has already closed,
        this operation will do nothing. An optional exception can be passed in to
        indicate that the handler was shutdown due to error.
        It is recommended to open a handler within a context manager as
        opposed to calling the method directly.

        .. note:: This operation is not thread-safe.

        :param exception: An optional exception if the handler is closing
         due to an error.
        :type exception: Exception

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START open_close_sender_directly]
                :end-before: [END open_close_sender_directly]
                :language: python
                :dedent: 4
                :caption: Explicitly open and close a Sender.

        """
        self.running = False
        if self.error:
            return
        if isinstance(exception, ServiceBusError):
            self.error = exception
        elif exception:
            self.error = ServiceBusError(str(exception))
        else:
            self.error = ServiceBusError("This message handler is now closed.")
        await self._handler.close_async()

async
def
close
(
self
,
exception
=
)
:
self
.
running
=
False
if
self
.
error
:
return
if
isinstance
(
exception
,
ServiceBusError
)
:
self
.
error
=
exception
elif
exception
:
self
.
error
=
ServiceBusError
(
str
(
exception
)
)
else
:
self
.
error
=
ServiceBusError
(
"This message handler is now closed."
)
await
self
.
_handler
.
close_async
(
)


async def close(self, exception=None):
        """Close down the receiver connection.

        If the receiver has already closed, this operation will do nothing. An optional
        exception can be passed in to indicate that the handler was shutdown due to error.
        It is recommended to open a handler within a context manager as
        opposed to calling the method directly.
        The receiver will be implicitly closed on completion of the message iterator,
        however this method will need to be called explicitly if the message iterator is not run
        to completion.

        .. note:: This operation is not thread-safe.

        :param exception: An optional exception if the handler is closing
         due to an error.
        :type exception: Exception

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START open_close_receiver_directly]
                :end-before: [END open_close_receiver_directly]
                :language: python
                :dedent: 4
                :caption: Iterate then explicitly close a Receiver.

        """
        if not self.running:
            return
        self.running = False
        self.receiver_shutdown = True
        self._used.set()
        await super(Receiver, self).close(exception=exception)

async def close ( self , exception = None ) : if not self . running : return self . running = False self . receiver_shutdown = True self . _used . set ( ) await super ( Receiver , self ) . close ( exception = exception )


async def get_session_state(self):
        """Get the session state.

        Returns None if no state has been set.

        :rtype: str

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START set_session_state]
                :end-before: [END set_session_state]
                :language: python
                :dedent: 4
                :caption: Getting and setting the state of a session.

        """
        await self._can_run()
        response = await self._mgmt_request_response(
            REQUEST_RESPONSE_GET_SESSION_STATE_OPERATION,
            {'session-id': self.session_id},
            mgmt_handlers.default)
        session_state = response.get(b'session-state')
        if isinstance(session_state, six.binary_type):
            session_state = session_state.decode('UTF-8')
        return session_state


async def set_session_state(self, state):
        """Set the session state.

        :param state: The state value.
        :type state: str or bytes or bytearray

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START set_session_state]
                :end-before: [END set_session_state]
                :language: python
                :dedent: 4
                :caption: Getting and setting the state of a session.

        """
        await self._can_run()
        state = state.encode(self.encoding) if isinstance(state, six.text_type) else state
        return await self._mgmt_request_response(
            REQUEST_RESPONSE_SET_SESSION_STATE_OPERATION,
            {'session-id': self.session_id, 'session-state': bytearray(state)},
            mgmt_handlers.default)


async def receive_deferred_messages(self, sequence_numbers, mode=ReceiveSettleMode.PeekLock):
        """Receive messages that have previously been deferred.

        This operation can only receive deferred messages from the current session.
        When receiving deferred messages from a partitioned entity, all of the supplied
        sequence numbers must be messages from the same partition.

        :param sequence_numbers: A list of the sequence numbers of messages that have been
         deferred.
        :type sequence_numbers: list[int]
        :param mode: The receive mode, default value is PeekLock.
        :type mode: ~azure.servicebus.common.constants.ReceiveSettleMode
        :rtype: list[~azure.servicebus.aio.async_message.DeferredMessage]

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START receiver_defer_session_messages]
                :end-before: [END receiver_defer_session_messages]
                :language: python
                :dedent: 8
                :caption: Defer messages, then retrieve them by sequence number.

        """
        if not sequence_numbers:
            raise ValueError("At least one sequence number must be specified.")
        await self._can_run()
        try:
            receive_mode = mode.value.value
        except AttributeError:
            receive_mode = int(mode)
        message = {
            'sequence-numbers': types.AMQPArray([types.AMQPLong(s) for s in sequence_numbers]),
            'receiver-settle-mode': types.AMQPuInt(receive_mode),
            'session-id': self.session_id
        }
        handler = functools.partial(mgmt_handlers.deferred_message_op, mode=receive_mode, message_type=DeferredMessage)
        messages = await self._mgmt_request_response(
            REQUEST_RESPONSE_RECEIVE_BY_SEQUENCE_NUMBER,
            message,
            handler)
        for m in messages:
            m._receiver = self  # pylint: disable=protected-access
        return messages

Receive messages that have previously been deferred .


def merge(
            self, reservation_order_id, sources=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Merges two `Reservation`s.

        Merge the specified `Reservation`s into a new `Reservation`. The two
        `Reservation`s being merged must have same properties.

        :param reservation_order_id: Order Id of the reservation
        :type reservation_order_id: str
        :param sources: Format of the resource id should be
         /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}
        :type sources: list[str]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns list or
         ClientRawResponse<list> if raw==True
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.reservations.models.ReservationResponse]]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.reservations.models.ReservationResponse]]]
        :raises:
         :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>`
        """
        raw_result = self._merge_initial(
            reservation_order_id=reservation_order_id,
            sources=sources,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            deserialized = self._deserialize('[ReservationResponse]', response)

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

            return deserialized

        lro_delay = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
        elif polling is False: polling_method = NoPolling()
        else: polling_method = polling
        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)

def merge ( self , reservation_order_id , sources = None , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _merge_initial ( reservation_order_id = reservation_order_id , sources = sources , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( '[ReservationResponse]' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) return client_raw_response return deserialized lro_delay = operation_config . get ( 'long_running_operation_timeout' , self . config . long_running_operation_timeout ) if polling is True : polling_method = ARMPolling ( lro_delay , * * operation_config ) elif polling is False : polling_method = NoPolling ( ) else : polling_method = polling return LROPoller ( self . _client , raw_result , get_long_running_output , polling_method )


def _validate_challenge(self, challenge):
        """ Verifies that the challenge is a Bearer challenge and returns the key=value pairs. """
        bearer_string = 'Bearer '
        if not challenge:
            raise ValueError('Challenge cannot be empty')

        challenge = challenge.strip()
        if not challenge.startswith(bearer_string):
            raise ValueError('Challenge is not Bearer')

        return challenge[len(bearer_string):]

def
_validate_challenge
(
self
,
challenge
)
:
bearer_string
=
'Bearer '
if
not
challenge
:
raise
ValueError
(
'Challenge cannot be empty'
)
challenge
=
challenge
.
strip
(
)
if
not
challenge
.
startswith
(
bearer_string
)
:
raise
ValueError
(
'Challenge is not Bearer'
)
return
challenge
[
len
(
bearer_string
)
:
]

Verifies that the challenge is a Bearer challenge and returns the key = value pairs .


def purge(
            self, resource_group_name, workspace_name, table, filters, custom_headers=None, raw=False, polling=True, **operation_config):
        """Purges data in an Log Analytics workspace by a set of user-defined
        filters.

        :param resource_group_name: The name of the resource group to get. The
         name is case insensitive.
        :type resource_group_name: str
        :param workspace_name: Log Analytics workspace name
        :type workspace_name: str
        :param table: Table from which to purge data.
        :type table: str
        :param filters: The set of columns and filters (queries) to run over
         them to purge the resulting data.
        :type filters:
         list[~azure.mgmt.loganalytics.models.WorkspacePurgeBodyFilters]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns object or
         ClientRawResponse<object> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[object] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[object]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._purge_initial(
            resource_group_name=resource_group_name,
            workspace_name=workspace_name,
            table=table,
            filters=filters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            deserialized = self._deserialize('object', response)

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

            return deserialized

        lro_delay = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
        elif polling is False: polling_method = NoPolling()
        else: polling_method = polling
        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)

def purge ( self , resource_group_name , workspace_name , table , filters , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _purge_initial ( resource_group_name = resource_group_name , workspace_name = workspace_name , table = table , filters = filters , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( 'object' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) return client_raw_response return deserialized lro_delay = operation_config . get ( 'long_running_operation_timeout' , self . config . long_running_operation_timeout ) if polling is True : polling_method = ARMPolling ( lro_delay , * * operation_config ) elif polling is False : polling_method = NoPolling ( ) else : polling_method = polling return LROPoller ( self . _client , raw_result , get_long_running_output , polling_method )

Purges data in an Log Analytics workspace by a set of user - defined filters .


def _error_handler(error):
    """Handle connection and service errors.

    Called internally when an event has failed to send so we
    can parse the error to determine whether we should attempt
    to retry sending the event again.
    Returns the action to take according to error type.

    :param error: The error received in the send attempt.
    :type error: Exception
    :rtype: ~uamqp.errors.ErrorAction
    """
    if error.condition == b'com.microsoft:server-busy':
        return errors.ErrorAction(retry=True, backoff=4)
    if error.condition == b'com.microsoft:timeout':
        return errors.ErrorAction(retry=True, backoff=2)
    if error.condition == b'com.microsoft:operation-cancelled':
        return errors.ErrorAction(retry=True)
    if error.condition == b"com.microsoft:container-close":
        return errors.ErrorAction(retry=True, backoff=4)
    if error.condition in _NO_RETRY_ERRORS:
        return errors.ErrorAction(retry=False)
    return errors.ErrorAction(retry=True)

def _error_handler ( error ) : if error . condition == b'com.microsoft:server-busy' : return errors . ErrorAction ( retry = True , backoff = 4 ) if error . condition == b'com.microsoft:timeout' : return errors . ErrorAction ( retry = True , backoff = 2 ) if error . condition == b'com.microsoft:operation-cancelled' : return errors . ErrorAction ( retry = True ) if error . condition == b"com.microsoft:container-close" : return errors . ErrorAction ( retry = True , backoff = 4 ) if error . condition in _NO_RETRY_ERRORS : return errors . ErrorAction ( retry = False ) return errors . ErrorAction ( retry = True )


def create_queue(self, queue_name, queue=None, fail_on_exist=False):
        '''
        Creates a new queue. Once created, this queue's resource manifest is
        immutable.

        queue_name:
            Name of the queue to create.
        queue:
            Queue object to create.
        fail_on_exist:
            Specify whether to throw an exception when the queue exists.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + ''
        request.body = _get_request_body(_convert_queue_to_xml(queue))
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        if not fail_on_exist:
            try:
                self._perform_request(request)
                return True
            except AzureHttpError as ex:
                _dont_fail_on_exist(ex)
                return False
        else:
            self._perform_request(request)
            return True

def
create_queue
(
self
,
queue_name
,
queue
=
,
fail_on_exist
=
False
)
:
_validate_not_none
(
'queue_name'
,
queue_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'PUT'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
queue_name
)
+
''
request
.
body
=
_get_request_body
(
_convert_queue_to_xml
(
queue
)
)
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
if
not
fail_on_exist
:
try
:
self
.
_perform_request
(
request
)
return
True
except
AzureHttpError
as
ex
:
_dont_fail_on_exist
(
ex
)
return
False
else
:
self
.
_perform_request
(
request
)
return
True

Creates a new queue . Once created this queue s resource manifest is immutable .


def delete_queue(self, queue_name, fail_not_exist=False):
        '''
        Deletes an existing queue. This operation will also remove all
        associated state including messages in the queue.

        queue_name:
            Name of the queue to delete.
        fail_not_exist:
            Specify whether to throw an exception if the queue doesn't exist.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + ''
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        if not fail_not_exist:
            try:
                self._perform_request(request)
                return True
            except AzureHttpError as ex:
                _dont_fail_not_exist(ex)
                return False
        else:
            self._perform_request(request)
            return True

def
delete_queue
(
self
,
queue_name
,
fail_not_exist
=
False
)
:
_validate_not_none
(
'queue_name'
,
queue_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'DELETE'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
queue_name
)
+
''
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
if
not
fail_not_exist
:
try
:
self
.
_perform_request
(
request
)
return
True
except
AzureHttpError
as
ex
:
_dont_fail_not_exist
(
ex
)
return
False
else
:
self
.
_perform_request
(
request
)
return
True

Deletes an existing queue . This operation will also remove all associated state including messages in the queue .


def get_queue(self, queue_name):
        '''
        Retrieves an existing queue.

        queue_name:
            Name of the queue.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + ''
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _convert_response_to_queue(response)

def
get_queue
(
self
,
queue_name
)
:
_validate_not_none
(
'queue_name'
,
queue_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
queue_name
)
+
''
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_convert_response_to_queue
(
response
)


def create_topic(self, topic_name, topic=None, fail_on_exist=False):
        '''
        Creates a new topic. Once created, this topic resource manifest is
        immutable.

        topic_name:
            Name of the topic to create.
        topic:
            Topic object to create.
        fail_on_exist:
            Specify whether to throw an exception when the topic exists.
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + ''
        request.body = _get_request_body(_convert_topic_to_xml(topic))
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        if not fail_on_exist:
            try:
                self._perform_request(request)
                return True
            except AzureHttpError as ex:
                _dont_fail_on_exist(ex)
                return False
        else:
            self._perform_request(request)
            return True

def
create_topic
(
self
,
topic_name
,
topic
=
,
fail_on_exist
=
False
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'PUT'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
''
request
.
body
=
_get_request_body
(
_convert_topic_to_xml
(
topic
)
)
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
if
not
fail_on_exist
:
try
:
self
.
_perform_request
(
request
)
return
True
except
AzureHttpError
as
ex
:
_dont_fail_on_exist
(
ex
)
return
False
else
:
self
.
_perform_request
(
request
)
return
True

Creates a new topic . Once created this topic resource manifest is immutable .


def get_topic(self, topic_name):
        '''
        Retrieves the description for the specified topic.

        topic_name:
            Name of the topic.
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + ''
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _convert_response_to_topic(response)

def
get_topic
(
self
,
topic_name
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
''
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_convert_response_to_topic
(
response
)

Retrieves the description for the specified topic .


def create_rule(self, topic_name, subscription_name, rule_name, rule=None,
                    fail_on_exist=False):
        '''
        Creates a new rule. Once created, this rule's resource manifest is
        immutable.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        rule_name:
            Name of the rule.
        fail_on_exist:
            Specify whether to throw an exception when the rule exists.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        _validate_not_none('rule_name', rule_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + \
            _str(subscription_name) + \
            '/rules/' + _str(rule_name) + ''
        request.body = _get_request_body(_convert_rule_to_xml(rule))
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        if not fail_on_exist:
            try:
                self._perform_request(request)
                return True
            except AzureHttpError as ex:
                _dont_fail_on_exist(ex)
                return False
        else:
            self._perform_request(request)
            return True

def
create_rule
(
self
,
topic_name
,
subscription_name
,
rule_name
,
rule
=
,
fail_on_exist
=
False
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'subscription_name'
,
subscription_name
)
_validate_not_none
(
'rule_name'
,
rule_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'PUT'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
+
_str
(
subscription_name
)
+
'/rules/'
+
_str
(
rule_name
)
+
''
request
.
body
=
_get_request_body
(
_convert_rule_to_xml
(
rule
)
)
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
if
not
fail_on_exist
:
try
:
self
.
_perform_request
(
request
)
return
True
except
AzureHttpError
as
ex
:
_dont_fail_on_exist
(
ex
)
return
False
else
:
self
.
_perform_request
(
request
)
return
True

Creates a new rule . Once created this rule s resource manifest is immutable .


def get_rule(self, topic_name, subscription_name, rule_name):
        '''
        Retrieves the description for the specified rule.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        rule_name:
            Name of the rule.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        _validate_not_none('rule_name', rule_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + \
            _str(subscription_name) + \
            '/rules/' + _str(rule_name) + ''
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _convert_response_to_rule(response)

def
get_rule
(
self
,
topic_name
,
subscription_name
,
rule_name
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'subscription_name'
,
subscription_name
)
_validate_not_none
(
'rule_name'
,
rule_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
+
_str
(
subscription_name
)
+
'/rules/'
+
_str
(
rule_name
)
+
''
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_convert_response_to_rule
(
response
)

Retrieves the description for the specified rule .


def list_rules(self, topic_name, subscription_name):
        '''
        Retrieves the rules that exist under the specified subscription.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + \
            _str(topic_name) + '/subscriptions/' + \
            _str(subscription_name) + '/rules/'
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _ETreeXmlToObject.convert_response_to_feeds(
            response, _convert_etree_element_to_rule)

def
list_rules
(
self
,
topic_name
,
subscription_name
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'subscription_name'
,
subscription_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
+
_str
(
subscription_name
)
+
'/rules/'
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_ETreeXmlToObject
.
convert_response_to_feeds
(
response
,
_convert_etree_element_to_rule
)

Retrieves the rules that exist under the specified subscription .


def create_subscription(self, topic_name, subscription_name,
                            subscription=None, fail_on_exist=False):
        '''
        Creates a new subscription. Once created, this subscription resource
        manifest is immutable.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        fail_on_exist:
            Specify whether throw exception when subscription exists.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + \
            _str(topic_name) + '/subscriptions/' + _str(subscription_name) + ''
        request.body = _get_request_body(
            _convert_subscription_to_xml(subscription))
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        if not fail_on_exist:
            try:
                self._perform_request(request)
                return True
            except AzureHttpError as ex:
                _dont_fail_on_exist(ex)
                return False
        else:
            self._perform_request(request)
            return True

def
create_subscription
(
self
,
topic_name
,
subscription_name
,
subscription
=
,
fail_on_exist
=
False
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'subscription_name'
,
subscription_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'PUT'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
+
_str
(
subscription_name
)
+
''
request
.
body
=
_get_request_body
(
_convert_subscription_to_xml
(
subscription
)
)
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
if
not
fail_on_exist
:
try
:
self
.
_perform_request
(
request
)
return
True
except
AzureHttpError
as
ex
:
_dont_fail_on_exist
(
ex
)
return
False
else
:
self
.
_perform_request
(
request
)
return
True

Creates a new subscription . Once created this subscription resource manifest is immutable .


def get_subscription(self, topic_name, subscription_name):
        '''
        Gets an existing subscription.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + \
            _str(topic_name) + '/subscriptions/' + _str(subscription_name) + ''
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _convert_response_to_subscription(response)

def
get_subscription
(
self
,
topic_name
,
subscription_name
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'subscription_name'
,
subscription_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
+
_str
(
subscription_name
)
+
''
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_convert_response_to_subscription
(
response
)


def list_subscriptions(self, topic_name):
        '''
        Retrieves the subscriptions in the specified topic.

        topic_name:
            Name of the topic.
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/'
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _ETreeXmlToObject.convert_response_to_feeds(
            response, _convert_etree_element_to_subscription)

def
list_subscriptions
(
self
,
topic_name
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
request
=
HTTPRequest
(
)
request
.
method
=
'GET'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/subscriptions/'
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
response
=
self
.
_perform_request
(
request
)
return
_ETreeXmlToObject
.
convert_response_to_feeds
(
response
,
_convert_etree_element_to_subscription
)

Retrieves the subscriptions in the specified topic .


def send_topic_message(self, topic_name, message=None):
        '''
        Enqueues a message into the specified topic. The limit to the number
        of messages which may be present in the topic is governed by the
        message size in MaxTopicSizeInBytes. If this message causes the topic
        to exceed its quota, a quota exceeded error is returned and the
        message will be rejected.

        topic_name:
            Name of the topic.
        message:
            Message object containing message body and properties.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('message', message)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/messages'
        request.headers = message.add_headers(request)
        request.body = _get_request_body(message.body)
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers = self._update_service_bus_header(request)
        self._perform_request(request)

def
send_topic_message
(
self
,
topic_name
,
message
=
)
:
_validate_not_none
(
'topic_name'
,
topic_name
)
_validate_not_none
(
'message'
,
message
)
request
=
HTTPRequest
(
)
request
.
method
=
'POST'
request
.
host
=
self
.
_get_host
(
)
request
.
path
=
'/'
+
_str
(
topic_name
)
+
'/messages'
request
.
headers
=
message
.
add_headers
(
request
)
request
.
body
=
_get_request_body
(
message
.
body
)
request
.
path
,
request
.
query
=
self
.
_httpclient
.
_update_request_uri_query
(
request
)
# pylint: disable=protected-access
request
.
headers
=
self
.
_update_service_bus_header
(
request
)
self
.
_perform_request
(
request
)

Enqueues a message into the specified topic . The limit to the number of messages which may be present in the topic is governed by the message size in MaxTopicSizeInBytes . If this message causes the topic to exceed its quota a quota exceeded error is returned and the message will be rejected .