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
)
# pylint: disable=protected-access
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
)
# pylint: disable=protected-access
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
=
,
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
)
# 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 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
=
)
:
_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 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
)
# 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 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 _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 _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
,
'/()$=\','
)
# add encoded queries to request.path.
if
request
.
query
:
request
.
path
+=
'?'
for
name
,
value
in
request
.
query
:
if
value
is
not
:
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
)
:
# 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

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 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 .


def unprovision_application_type(
            self, application_type_name, application_type_version, timeout=60, async_parameter=None, custom_headers=None, raw=False, **operation_config):
        """Removes or unregisters a Service Fabric application type from the
        cluster.

        This operation can only be performed if all application instances of
        the application type have been deleted. Once the application type is
        unregistered, no new application instances can be created for this
        particular application type.

        :param application_type_name: The name of the application type.
        :type application_type_name: str
        :param application_type_version: The version of the application type
         as defined in the application manifest.
        :type application_type_version: str
        :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 async_parameter: The flag indicating whether or not unprovision
         should occur asynchronously. When set to true, the unprovision
         operation returns when the request is accepted by the system, and the
         unprovision operation continues without any timeout limit. The default
         value is false. However, we recommend setting it to true for large
         application packages that were provisioned.
        :type async_parameter: 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: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        unprovision_application_type_description_info = models.UnprovisionApplicationTypeDescriptionInfo(application_type_version=application_type_version, async_property=async_parameter)

        api_version = "6.0"

        # Construct URL
        url = self.unprovision_application_type.metadata['url']
        path_format_arguments = {
            'applicationTypeName': self._serialize.url("application_type_name", application_type_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
        if timeout is not None:
            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'long', maximum=4294967295, minimum=1)

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

        # Construct body
        body_content = self._serialize.body(unprovision_application_type_description_info, 'UnprovisionApplicationTypeDescriptionInfo')

        # 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, 202]:
            raise models.FabricErrorException(self._deserialize, response)

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

Removes or unregisters a Service Fabric application type from the cluster .


def get_repair_task_list(
            self, task_id_filter=None, state_filter=None, executor_filter=None, custom_headers=None, raw=False, **operation_config):
        """Gets a list of repair tasks matching the given filters.

        This API supports the Service Fabric platform; it is not meant to be
        used directly from your code.

        :param task_id_filter: The repair task ID prefix to be matched.
        :type task_id_filter: str
        :param state_filter: A bitwise-OR of the following values, specifying
         which task states should be included in the result list.
         - 1 - Created
         - 2 - Claimed
         - 4 - Preparing
         - 8 - Approved
         - 16 - Executing
         - 32 - Restoring
         - 64 - Completed
        :type state_filter: int
        :param executor_filter: The name of the repair executor whose claimed
         tasks should be included in the list.
        :type executor_filter: str
        :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: list or ClientRawResponse if raw=true
        :rtype: list[~azure.servicefabric.models.RepairTask] or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        api_version = "6.0"

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

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
        if task_id_filter is not None:
            query_parameters['TaskIdFilter'] = self._serialize.query("task_id_filter", task_id_filter, 'str')
        if state_filter is not None:
            query_parameters['StateFilter'] = self._serialize.query("state_filter", state_filter, 'int')
        if executor_filter is not None:
            query_parameters['ExecutorFilter'] = self._serialize.query("executor_filter", executor_filter, 'str')

        # 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('[RepairTask]', response)

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

        return deserialized

def
get_repair_task_list
(
self
,
task_id_filter
=
,
state_filter
=
,
executor_filter
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
api_version
=
"6.0"
# Construct URL
url
=
self
.
get_repair_task_list
.
metadata
[
'url'
]
# Construct parameters
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"api_version"
,
api_version
,
'str'
)
if
task_id_filter
is
not
:
query_parameters
[
'TaskIdFilter'
]
=
self
.
_serialize
.
query
(
"task_id_filter"
,
task_id_filter
,
'str'
)
if
state_filter
is
not
:
query_parameters
[
'StateFilter'
]
=
self
.
_serialize
.
query
(
"state_filter"
,
state_filter
,
'int'
)
if
executor_filter
is
not
:
query_parameters
[
'ExecutorFilter'
]
=
self
.
_serialize
.
query
(
"executor_filter"
,
executor_filter
,
'str'
)
# 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
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'[RepairTask]'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Gets a list of repair tasks matching the given filters .


def submit_property_batch(
            self, name_id, timeout=60, operations=None, custom_headers=None, raw=False, **operation_config):
        """Submits a property batch.

        Submits a batch of property operations. Either all or none of the
        operations will be committed.

        :param name_id: The Service Fabric name, without the 'fabric:' URI
         scheme.
        :type name_id: str
        :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 operations: A list of the property batch operations to be
         executed.
        :type operations:
         list[~azure.servicefabric.models.PropertyBatchOperation]
        :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: PropertyBatchInfo or ClientRawResponse if raw=true
        :rtype: ~azure.servicefabric.models.PropertyBatchInfo or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        property_batch_description_list = models.PropertyBatchDescriptionList(operations=operations)

        api_version = "6.0"

        # Construct URL
        url = self.submit_property_batch.metadata['url']
        path_format_arguments = {
            'nameId': self._serialize.url("name_id", name_id, 'str', skip_quote=True)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
        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
        body_content = self._serialize.body(property_batch_description_list, 'PropertyBatchDescriptionList')

        # 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, 409]:
            raise models.FabricErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('SuccessfulPropertyBatchInfo', response)
        if response.status_code == 409:
            deserialized = self._deserialize('FailedPropertyBatchInfo', response)

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

        return deserialized

def
submit_property_batch
(
self
,
name_id
,
timeout
=
60
,
operations
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
property_batch_description_list
=
models
.
PropertyBatchDescriptionList
(
operations
=
operations
)
api_version
=
"6.0"
# Construct URL
url
=
self
.
submit_property_batch
.
metadata
[
'url'
]
path_format_arguments
=
{
'nameId'
:
self
.
_serialize
.
url
(
"name_id"
,
name_id
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"api_version"
,
api_version
,
'str'
)
if
timeout
is
not
:
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
body_content
=
self
.
_serialize
.
body
(
property_batch_description_list
,
'PropertyBatchDescriptionList'
)
# 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
,
409
]
:
raise
models
.
FabricErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'SuccessfulPropertyBatchInfo'
,
response
)
if
response
.
status_code
==
409
:
deserialized
=
self
.
_deserialize
(
'FailedPropertyBatchInfo'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized


def _general_error_handler(http_error):
    ''' Simple error handler for azure.'''
    message = str(http_error)
    if http_error.respbody is not None:
        message += '\n' + http_error.respbody.decode('utf-8-sig')
    raise AzureHttpError(message, http_error.status)

def _general_error_handler ( http_error ) : message = str ( http_error ) if http_error . respbody is not None : message += '\n' + http_error . respbody . decode ( 'utf-8-sig' ) raise AzureHttpError ( message , http_error . status )


def start_web_site_network_trace_operation(
            self, resource_group_name, name, duration_in_seconds=None, max_frame_length=None, sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Start capturing network packets for the site.

        Start capturing network packets for the site.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param name: The name of the web app.
        :type name: str
        :param duration_in_seconds: The duration to keep capturing in seconds.
        :type duration_in_seconds: int
        :param max_frame_length: The maximum frame length in bytes (Optional).
        :type max_frame_length: int
        :param sas_url: The Blob URL to store capture file.
        :type sas_url: 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.web.models.NetworkTrace]]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.web.models.NetworkTrace]]]
        :raises:
         :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
        """
        raw_result = self._start_web_site_network_trace_operation_initial(
            resource_group_name=resource_group_name,
            name=name,
            duration_in_seconds=duration_in_seconds,
            max_frame_length=max_frame_length,
            sas_url=sas_url,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            deserialized = self._deserialize('[NetworkTrace]', 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)

Start capturing network packets for the site .


def list_slot_differences_slot(
            self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, **operation_config):
        """Get the difference in configuration settings between two web app slots.

        Get the difference in configuration settings between two web app slots.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param name: Name of the app.
        :type name: str
        :param slot: Name of the source slot. If a slot is not specified, the
         production slot is used as the source slot.
        :type slot: str
        :param target_slot: Destination deployment slot during swap operation.
        :type target_slot: str
        :param preserve_vnet: true to preserve Virtual Network to
         the slot during swap; otherwise, false.
        :type preserve_vnet: 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 SlotDifference
        :rtype:
         ~azure.mgmt.web.models.SlotDifferencePaged[~azure.mgmt.web.models.SlotDifference]
        :raises:
         :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
        """
        slot_swap_entity = models.CsmSlotEntity(target_slot=target_slot, preserve_vnet=preserve_vnet)

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

            if not next_link:
                # Construct URL
                url = self.list_slot_differences_slot.metadata['url']
                path_format_arguments = {
                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
                    'name': self._serialize.url("name", name, 'str'),
                    'slot': self._serialize.url("slot", slot, '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(slot_swap_entity, 'CsmSlotEntity')

            # 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.SlotDifferencePaged(internal_paging, self._deserialize.dependencies)

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

        return deserialized

def
list_slot_differences_slot
(
self
,
resource_group_name
,
name
,
slot
,
target_slot
,
preserve_vnet
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
slot_swap_entity
=
models
.
CsmSlotEntity
(
target_slot
=
target_slot
,
preserve_vnet
=
preserve_vnet
)
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
# Construct URL
url
=
self
.
list_slot_differences_slot
.
metadata
[
'url'
]
path_format_arguments
=
{
'resourceGroupName'
:
self
.
_serialize
.
url
(
"resource_group_name"
,
resource_group_name
,
'str'
,
max_length
=
90
,
min_length
=
1
,
pattern
=
r'^[-\w\._\(\)]+[^\.]$'
)
,
'name'
:
self
.
_serialize
.
url
(
"name"
,
name
,
'str'
)
,
'slot'
:
self
.
_serialize
.
url
(
"slot"
,
slot
,
'str'
)
,
'subscriptionId'
:
self
.
_serialize
.
url
(
"self.config.subscription_id"
,
self
.
config
.
subscription_id
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
# Construct headers
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
slot_swap_entity
,
'CsmSlotEntity'
)
# 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
.
SlotDifferencePaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
SlotDifferencePaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

Get the difference in configuration settings between two web app slots .


def swap_slot_slot(
            self, resource_group_name, name, slot, target_slot, preserve_vnet, custom_headers=None, raw=False, polling=True, **operation_config):
        """Swaps two deployment slots of an app.

        Swaps two deployment slots of an app.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param name: Name of the app.
        :type name: str
        :param slot: Name of the source slot. If a slot is not specified, the
         production slot is used as the source slot.
        :type slot: str
        :param target_slot: Destination deployment slot during swap operation.
        :type target_slot: str
        :param preserve_vnet: true to preserve Virtual Network to
         the slot during swap; otherwise, false.
        :type preserve_vnet: bool
        :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._swap_slot_slot_initial(
            resource_group_name=resource_group_name,
            name=name,
            slot=slot,
            target_slot=target_slot,
            preserve_vnet=preserve_vnet,
            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)

def swap_slot_slot ( self , resource_group_name , name , slot , target_slot , preserve_vnet , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _swap_slot_slot_initial ( resource_group_name = resource_group_name , name = name , slot = slot , target_slot = target_slot , preserve_vnet = preserve_vnet , 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 )


def get_by_type(
            self, app_id, event_type, timespan=None, filter=None, search=None, orderby=None, select=None, skip=None, top=None, format=None, count=None, apply=None, custom_headers=None, raw=False, **operation_config):
        """Execute OData query.

        Executes an OData query for events.

        :param app_id: ID of the application. This is Application ID from the
         API Access settings blade in the Azure portal.
        :type app_id: str
        :param event_type: The type of events to query; either a standard
         event type (`traces`, `customEvents`, `pageViews`, `requests`,
         `dependencies`, `exceptions`, `availabilityResults`) or `$all` to
         query across all event types. Possible values include: '$all',
         'traces', 'customEvents', 'pageViews', 'browserTimings', 'requests',
         'dependencies', 'exceptions', 'availabilityResults',
         'performanceCounters', 'customMetrics'
        :type event_type: str or ~azure.applicationinsights.models.EventType
        :param timespan: Optional. The timespan over which to retrieve events.
         This is an ISO8601 time period value.  This timespan is applied in
         addition to any that are specified in the Odata expression.
        :type timespan: str
        :param filter: An expression used to filter the returned events
        :type filter: str
        :param search: A free-text search expression to match for whether a
         particular event should be returned
        :type search: str
        :param orderby: A comma-separated list of properties with \\"asc\\"
         (the default) or \\"desc\\" to control the order of returned events
        :type orderby: str
        :param select: Limits the properties to just those requested on each
         returned event
        :type select: str
        :param skip: The number of items to skip over before returning events
        :type skip: int
        :param top: The number of events to return
        :type top: int
        :param format: Format for the returned events
        :type format: str
        :param count: Request a count of matching items included with the
         returned events
        :type count: bool
        :param apply: An expression used for aggregation over returned events
        :type apply: str
        :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: EventsResults or ClientRawResponse if raw=true
        :rtype: ~azure.applicationinsights.models.EventsResults or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.applicationinsights.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.get_by_type.metadata['url']
        path_format_arguments = {
            'appId': self._serialize.url("app_id", app_id, 'str'),
            'eventType': self._serialize.url("event_type", event_type, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if timespan is not None:
            query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str')
        if filter is not None:
            query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
        if search is not None:
            query_parameters['$search'] = self._serialize.query("search", search, 'str')
        if orderby is not None:
            query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str')
        if select is not None:
            query_parameters['$select'] = self._serialize.query("select", select, 'str')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query("skip", skip, 'int')
        if top is not None:
            query_parameters['$top'] = self._serialize.query("top", top, 'int')
        if format is not None:
            query_parameters['$format'] = self._serialize.query("format", format, 'str')
        if count is not None:
            query_parameters['$count'] = self._serialize.query("count", count, 'bool')
        if apply is not None:
            query_parameters['$apply'] = self._serialize.query("apply", apply, 'str')

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

        deserialized = None

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

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

        return deserialized

def
get_by_type
(
self
,
app_id
,
event_type
,
timespan
=
,
filter
=
,
search
=
,
orderby
=
,
select
=
,
skip
=
,
top
=
,
format
=
,
count
=
,
apply
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
# Construct URL
url
=
self
.
get_by_type
.
metadata
[
'url'
]
path_format_arguments
=
{
'appId'
:
self
.
_serialize
.
url
(
"app_id"
,
app_id
,
'str'
)
,
'eventType'
:
self
.
_serialize
.
url
(
"event_type"
,
event_type
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
if
timespan
is
not
:
query_parameters
[
'timespan'
]
=
self
.
_serialize
.
query
(
"timespan"
,
timespan
,
'str'
)
if
filter
is
not
:
query_parameters
[
'$filter'
]
=
self
.
_serialize
.
query
(
"filter"
,
filter
,
'str'
)
if
search
is
not
:
query_parameters
[
'$search'
]
=
self
.
_serialize
.
query
(
"search"
,
search
,
'str'
)
if
orderby
is
not
:
query_parameters
[
'$orderby'
]
=
self
.
_serialize
.
query
(
"orderby"
,
orderby
,
'str'
)
if
select
is
not
:
query_parameters
[
'$select'
]
=
self
.
_serialize
.
query
(
"select"
,
select
,
'str'
)
if
skip
is
not
:
query_parameters
[
'$skip'
]
=
self
.
_serialize
.
query
(
"skip"
,
skip
,
'int'
)
if
top
is
not
:
query_parameters
[
'$top'
]
=
self
.
_serialize
.
query
(
"top"
,
top
,
'int'
)
if
format
is
not
:
query_parameters
[
'$format'
]
=
self
.
_serialize
.
query
(
"format"
,
format
,
'str'
)
if
count
is
not
:
query_parameters
[
'$count'
]
=
self
.
_serialize
.
query
(
"count"
,
count
,
'bool'
)
if
apply
is
not
:
query_parameters
[
'$apply'
]
=
self
.
_serialize
.
query
(
"apply"
,
apply
,
'str'
)
# 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
.
ErrorResponseException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'EventsResults'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized


def add_face_from_stream(
            self, large_face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config):
        """Add a face to a large face list. The input face is specified as an
        image with a targetFace rectangle. It returns a persistedFaceId
        representing the added face, and persistedFaceId will not expire.

        :param large_face_list_id: Id referencing a particular large face
         list.
        :type large_face_list_id: str
        :param image: An image stream.
        :type image: Generator
        :param user_data: User-specified data about the face for any purpose.
         The maximum length is 1KB.
        :type user_data: str
        :param target_face: A face rectangle to specify the target face to be
         added to a person in the format of "targetFace=left,top,width,height".
         E.g. "targetFace=10,10,100,100". If there is more than one face in the
         image, targetFace is required to specify which face to add. No
         targetFace means there is only one face detected in the entire image.
        :type target_face: list[int]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param callback: When specified, will be called with each chunk of
         data that is streamed. The callback should take two arguments, the
         bytes of the current chunk of data and the response object. If the
         data is uploading, response will be None.
        :type callback: Callable[Bytes, response=None]
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: PersistedFace or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.face.models.PersistedFace or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_face_from_stream.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'largeFaceListId': self._serialize.url("large_face_list_id", large_face_list_id, 'str', max_length=64, pattern=r'^[a-z0-9-_]+$')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if user_data is not None:
            query_parameters['userData'] = self._serialize.query("user_data", user_data, 'str', max_length=1024)
        if target_face is not None:
            query_parameters['targetFace'] = self._serialize.query("target_face", target_face, '[int]', div=',')

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

        # Construct body
        body_content = self._client.stream_upload(image, callback)

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

        deserialized = None

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

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

        return deserialized

def
add_face_from_stream
(
self
,
large_face_list_id
,
image
,
user_data
=
,
target_face
=
,
custom_headers
=
,
raw
=
False
,
callback
=
,
*
*
operation_config
)
:
# Construct URL
url
=
self
.
add_face_from_stream
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
,
'largeFaceListId'
:
self
.
_serialize
.
url
(
"large_face_list_id"
,
large_face_list_id
,
'str'
,
max_length
=
64
,
pattern
=
r'^[a-z0-9-_]+$'
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
if
user_data
is
not
:
query_parameters
[
'userData'
]
=
self
.
_serialize
.
query
(
"user_data"
,
user_data
,
'str'
,
max_length
=
1024
)
if
target_face
is
not
:
query_parameters
[
'targetFace'
]
=
self
.
_serialize
.
query
(
"target_face"
,
target_face
,
'[int]'
,
div
=
','
)
# Construct headers
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/octet-stream'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
# Construct body
body_content
=
self
.
_client
.
stream_upload
(
image
,
callback
)
# 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
.
APIErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'PersistedFace'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Add a face to a large face list . The input face is specified as an image with a targetFace rectangle . It returns a persistedFaceId representing the added face and persistedFaceId will not expire .


def _handle_redirect(self, r, **kwargs):
        """Reset auth_attempted on redirects."""
        if r.is_redirect:
            self._thread_local.auth_attempted = False

def _handle_redirect ( self , r , * * kwargs ) : if r . is_redirect : self . _thread_local . auth_attempted = False


def create_and_start_migration(
            self, resource_group_name, namespace_name, target_namespace, post_migration_name, custom_headers=None, raw=False, polling=True, **operation_config):
        """Creates Migration configuration and starts migration of entities from
        Standard to Premium namespace.

        :param resource_group_name: Name of the Resource group within the
         Azure subscription.
        :type resource_group_name: str
        :param namespace_name: The namespace name
        :type namespace_name: str
        :param target_namespace: Existing premium Namespace ARM Id name which
         has no entities, will be used for migration
        :type target_namespace: str
        :param post_migration_name: Name to access Standard Namespace after
         migration
        :type post_migration_name: 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
         MigrationConfigProperties or
         ClientRawResponse<MigrationConfigProperties> if raw==True
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servicebus.models.MigrationConfigProperties]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servicebus.models.MigrationConfigProperties]]
        :raises:
         :class:`ErrorResponseException<azure.mgmt.servicebus.models.ErrorResponseException>`
        """
        raw_result = self._create_and_start_migration_initial(
            resource_group_name=resource_group_name,
            namespace_name=namespace_name,
            target_namespace=target_namespace,
            post_migration_name=post_migration_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            deserialized = self._deserialize('MigrationConfigProperties', 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 create_and_start_migration ( self , resource_group_name , namespace_name , target_namespace , post_migration_name , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _create_and_start_migration_initial ( resource_group_name = resource_group_name , namespace_name = namespace_name , target_namespace = target_namespace , post_migration_name = post_migration_name , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( 'MigrationConfigProperties' , 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 )

Creates Migration configuration and starts migration of entities from Standard to Premium namespace .


def publish_events(
            self, topic_hostname, events, custom_headers=None, raw=False, **operation_config):
        """Publishes a batch of events to an Azure Event Grid topic.

        :param topic_hostname: The host name of the topic, e.g.
         topic1.westus2-1.eventgrid.azure.net
        :type topic_hostname: str
        :param events: An array of events to be published to Event Grid.
        :type events: list[~azure.eventgrid.models.EventGridEvent]
        :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: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        # Construct URL
        url = self.publish_events.metadata['url']
        path_format_arguments = {
            'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True)
        }
        url = self._client.format_url(url, **path_format_arguments)

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

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

        # Construct body
        body_content = self._serialize.body(events, '[EventGridEvent]')

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

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

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

def
publish_events
(
self
,
topic_hostname
,
events
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
# Construct URL
url
=
self
.
publish_events
.
metadata
[
'url'
]
path_format_arguments
=
{
'topicHostname'
:
self
.
_serialize
.
url
(
"topic_hostname"
,
topic_hostname
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
# Construct headers
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
events
,
'[EventGridEvent]'
)
# Construct and send request
request
=
self
.
_client
.
post
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
HttpOperationError
(
self
.
_deserialize
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
,
response
)
return
client_raw_response

Publishes a batch of events to an Azure Event Grid topic .