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
:
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
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
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'
)
body_content
=
self
.
_serialize
.
body
(
agreement_option
,
'TopLevelDomainAgreementOption'
)
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
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 = None , 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 ) 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 ) 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 ) 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 = None , 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 ) 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 ) 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 = None , 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 ) 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 ) 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 ) 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 = None , 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 ) 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 ) 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 ) 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 = None ) : _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 ) 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 .


def unlock_subscription_message(self, topic_name, subscription_name,
                                    sequence_number, lock_token):
        '''
        Unlock a message for processing by other receivers on a given
        subscription. This operation deletes the lock object, causing the
        message to be unlocked. A message must have first been locked by a
        receiver before this operation is called.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        sequence_number:
            The sequence number of the message to be unlocked as returned in
            BrokerProperties['SequenceNumber'] by the Peek Message operation.
        lock_token:
            The ID of the lock as returned by the Peek Message operation in
            BrokerProperties['LockToken']
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        _validate_not_none('sequence_number', sequence_number)
        _validate_not_none('lock_token', lock_token)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + \
                       '/subscriptions/' + str(subscription_name) + \
                       '/messages/' + _str(sequence_number) + \
                       '/' + _str(lock_token) + ''
        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 unlock_subscription_message ( self , topic_name , subscription_name , sequence_number , lock_token ) : _validate_not_none ( 'topic_name' , topic_name ) _validate_not_none ( 'subscription_name' , subscription_name ) _validate_not_none ( 'sequence_number' , sequence_number ) _validate_not_none ( 'lock_token' , lock_token ) request = HTTPRequest ( ) request . method = 'PUT' request . host = self . _get_host ( ) request . path = '/' + _str ( topic_name ) + '/subscriptions/' + str ( subscription_name ) + '/messages/' + _str ( sequence_number ) + '/' + _str ( lock_token ) + '' request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers = self . _update_service_bus_header ( request ) self . _perform_request ( request )

Unlock a message for processing by other receivers on a given subscription . This operation deletes the lock object causing the message to be unlocked . A message must have first been locked by a receiver before this operation is called .


def send_queue_message_batch(self, queue_name, messages=None):
        '''
        Sends a batch of messages into the specified queue. The limit to the number of
        messages which may be present in the topic is governed by the message
        size the MaxTopicSizeInMegaBytes. If this message will cause the queue
        to exceed its quota, a quota exceeded error is returned and the
        message will be rejected.

        queue_name:
            Name of the queue.
        messages:
            List of message objects containing message body and properties.
        '''
        _validate_not_none('queue_name', queue_name)
        _validate_not_none('messages', messages)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + '/messages'
        request.headers.append(('Content-Type', 'application/vnd.microsoft.servicebus.json'))
        request.body = _get_request_body(json.dumps([m.as_batch_body() for m in messages]))
        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)

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


def unlock_queue_message(self, queue_name, sequence_number, lock_token):
        '''
        Unlocks a message for processing by other receivers on a given
        queue. This operation deletes the lock object, causing the
        message to be unlocked. A message must have first been locked by a
        receiver before this operation is called.

        queue_name:
            Name of the queue.
        sequence_number:
            The sequence number of the message to be unlocked as returned in
            BrokerProperties['SequenceNumber'] by the Peek Message operation.
        lock_token:
            The ID of the lock as returned by the Peek Message operation in
            BrokerProperties['LockToken']
        '''
        _validate_not_none('queue_name', queue_name)
        _validate_not_none('sequence_number', sequence_number)
        _validate_not_none('lock_token', lock_token)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + \
                       '/messages/' + _str(sequence_number) + \
                       '/' + _str(lock_token) + ''
        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 unlock_queue_message ( self , queue_name , sequence_number , lock_token ) : _validate_not_none ( 'queue_name' , queue_name ) _validate_not_none ( 'sequence_number' , sequence_number ) _validate_not_none ( 'lock_token' , lock_token ) request = HTTPRequest ( ) request . method = 'PUT' request . host = self . _get_host ( ) request . path = '/' + _str ( queue_name ) + '/messages/' + _str ( sequence_number ) + '/' + _str ( lock_token ) + '' request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers = self . _update_service_bus_header ( request ) self . _perform_request ( request )

Unlocks a message for processing by other receivers on a given queue . This operation deletes the lock object causing the message to be unlocked . A message must have first been locked by a receiver before this operation is called .


def receive_queue_message(self, queue_name, peek_lock=True, timeout=60):
        '''
        Receive a message from a queue for processing.

        queue_name:
            Name of the queue.
        peek_lock:
            Optional. True to retrieve and lock the message. False to read and
            delete the message. Default is True (lock).
        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        if peek_lock:
            return self.peek_lock_queue_message(queue_name, timeout)
        return self.read_delete_queue_message(queue_name, timeout)

def receive_queue_message ( self , queue_name , peek_lock = True , timeout = 60 ) : if peek_lock : return self . peek_lock_queue_message ( queue_name , timeout ) return self . read_delete_queue_message ( queue_name , timeout )

Receive a message from a queue for processing .


def receive_subscription_message(self, topic_name, subscription_name,
                                     peek_lock=True, timeout=60):
        '''
        Receive a message from a subscription for processing.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        peek_lock:
            Optional. True to retrieve and lock the message. False to read and
            delete the message. Default is True (lock).
        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        if peek_lock:
            return self.peek_lock_subscription_message(topic_name,
                                                       subscription_name,
                                                       timeout)
        return self.read_delete_subscription_message(topic_name,
                                                     subscription_name,
                                                     timeout)

def receive_subscription_message ( self , topic_name , subscription_name , peek_lock = True , timeout = 60 ) : if peek_lock : return self . peek_lock_subscription_message ( topic_name , subscription_name , timeout ) return self . read_delete_subscription_message ( topic_name , subscription_name , timeout )

Receive a message from a subscription for processing .


def create_event_hub(self, hub_name, hub=None, fail_on_exist=False):
        '''
        Creates a new Event Hub.

        hub_name:
            Name of event hub.
        hub:
            Optional. Event hub properties. Instance of EventHub class.
        hub.message_retention_in_days:
            Number of days to retain the events for this Event Hub.
        hub.status:
            Status of the Event Hub (enabled or disabled).
        hub.user_metadata:
            User metadata.
        hub.partition_count:
            Number of shards on the Event Hub.
        fail_on_exist:
            Specify whether to throw an exception when the event hub exists.
        '''
        _validate_not_none('hub_name', hub_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(hub_name) + '?api-version=2014-01'
        request.body = _get_request_body(_convert_event_hub_to_xml(hub))
        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_event_hub ( self , hub_name , hub = None , fail_on_exist = False ) : _validate_not_none ( 'hub_name' , hub_name ) request = HTTPRequest ( ) request . method = 'PUT' request . host = self . _get_host ( ) request . path = '/' + _str ( hub_name ) + '?api-version=2014-01' request . body = _get_request_body ( _convert_event_hub_to_xml ( hub ) ) request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) 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 update_event_hub(self, hub_name, hub=None):
        '''
        Updates an Event Hub.

        hub_name:
            Name of event hub.
        hub:
            Optional. Event hub properties. Instance of EventHub class.
        hub.message_retention_in_days:
            Number of days to retain the events for this Event Hub.
        '''
        _validate_not_none('hub_name', hub_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/' + _str(hub_name) + '?api-version=2014-01'
        request.body = _get_request_body(_convert_event_hub_to_xml(hub))
        request.path, request.query = self._httpclient._update_request_uri_query(request)  # pylint: disable=protected-access
        request.headers.append(('If-Match', '*'))
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _convert_response_to_event_hub(response)

def update_event_hub ( self , hub_name , hub = None ) : _validate_not_none ( 'hub_name' , hub_name ) request = HTTPRequest ( ) request . method = 'PUT' request . host = self . _get_host ( ) request . path = '/' + _str ( hub_name ) + '?api-version=2014-01' request . body = _get_request_body ( _convert_event_hub_to_xml ( hub ) ) request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers . append ( ( 'If-Match' , '*' ) ) request . headers = self . _update_service_bus_header ( request ) response = self . _perform_request ( request ) return _convert_response_to_event_hub ( response )


def get_event_hub(self, hub_name):
        '''
        Retrieves an existing event hub.

        hub_name:
            Name of the event hub.
        '''
        _validate_not_none('hub_name', hub_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(hub_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_event_hub(response)

def get_event_hub ( self , hub_name ) : _validate_not_none ( 'hub_name' , hub_name ) request = HTTPRequest ( ) request . method = 'GET' request . host = self . _get_host ( ) request . path = '/' + _str ( hub_name ) + '' request . path , request . query = self . _httpclient . _update_request_uri_query ( request ) request . headers = self . _update_service_bus_header ( request ) response = self . _perform_request ( request ) return _convert_response_to_event_hub ( response )


def send_event(self, hub_name, message, device_id=None,
                   broker_properties=None):
        '''
        Sends a new message event to an Event Hub.
        '''
        _validate_not_none('hub_name', hub_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        if device_id:
            request.path = '/{0}/publishers/{1}/messages?api-version=2014-01'.format(hub_name, device_id)
        else:
            request.path = '/{0}/messages?api-version=2014-01'.format(hub_name)
        if broker_properties:
            request.headers.append(
                ('BrokerProperties', str(broker_properties)))
        request.body = _get_request_body(message)
        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)

Sends a new message event to an Event Hub .


def _update_service_bus_header(self, request):
        ''' Add additional headers for Service Bus. '''

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

        # 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 name.lower() == 'content-type':
                    break
            else:
                request.headers.append(
                    ('Content-Type',
                     'application/atom+xml;type=entry;charset=utf-8'))

        # Adds authorization header for authentication.
        self.authentication.sign_request(request, self._httpclient)

        return request.headers

Add additional headers for Service Bus .


def _get_authorization(self, request, httpclient):
        ''' return the signed string with token. '''
        return 'WRAP access_token="' + \
                self._get_token(request.host, request.path, httpclient) + '"'

def
_get_authorization
(
self
,
request
,
httpclient
)
:
return
'WRAP access_token="'
+
self
.
_get_token
(
request
.
host
,
request
.
path
,
httpclient
)
+
'"'


def _token_is_expired(self, token):  # pylint: disable=no-self-use
        ''' Check if token expires or not. '''
        time_pos_begin = token.find('ExpiresOn=') + len('ExpiresOn=')
        time_pos_end = token.find('&', time_pos_begin)
        token_expire_time = int(token[time_pos_begin:time_pos_end])
        time_now = time.mktime(time.localtime())

        # Adding 30 seconds so the token wouldn't be expired when we send the
        # token to server.
        return (token_expire_time - time_now) < 30

def _token_is_expired ( self , token ) : time_pos_begin = token . find ( 'ExpiresOn=' ) + len ( 'ExpiresOn=' ) time_pos_end = token . find ( '&' , time_pos_begin ) token_expire_time = int ( token [ time_pos_begin : time_pos_end ] ) time_now = time . mktime ( time . localtime ( ) ) return ( token_expire_time - time_now ) < 30


def _get_token(self, host, path, httpclient):
        '''
        Returns token for the request.

        host:
            the Service Bus service request.
        path:
            the Service Bus service request.
        '''
        wrap_scope = 'http://' + host + path + self.issuer + self.account_key

        # Check whether has unexpired cache, return cached token if it is still
        # usable.
        if wrap_scope in _tokens:
            token = _tokens[wrap_scope]
            if not self._token_is_expired(token):
                return token

        # get token from accessconstrol server
        request = HTTPRequest()
        request.protocol_override = 'https'
        request.host = host.replace('.servicebus.', '-sb.accesscontrol.')
        request.method = 'POST'
        request.path = '/WRAPv0.9'
        request.body = ('wrap_name=' + url_quote(self.issuer) +
                        '&wrap_password=' + url_quote(self.account_key) +
                        '&wrap_scope=' +
                        url_quote('http://' + host + path)).encode('utf-8')
        request.headers.append(('Content-Length', str(len(request.body))))
        resp = httpclient.perform_request(request)

        token = resp.body.decode('utf-8-sig')
        token = url_unquote(token[token.find('=') + 1:token.rfind('&')])
        _tokens[wrap_scope] = token

        return token

def _get_token ( self , host , path , httpclient ) : wrap_scope = 'http://' + host + path + self . issuer + self . account_key if wrap_scope in _tokens : token = _tokens [ wrap_scope ] if not self . _token_is_expired ( token ) : return token request = HTTPRequest ( ) request . protocol_override = 'https' request . host = host . replace ( '.servicebus.' , '-sb.accesscontrol.' ) request . method = 'POST' request . path = '/WRAPv0.9' request . body = ( 'wrap_name=' + url_quote ( self . issuer ) + '&wrap_password=' + url_quote ( self . account_key ) + '&wrap_scope=' + url_quote ( 'http://' + host + path ) ) . encode ( 'utf-8' ) request . headers . append ( ( 'Content-Length' , str ( len ( request . body ) ) ) ) resp = httpclient . perform_request ( request ) token = resp . body . decode ( 'utf-8-sig' ) token = url_unquote ( token [ token . find ( '=' ) + 1 : token . rfind ( '&' ) ] ) _tokens [ wrap_scope ] = token return token


def _update_request_uri_query(self, request):
        '''pulls the query string out of the URI and moves it into
        the query portion of the request object.  If there are already
        query parameters on the request the parameters in the URI will
        appear after the existing parameters'''

        if '?' in request.path:
            request.path, _, query_string = request.path.partition('?')
            if query_string:
                query_params = query_string.split('&')
                for query in query_params:
                    if '=' in query:
                        name, _, value = query.partition('=')
                        request.query.append((name, value))

        request.path = url_quote(request.path, '/()$=\',')

        # add encoded queries to request.path.
        if request.query:
            request.path += '?'
            for name, value in request.query:
                if value is not None:
                    request.path += name + '=' + url_quote(value, '/()$=\',') + '&'
            request.path = request.path[:-1]

        return request.path, request.query

def _update_request_uri_query ( self , request ) : if '?' in request . path : request . path , _ , query_string = request . path . partition ( '?' ) if query_string : query_params = query_string . split ( '&' ) for query in query_params : if '=' in query : name , _ , value = query . partition ( '=' ) request . query . append ( ( name , value ) ) request . path = url_quote ( request . path , '/()$=\',' ) if request . query : request . path += '?' for name , value in request . query : if value is not None : request . path += name + '=' + url_quote ( value , '/()$=\',' ) + '&' request . path = request . path [ : - 1 ] return request . path , request . query

pulls the query string out of the URI and moves it into the query portion of the request object . If there are already query parameters on the request the parameters in the URI will appear after the existing parameters


def reset_service_principal_profile(
            self, resource_group_name, resource_name, client_id, secret=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Reset Service Principal Profile of a managed cluster.

        Update the service principal Profile for a managed cluster.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param resource_name: The name of the managed cluster resource.
        :type resource_name: str
        :param client_id: The ID for the service principal.
        :type client_id: str
        :param secret: The secret password associated with the service
         principal in plain text.
        :type secret: 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 None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._reset_service_principal_profile_initial(
            resource_group_name=resource_group_name,
            resource_name=resource_name,
            client_id=client_id,
            secret=secret,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

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

        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)

Reset Service Principal Profile of a managed cluster .


def delete(self):
        ''' Deletes itself if find queue name or topic name and subscription
        name. '''
        if self._queue_name:
            self.service_bus_service.delete_queue_message(
                self._queue_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        elif self._topic_name and self._subscription_name:
            self.service_bus_service.delete_subscription_message(
                self._topic_name,
                self._subscription_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        else:
            raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_DELETE)

Deletes itself if find queue name or topic name and subscription name .


def unlock(self):
        ''' Unlocks itself if find queue name or topic name and subscription
        name. '''
        if self._queue_name:
            self.service_bus_service.unlock_queue_message(
                self._queue_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        elif self._topic_name and self._subscription_name:
            self.service_bus_service.unlock_subscription_message(
                self._topic_name,
                self._subscription_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        else:
            raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_UNLOCK)

Unlocks itself if find queue name or topic name and subscription name .


def renew_lock(self):
        ''' Renew lock on itself if find queue name or topic name and subscription
        name. '''
        if self._queue_name:
            self.service_bus_service.renew_lock_queue_message(
                self._queue_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        elif self._topic_name and self._subscription_name:
            self.service_bus_service.renew_lock_subscription_message(
                self._topic_name,
                self._subscription_name,
                self.broker_properties['SequenceNumber'],
                self.broker_properties['LockToken'])
        else:
            raise AzureServiceBusPeekLockError(_ERROR_MESSAGE_NOT_PEEK_LOCKED_ON_RENEW_LOCK)

Renew lock on itself if find queue name or topic name and subscription name .


def add_headers(self, request):
        ''' add addtional headers to request for message request.'''

        # Adds custom properties
        if self.custom_properties:
            for name, value in self.custom_properties.items():
                request.headers.append((name, self._serialize_escaped_properties_value(value)))

        # Adds content-type
        request.headers.append(('Content-Type', self.type))

        # Adds BrokerProperties
        if self.broker_properties:
            if hasattr(self.broker_properties, 'items'):
                broker_properties = {name: self._serialize_basic_properties_value(value)
                                     for name, value
                                     in self.broker_properties.items()}
                broker_properties = json.dumps(broker_properties)
            else:
                broker_properties = self.broker_properties
            request.headers.append(
                ('BrokerProperties', str(broker_properties)))

        return request.headers

def add_headers ( self , request ) : if self . custom_properties : for name , value in self . custom_properties . items ( ) : request . headers . append ( ( name , self . _serialize_escaped_properties_value ( value ) ) ) request . headers . append ( ( 'Content-Type' , self . type ) ) if self . broker_properties : if hasattr ( self . broker_properties , 'items' ) : broker_properties = { name : self . _serialize_basic_properties_value ( value ) for name , value in self . broker_properties . items ( ) } broker_properties = json . dumps ( broker_properties ) else : broker_properties = self . broker_properties request . headers . append ( ( 'BrokerProperties' , str ( broker_properties ) ) ) return request . headers

add addtional headers to request for message request .


def as_batch_body(self):
        ''' return the current message as expected by batch body format'''
        if sys.version_info >= (3,) and isinstance(self.body, bytes):
            # It HAS to be string to be serialized in JSON
            body = self.body.decode('utf-8')
        else:
            # Python 2.7 people handle this themself
            body = self.body
        result = {'Body': body}

        # Adds custom properties
        if self.custom_properties:
            result['UserProperties'] = {name: self._serialize_basic_properties_value(value)
                                        for name, value
                                        in self.custom_properties.items()}

        # Adds BrokerProperties
        if self.broker_properties:
            result['BrokerProperties'] = {name: self._serialize_basic_properties_value(value)
                                          for name, value
                                          in self.broker_properties.items()}

        return result

def as_batch_body ( self ) : if sys . version_info >= ( 3 , ) and isinstance ( self . body , bytes ) : body = self . body . decode ( 'utf-8' ) else : body = self . body result = { 'Body' : body } if self . custom_properties : result [ 'UserProperties' ] = { name : self . _serialize_basic_properties_value ( value ) for name , value in self . custom_properties . items ( ) } if self . broker_properties : result [ 'BrokerProperties' ] = { name : self . _serialize_basic_properties_value ( value ) for name , value in self . broker_properties . items ( ) } return result


def get_cluster_health(
            self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, custom_headers=None, raw=False, **operation_config):
        """Gets the health of a Service Fabric cluster.

        Use EventsHealthStateFilter to filter the collection of health events
        reported on the cluster based on the health state.
        Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter
        to filter the collection of nodes and applications returned based on
        their aggregated health state.

        :param nodes_health_state_filter: Allows filtering of the node health
         state objects returned in the result of cluster health query
         based on their health state. The possible values for this parameter
         include integer value of one of the
         following health states. Only nodes that match the filter are
         returned. All nodes are used to evaluate the aggregated health state.
         If not specified, all entries are returned.
         The state values are flag-based enumeration, so the value could be a
         combination of these values obtained using bitwise 'OR' operator.
         For example, if the provided value is 6 then health state of nodes
         with HealthState value of OK (2) and Warning (4) are returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type nodes_health_state_filter: int
        :param applications_health_state_filter: Allows filtering of the
         application health state objects returned in the result of cluster
         health
         query based on their health state.
         The possible values for this parameter include integer value obtained
         from members or bitwise operations
         on members of HealthStateFilter enumeration. Only applications that
         match the filter are returned.
         All applications are used to evaluate the aggregated health state. If
         not specified, all entries are returned.
         The state values are flag-based enumeration, so the value could be a
         combination of these values obtained using bitwise 'OR' operator.
         For example, if the provided value is 6 then health state of
         applications with HealthState value of OK (2) and Warning (4) are
         returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type applications_health_state_filter: int
        :param events_health_state_filter: Allows filtering the collection of
         HealthEvent objects returned based on health state.
         The possible values for this parameter include integer value of one of
         the following health states.
         Only events that match the filter are returned. All events are used to
         evaluate the aggregated health state.
         If not specified, all entries are returned. The state values are
         flag-based enumeration, so the value could be a combination of these
         values, obtained using the bitwise 'OR' operator. For example, If the
         provided value is 6 then all of the events with HealthState value of
         OK (2) and Warning (4) are returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type events_health_state_filter: int
        :param exclude_health_statistics: Indicates whether the health
         statistics should be returned as part of the query result. False by
         default.
         The statistics show the number of children entities in health state
         Ok, Warning, and Error.
        :type exclude_health_statistics: bool
        :param include_system_application_health_statistics: Indicates whether
         the health statistics should include the fabric:/System application
         health statistics. False by default.
         If IncludeSystemApplicationHealthStatistics is set to true, the health
         statistics include the entities that belong to the fabric:/System
         application.
         Otherwise, the query result includes health statistics only for user
         applications.
         The health statistics must be included in the query result for this
         parameter to be applied.
        :type include_system_application_health_statistics: bool
        :param timeout: The server timeout for performing the operation in
         seconds. This timeout specifies the time duration that the client is
         willing to wait for the requested operation to complete. The default
         value for this parameter is 60 seconds.
        :type timeout: long
        :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: ClusterHealth or ClientRawResponse if raw=true
        :rtype: ~azure.servicefabric.models.ClusterHealth or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        api_version = "6.0"

        # Construct URL
        url = self.get_cluster_health.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
        if nodes_health_state_filter is not None:
            query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int')
        if applications_health_state_filter is not None:
            query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int')
        if events_health_state_filter is not None:
            query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int')
        if exclude_health_statistics is not None:
            query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool')
        if include_system_application_health_statistics is not None:
            query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool')
        if timeout is not None:
            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1)

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized

Gets the health of a Service Fabric cluster .


def get_cluster_health_using_policy(
            self, nodes_health_state_filter=0, applications_health_state_filter=0, events_health_state_filter=0, exclude_health_statistics=False, include_system_application_health_statistics=False, timeout=60, application_health_policy_map=None, cluster_health_policy=None, custom_headers=None, raw=False, **operation_config):
        """Gets the health of a Service Fabric cluster using the specified policy.

        Use EventsHealthStateFilter to filter the collection of health events
        reported on the cluster based on the health state.
        Similarly, use NodesHealthStateFilter and ApplicationsHealthStateFilter
        to filter the collection of nodes and applications returned based on
        their aggregated health state.
        Use ClusterHealthPolicies to override the health policies used to
        evaluate the health.

        :param nodes_health_state_filter: Allows filtering of the node health
         state objects returned in the result of cluster health query
         based on their health state. The possible values for this parameter
         include integer value of one of the
         following health states. Only nodes that match the filter are
         returned. All nodes are used to evaluate the aggregated health state.
         If not specified, all entries are returned.
         The state values are flag-based enumeration, so the value could be a
         combination of these values obtained using bitwise 'OR' operator.
         For example, if the provided value is 6 then health state of nodes
         with HealthState value of OK (2) and Warning (4) are returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type nodes_health_state_filter: int
        :param applications_health_state_filter: Allows filtering of the
         application health state objects returned in the result of cluster
         health
         query based on their health state.
         The possible values for this parameter include integer value obtained
         from members or bitwise operations
         on members of HealthStateFilter enumeration. Only applications that
         match the filter are returned.
         All applications are used to evaluate the aggregated health state. If
         not specified, all entries are returned.
         The state values are flag-based enumeration, so the value could be a
         combination of these values obtained using bitwise 'OR' operator.
         For example, if the provided value is 6 then health state of
         applications with HealthState value of OK (2) and Warning (4) are
         returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type applications_health_state_filter: int
        :param events_health_state_filter: Allows filtering the collection of
         HealthEvent objects returned based on health state.
         The possible values for this parameter include integer value of one of
         the following health states.
         Only events that match the filter are returned. All events are used to
         evaluate the aggregated health state.
         If not specified, all entries are returned. The state values are
         flag-based enumeration, so the value could be a combination of these
         values, obtained using the bitwise 'OR' operator. For example, If the
         provided value is 6 then all of the events with HealthState value of
         OK (2) and Warning (4) are returned.
         - Default - Default value. Matches any HealthState. The value is zero.
         - None - Filter that doesn't match any HealthState value. Used in
         order to return no results on a given collection of states. The value
         is 1.
         - Ok - Filter that matches input with HealthState value Ok. The value
         is 2.
         - Warning - Filter that matches input with HealthState value Warning.
         The value is 4.
         - Error - Filter that matches input with HealthState value Error. The
         value is 8.
         - All - Filter that matches input with any HealthState value. The
         value is 65535.
        :type events_health_state_filter: int
        :param exclude_health_statistics: Indicates whether the health
         statistics should be returned as part of the query result. False by
         default.
         The statistics show the number of children entities in health state
         Ok, Warning, and Error.
        :type exclude_health_statistics: bool
        :param include_system_application_health_statistics: Indicates whether
         the health statistics should include the fabric:/System application
         health statistics. False by default.
         If IncludeSystemApplicationHealthStatistics is set to true, the health
         statistics include the entities that belong to the fabric:/System
         application.
         Otherwise, the query result includes health statistics only for user
         applications.
         The health statistics must be included in the query result for this
         parameter to be applied.
        :type include_system_application_health_statistics: bool
        :param timeout: The server timeout for performing the operation in
         seconds. This timeout specifies the time duration that the client is
         willing to wait for the requested operation to complete. The default
         value for this parameter is 60 seconds.
        :type timeout: long
        :param application_health_policy_map: Defines a map that contains
         specific application health policies for different applications.
         Each entry specifies as key the application name and as value an
         ApplicationHealthPolicy used to evaluate the application health.
         If an application is not specified in the map, the application health
         evaluation uses the ApplicationHealthPolicy found in its application
         manifest or the default application health policy (if no health policy
         is defined in the manifest).
         The map is empty by default.
        :type application_health_policy_map:
         list[~azure.servicefabric.models.ApplicationHealthPolicyMapItem]
        :param cluster_health_policy: Defines a health policy used to evaluate
         the health of the cluster or of a cluster node.
        :type cluster_health_policy:
         ~azure.servicefabric.models.ClusterHealthPolicy
        :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: ClusterHealth or ClientRawResponse if raw=true
        :rtype: ~azure.servicefabric.models.ClusterHealth or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        cluster_health_policies = None
        if application_health_policy_map is not None or cluster_health_policy is not None:
            cluster_health_policies = models.ClusterHealthPolicies(application_health_policy_map=application_health_policy_map, cluster_health_policy=cluster_health_policy)

        api_version = "6.0"

        # Construct URL
        url = self.get_cluster_health_using_policy.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
        if nodes_health_state_filter is not None:
            query_parameters['NodesHealthStateFilter'] = self._serialize.query("nodes_health_state_filter", nodes_health_state_filter, 'int')
        if applications_health_state_filter is not None:
            query_parameters['ApplicationsHealthStateFilter'] = self._serialize.query("applications_health_state_filter", applications_health_state_filter, 'int')
        if events_health_state_filter is not None:
            query_parameters['EventsHealthStateFilter'] = self._serialize.query("events_health_state_filter", events_health_state_filter, 'int')
        if exclude_health_statistics is not None:
            query_parameters['ExcludeHealthStatistics'] = self._serialize.query("exclude_health_statistics", exclude_health_statistics, 'bool')
        if include_system_application_health_statistics is not None:
            query_parameters['IncludeSystemApplicationHealthStatistics'] = self._serialize.query("include_system_application_health_statistics", include_system_application_health_statistics, 'bool')
        if timeout is not None:
            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1)

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        if cluster_health_policies is not None:
            body_content = self._serialize.body(cluster_health_policies, 'ClusterHealthPolicies')
        else:
            body_content = None

        # 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.FabricErrorException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized

Gets the health of a Service Fabric cluster using the specified policy .