def getresponse(self):
        ''' Gets the response and generates the _Response object'''
        status = self._httprequest.status()
        status_text = self._httprequest.status_text()

        resp_headers = self._httprequest.get_all_response_headers()
        fixed_headers = []
        for resp_header in resp_headers.split('\n'):
            if (resp_header.startswith('\t') or\
                resp_header.startswith(' ')) and fixed_headers:
                # append to previous header
                fixed_headers[-1] += resp_header
            else:
                fixed_headers.append(resp_header)

        headers = []
        for resp_header in fixed_headers:
            if ':' in resp_header:
                pos = resp_header.find(':')
                headers.append(
                    (resp_header[:pos].lower(), resp_header[pos + 1:].strip()))

        body = self._httprequest.response_body()
        length = len(body)

        return _Response(status, status_text, length, headers, body)

def
getresponse
(
self
)
:
status
=
self
.
_httprequest
.
status
(
)
status_text
=
self
.
_httprequest
.
status_text
(
)
resp_headers
=
self
.
_httprequest
.
get_all_response_headers
(
)
fixed_headers
=
[
]
for
resp_header
in
resp_headers
.
split
(
'\n'
)
:
if
(
resp_header
.
startswith
(
'\t'
)
or
resp_header
.
startswith
(
' '
)
)
and
fixed_headers
:
fixed_headers
[
1
]
+=
resp_header
else
:
fixed_headers
.
append
(
resp_header
)
headers
=
[
]
for
resp_header
in
fixed_headers
:
if
':'
in
resp_header
:
pos
=
resp_header
.
find
(
':'
)
headers
.
append
(
(
resp_header
[
:
pos
]
.
lower
(
)
,
resp_header
[
pos
+
1
:
]
.
strip
(
)
)
)
body
=
self
.
_httprequest
.
response_body
(
)
length
=
len
(
body
)
return
_Response
(
status
,
status_text
,
length
,
headers
,
body
)


def _get_readable_id(id_name, id_prefix_to_skip):
    """simplified an id to be more friendly for us people"""
    # id_name is in the form 'https://namespace.host.suffix/name'
    # where name may contain a forward slash!
    pos = id_name.find('//')
    if pos != -1:
        pos += 2
        if id_prefix_to_skip:
            pos = id_name.find(id_prefix_to_skip, pos)
            if pos != -1:
                pos += len(id_prefix_to_skip)
        pos = id_name.find('/', pos)
        if pos != -1:
            return id_name[pos + 1:]
    return id_name

def _get_readable_id ( id_name , id_prefix_to_skip ) : pos = id_name . find ( '//' ) if pos != - 1 : pos += 2 if id_prefix_to_skip : pos = id_name . find ( id_prefix_to_skip , pos ) if pos != - 1 : pos += len ( id_prefix_to_skip ) pos = id_name . find ( '/' , pos ) if pos != - 1 : return id_name [ pos + 1 : ] return id_name


def _get_serialization_name(element_name):
    """converts a Python name into a serializable name"""
    known = _KNOWN_SERIALIZATION_XFORMS.get(element_name)
    if known is not None:
        return known

    if element_name.startswith('x_ms_'):
        return element_name.replace('_', '-')
    if element_name.endswith('_id'):
        element_name = element_name.replace('_id', 'ID')
    for name in ['content_', 'last_modified', 'if_', 'cache_control']:
        if element_name.startswith(name):
            element_name = element_name.replace('_', '-_')

    return ''.join(name.capitalize() for name in element_name.split('_'))

def _get_serialization_name ( element_name ) : known = _KNOWN_SERIALIZATION_XFORMS . get ( element_name ) if known is not None : return known if element_name . startswith ( 'x_ms_' ) : return element_name . replace ( '_' , '-' ) if element_name . endswith ( '_id' ) : element_name = element_name . replace ( '_id' , 'ID' ) for name in [ 'content_' , 'last_modified' , 'if_' , 'cache_control' ] : if element_name . startswith ( name ) : element_name = element_name . replace ( '_' , '-_' ) return '' . join ( name . capitalize ( ) for name in element_name . split ( '_' ) )


def verify_face_to_person(
            self, face_id, person_id, person_group_id=None, large_person_group_id=None, custom_headers=None, raw=False, **operation_config):
        """Verify whether two faces belong to a same person. Compares a face Id
        with a Person Id.

        :param face_id: FaceId of the face, comes from Face - Detect
        :type face_id: str
        :param person_id: Specify a certain person in a person group or a
         large person group. personId is created in PersonGroup Person - Create
         or LargePersonGroup Person - Create.
        :type person_id: str
        :param person_group_id: Using existing personGroupId and personId for
         fast loading a specified person. personGroupId is created in
         PersonGroup - Create. Parameter personGroupId and largePersonGroupId
         should not be provided at the same time.
        :type person_group_id: str
        :param large_person_group_id: Using existing largePersonGroupId and
         personId for fast loading a specified person. largePersonGroupId is
         created in LargePersonGroup - Create. Parameter personGroupId and
         largePersonGroupId should not be provided at the same time.
        :type large_person_group_id: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: VerifyResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.face.models.VerifyResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
        """
        body = models.VerifyFaceToPersonRequest(face_id=face_id, person_group_id=person_group_id, large_person_group_id=large_person_group_id, person_id=person_id)

        # Construct URL
        url = self.verify_face_to_person.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # 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(body, 'VerifyFaceToPersonRequest')

        # 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('VerifyResult', response)

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

        return deserialized

def
verify_face_to_person
(
self
,
face_id
,
person_id
,
person_group_id
=
,
large_person_group_id
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
body
=
models
.
VerifyFaceToPersonRequest
(
face_id
=
face_id
,
person_group_id
=
person_group_id
,
large_person_group_id
=
large_person_group_id
,
person_id
=
person_id
)
url
=
self
.
verify_face_to_person
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
body_content
=
self
.
_serialize
.
body
(
body
,
'VerifyFaceToPersonRequest'
)
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
(
'VerifyResult'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Verify whether two faces belong to a same person . Compares a face Id with a Person Id .


def add(
            self, job, job_add_options=None, custom_headers=None, raw=False, **operation_config):
        """Adds a job to the specified account.

        The Batch service supports two ways to control the work done as part of
        a job. In the first approach, the user specifies a Job Manager task.
        The Batch service launches this task when it is ready to start the job.
        The Job Manager task controls all other tasks that run under this job,
        by using the Task APIs. In the second approach, the user directly
        controls the execution of tasks under an active job, by using the Task
        APIs. Also note: when naming jobs, avoid including sensitive
        information such as user names or secret project names. This
        information may appear in telemetry logs accessible to Microsoft
        Support engineers.

        :param job: The job to be added.
        :type job: ~azure.batch.models.JobAddParameter
        :param job_add_options: Additional parameters for the operation
        :type job_add_options: ~azure.batch.models.JobAddOptions
        :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:`BatchErrorException<azure.batch.models.BatchErrorException>`
        """
        timeout = None
        if job_add_options is not None:
            timeout = job_add_options.timeout
        client_request_id = None
        if job_add_options is not None:
            client_request_id = job_add_options.client_request_id
        return_client_request_id = None
        if job_add_options is not None:
            return_client_request_id = job_add_options.return_client_request_id
        ocp_date = None
        if job_add_options is not None:
            ocp_date = job_add_options.ocp_date

        # Construct URL
        url = self.add.metadata['url']
        path_format_arguments = {
            'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, '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')
        if timeout is not None:
            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['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')
        if client_request_id is not None:
            header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str')
        if return_client_request_id is not None:
            header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool')
        if ocp_date is not None:
            header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123')

        # Construct body
        body_content = self._serialize.body(job, 'JobAddParameter')

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            client_raw_response.add_headers({
                'client-request-id': 'str',
                'request-id': 'str',
                'ETag': 'str',
                'Last-Modified': 'rfc-1123',
                'DataServiceId': 'str',
            })
            return client_raw_response


def get_entry_properties_from_node(entry, include_id, id_prefix_to_skip=None, use_title_as_id=False):
        ''' get properties from entry xml '''
        properties = {}

        etag = entry.getAttributeNS(METADATA_NS, 'etag')
        if etag:
            properties['etag'] = etag
        for updated in _MinidomXmlToObject.get_child_nodes(entry, 'updated'):
            properties['updated'] = updated.firstChild.nodeValue
        for name in _MinidomXmlToObject.get_children_from_path(entry, 'author', 'name'):
            if name.firstChild is not None:
                properties['author'] = name.firstChild.nodeValue

        if include_id:
            if use_title_as_id:
                for title in _MinidomXmlToObject.get_child_nodes(entry, 'title'):
                    properties['name'] = title.firstChild.nodeValue
            else:
                # TODO: check if this is used
                for id in _MinidomXmlToObject.get_child_nodes(entry, 'id'):
                    properties['name'] = _get_readable_id(
                        id.firstChild.nodeValue, id_prefix_to_skip)

        return properties

def get_entry_properties_from_node ( entry , include_id , id_prefix_to_skip = None , use_title_as_id = False ) : properties = { } etag = entry . getAttributeNS ( METADATA_NS , 'etag' ) if etag : properties [ 'etag' ] = etag for updated in _MinidomXmlToObject . get_child_nodes ( entry , 'updated' ) : properties [ 'updated' ] = updated . firstChild . nodeValue for name in _MinidomXmlToObject . get_children_from_path ( entry , 'author' , 'name' ) : if name . firstChild is not None : properties [ 'author' ] = name . firstChild . nodeValue if include_id : if use_title_as_id : for title in _MinidomXmlToObject . get_child_nodes ( entry , 'title' ) : properties [ 'name' ] = title . firstChild . nodeValue else : for id in _MinidomXmlToObject . get_child_nodes ( entry , 'id' ) : properties [ 'name' ] = _get_readable_id ( id . firstChild . nodeValue , id_prefix_to_skip ) return properties


def get_children_from_path(node, *path):
        '''descends through a hierarchy of nodes returning the list of children
        at the inner most level.  Only returns children who share a common parent,
        not cousins.'''
        cur = node
        for index, child in enumerate(path):
            if isinstance(child, _strtype):
                next = _MinidomXmlToObject.get_child_nodes(cur, child)
            else:
                next = _MinidomXmlToObject._get_child_nodesNS(cur, *child)
            if index == len(path) - 1:
                return next
            elif not next:
                break

            cur = next[0]
        return []

def get_children_from_path ( node , * path ) : cur = node for index , child in enumerate ( path ) : if isinstance ( child , _strtype ) : next = _MinidomXmlToObject . get_child_nodes ( cur , child ) else : next = _MinidomXmlToObject . _get_child_nodesNS ( cur , * child ) if index == len ( path ) - 1 : return next elif not next : break cur = next [ 0 ] return [ ]

descends through a hierarchy of nodes returning the list of children at the inner most level . Only returns children who share a common parent not cousins .


def _find_namespaces_from_child(parent, child, namespaces):
        """Recursively searches from the parent to the child,
        gathering all the applicable namespaces along the way"""
        for cur_child in parent.childNodes:
            if cur_child is child:
                return True
            if _MinidomXmlToObject._find_namespaces_from_child(cur_child, child, namespaces):
                # we are the parent node
                for key in cur_child.attributes.keys():
                    if key.startswith('xmlns:') or key == 'xmlns':
                        namespaces[key] = cur_child.attributes[key]
                break
        return False

def _find_namespaces_from_child ( parent , child , namespaces ) : for cur_child in parent . childNodes : if cur_child is child : return True if _MinidomXmlToObject . _find_namespaces_from_child ( cur_child , child , namespaces ) : for key in cur_child . attributes . keys ( ) : if key . startswith ( 'xmlns:' ) or key == 'xmlns' : namespaces [ key ] = cur_child . attributes [ key ] break return False

Recursively searches from the parent to the child gathering all the applicable namespaces along the way


def xml_to_namespace(xmlstr):
        '''Converts xml response to service bus namespace

        The xml format for namespace:
<entry>
<id>uuid:00000000-0000-0000-0000-000000000000;id=0000000</id>
<title type="text">myunittests</title>
<updated>2012-08-22T16:48:10Z</updated>
<content type="application/xml">
    <NamespaceDescription
        xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"
        xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Name>myunittests</Name>
    <Region>West US</Region>
    <DefaultKey>0000000000000000000000000000000000000000000=</DefaultKey>
    <Status>Active</Status>
    <CreatedAt>2012-08-22T16:48:10.217Z</CreatedAt>
    <AcsManagementEndpoint>https://myunittests-sb.accesscontrol.windows.net/</AcsManagementEndpoint>
    <ServiceBusEndpoint>https://myunittests.servicebus.windows.net/</ServiceBusEndpoint>
    <ConnectionString>Endpoint=sb://myunittests.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=0000000000000000000000000000000000000000000=</ConnectionString>
    <SubscriptionId>00000000000000000000000000000000</SubscriptionId>
    <Enabled>true</Enabled>
    </NamespaceDescription>
</content>
</entry>
        '''
        xmldoc = minidom.parseString(xmlstr)
        namespace = ServiceBusNamespace()

        mappings = (
            ('Name', 'name', None),
            ('Region', 'region', None),
            ('DefaultKey', 'default_key', None),
            ('Status', 'status', None),
            ('CreatedAt', 'created_at', None),
            ('AcsManagementEndpoint', 'acs_management_endpoint', None),
            ('ServiceBusEndpoint', 'servicebus_endpoint', None),
            ('ConnectionString', 'connection_string', None),
            ('SubscriptionId', 'subscription_id', None),
            ('Enabled', 'enabled', _parse_bool),
        )

        for desc in _MinidomXmlToObject.get_children_from_path(
            xmldoc,
            'entry',
            'content',
            'NamespaceDescription'):
            for xml_name, field_name, conversion_func in mappings:
                node_value = _MinidomXmlToObject.get_first_child_node_value(desc, xml_name)
                if node_value is not None:
                    if conversion_func is not None:
                        node_value = conversion_func(node_value)
                    setattr(namespace, field_name, node_value)

        return namespace

def xml_to_namespace ( xmlstr ) : xmldoc = minidom . parseString ( xmlstr ) namespace = ServiceBusNamespace ( ) mappings = ( ( 'Name' , 'name' , None ) , ( 'Region' , 'region' , None ) , ( 'DefaultKey' , 'default_key' , None ) , ( 'Status' , 'status' , None ) , ( 'CreatedAt' , 'created_at' , None ) , ( 'AcsManagementEndpoint' , 'acs_management_endpoint' , None ) , ( 'ServiceBusEndpoint' , 'servicebus_endpoint' , None ) , ( 'ConnectionString' , 'connection_string' , None ) , ( 'SubscriptionId' , 'subscription_id' , None ) , ( 'Enabled' , 'enabled' , _parse_bool ) , ) for desc in _MinidomXmlToObject . get_children_from_path ( xmldoc , 'entry' , 'content' , 'NamespaceDescription' ) : for xml_name , field_name , conversion_func in mappings : node_value = _MinidomXmlToObject . get_first_child_node_value ( desc , xml_name ) if node_value is not None : if conversion_func is not None : node_value = conversion_func ( node_value ) setattr ( namespace , field_name , node_value ) return namespace


def xml_to_region(xmlstr):
        '''Converts xml response to service bus region

        The xml format for region:
<entry>
<id>uuid:157c311f-081f-4b4a-a0ba-a8f990ffd2a3;id=1756759</id>
<title type="text"></title>
<updated>2013-04-10T18:25:29Z</updated>
<content type="application/xml">
    <RegionCodeDescription
        xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"
        xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    East Asia
    <FullName>East Asia</FullName>
    </RegionCodeDescription>
</content>
</entry>
          '''
        xmldoc = minidom.parseString(xmlstr)
        region = ServiceBusRegion()

        for desc in _MinidomXmlToObject.get_children_from_path(xmldoc, 'entry', 'content',
                                            'RegionCodeDescription'):
            node_value = _MinidomXmlToObject.get_first_child_node_value(desc, 'Code')
            if node_value is not None:
                region.code = node_value
            node_value = _MinidomXmlToObject.get_first_child_node_value(desc, 'FullName')
            if node_value is not None:
                region.fullname = node_value

        return region

def xml_to_region ( xmlstr ) : xmldoc = minidom . parseString ( xmlstr ) region = ServiceBusRegion ( ) for desc in _MinidomXmlToObject . get_children_from_path ( xmldoc , 'entry' , 'content' , 'RegionCodeDescription' ) : node_value = _MinidomXmlToObject . get_first_child_node_value ( desc , 'Code' ) if node_value is not None : region . code = node_value node_value = _MinidomXmlToObject . get_first_child_node_value ( desc , 'FullName' ) if node_value is not None : region . fullname = node_value return region


def xml_to_namespace_availability(xmlstr):
        '''Converts xml response to service bus namespace availability

        The xml format:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <id>uuid:9fc7c652-1856-47ab-8d74-cd31502ea8e6;id=3683292</id>
    <title type="text"></title>
    <updated>2013-04-16T03:03:37Z</updated>
    <content type="application/xml">
        <NamespaceAvailability
            xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"
            xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <Result>false</Result>
        </NamespaceAvailability>
    </content>
</entry>
        '''
        xmldoc = minidom.parseString(xmlstr)
        availability = AvailabilityResponse()

        for desc in _MinidomXmlToObject.get_children_from_path(xmldoc, 'entry', 'content',
                                            'NamespaceAvailability'):
            node_value = _MinidomXmlToObject.get_first_child_node_value(desc, 'Result')
            if node_value is not None:
                availability.result = _parse_bool(node_value)

        return availability

def xml_to_namespace_availability ( xmlstr ) : xmldoc = minidom . parseString ( xmlstr ) availability = AvailabilityResponse ( ) for desc in _MinidomXmlToObject . get_children_from_path ( xmldoc , 'entry' , 'content' , 'NamespaceAvailability' ) : node_value = _MinidomXmlToObject . get_first_child_node_value ( desc , 'Result' ) if node_value is not None : availability . result = _parse_bool ( node_value ) return availability


def xml_to_metrics(xmlstr, object_type):
        '''Converts xml response to service bus metrics objects

        The xml format for MetricProperties
<entry>
    <id>https://sbgm.windows.net/Metrics(\'listeners.active\')</id>
    <title/>
    <updated>2014-10-09T11:56:50Z</updated>
    <author>
        <name/>
    </author>
    <content type="application/xml">
        <m:properties>
            <d:Name>listeners.active</d:Name>
            <d:PrimaryAggregation>Average</d:PrimaryAggregation>
            <d:Unit>Count</d:Unit>
            <d:DisplayName>Active listeners</d:DisplayName>
        </m:properties>
    </content>
</entry>

        The xml format for MetricValues
    <entry>
        <id>https://sbgm.windows.net/MetricValues(datetime\'2014-10-02T00:00:00Z\')</id>
        <title/>
        <updated>2014-10-09T18:38:28Z</updated>
        <author>
            <name/>
        </author>
        <content type="application/xml">
            <m:properties>
                <d:Timestamp m:type="Edm.DateTime">2014-10-02T00:00:00Z</d:Timestamp>
                <d:Min m:type="Edm.Int64">-118</d:Min>
                <d:Max m:type="Edm.Int64">15</d:Max>
                <d:Average m:type="Edm.Single">-78.44444</d:Average>
                <d:Total m:type="Edm.Int64">0</d:Total>
            </m:properties>
        </content>
    </entry>
        '''

        xmldoc = minidom.parseString(xmlstr)
        return_obj = object_type()

        members = dict(vars(return_obj))

        # Only one entry here
        for xml_entry in _MinidomXmlToObject.get_children_from_path(xmldoc,
                                                 'entry'):
            for node in _MinidomXmlToObject.get_children_from_path(xml_entry,
                                                'content',
                                                'properties'):
                for name in members:
                    xml_name = _get_serialization_name(name)
                    children = _MinidomXmlToObject.get_child_nodes(node, xml_name)
                    if not children:
                        continue
                    child = children[0]
                    node_type = child.getAttributeNS("http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", 'type')
                    node_value = _ServiceBusManagementXmlSerializer.odata_converter(child.firstChild.nodeValue, node_type)
                    setattr(return_obj, name, node_value)
            for name, value in _MinidomXmlToObject.get_entry_properties_from_node(
                xml_entry,
                include_id=True,
                use_title_as_id=False).items():
                if name in members:
                    continue  # Do not override if already members
                setattr(return_obj, name, value)
        return return_obj


def replace_content(
            self, resource_group_name, automation_account_name, runbook_name, runbook_content, custom_headers=None, raw=False, callback=None, polling=True, **operation_config):
        """Replaces the runbook draft content.

        :param resource_group_name: Name of an Azure Resource group.
        :type resource_group_name: str
        :param automation_account_name: The name of the automation account.
        :type automation_account_name: str
        :param runbook_name: The runbook name.
        :type runbook_name: str
        :param runbook_content: The runbook draft content.
        :type runbook_content: Generator
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns object or
         ClientRawResponse<object> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[Generator]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[Generator]]
        :raises:
         :class:`ErrorResponseException<azure.mgmt.automation.models.ErrorResponseException>`
        """
        raw_result = self._replace_content_initial(
            resource_group_name=resource_group_name,
            automation_account_name=automation_account_name,
            runbook_name=runbook_name,
            runbook_content=runbook_content,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            header_dict = {
                'location': 'str',
            }
            deserialized = self._deserialize('object', response)

            if raw:
                client_raw_response = ClientRawResponse(deserialized, response)
                client_raw_response.add_headers(header_dict)
                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 replace_content ( self , resource_group_name , automation_account_name , runbook_name , runbook_content , custom_headers = None , raw = False , callback = None , polling = True , ** operation_config ) : raw_result = self . _replace_content_initial ( resource_group_name = resource_group_name , automation_account_name = automation_account_name , runbook_name = runbook_name , runbook_content = runbook_content , custom_headers = custom_headers , raw = True , ** operation_config ) def get_long_running_output ( response ) : header_dict = { 'location' : 'str' , } deserialized = self . _deserialize ( 'object' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) client_raw_response . add_headers ( header_dict ) 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 list_recommendations(
            self, keywords=None, max_domain_recommendations=None, custom_headers=None, raw=False, **operation_config):
        """Get domain name recommendations based on keywords.

        Get domain name recommendations based on keywords.

        :param keywords: Keywords to be used for generating domain
         recommendations.
        :type keywords: str
        :param max_domain_recommendations: Maximum number of recommendations.
        :type max_domain_recommendations: 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 operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: An iterator like instance of NameIdentifier
        :rtype:
         ~azure.mgmt.web.models.NameIdentifierPaged[~azure.mgmt.web.models.NameIdentifier]
        :raises:
         :class:`DefaultErrorResponseException<azure.mgmt.web.models.DefaultErrorResponseException>`
        """
        parameters = models.DomainRecommendationSearchParameters(keywords=keywords, max_domain_recommendations=max_domain_recommendations)

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

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

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

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

        return deserialized

def
list_recommendations
(
self
,
keywords
=
,
max_domain_recommendations
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
DomainRecommendationSearchParameters
(
keywords
=
keywords
,
max_domain_recommendations
=
max_domain_recommendations
)
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
url
=
self
.
list_recommendations
.
metadata
[
'url'
]
path_format_arguments
=
{
'subscriptionId'
:
self
.
_serialize
.
url
(
"self.config.subscription_id"
,
self
.
config
.
subscription_id
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'DomainRecommendationSearchParameters'
)
request
=
self
.
_client
.
post
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
DefaultErrorResponseException
(
self
.
_deserialize
,
response
)
return
response
deserialized
=
models
.
NameIdentifierPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
NameIdentifierPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

Get domain name recommendations based on keywords .


def update(
            self, kb_id, update_kb, custom_headers=None, raw=False, **operation_config):
        """Asynchronous operation to modify a knowledgebase.

        :param kb_id: Knowledgebase id.
        :type kb_id: str
        :param update_kb: Post body of the request.
        :type update_kb:
         ~azure.cognitiveservices.knowledge.qnamaker.models.UpdateKbOperationDTO
        :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: Operation or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.knowledge.qnamaker.models.Operation
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.update.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'kbId': self._serialize.url("kb_id", kb_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # 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(update_kb, 'UpdateKbOperationDTO')

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

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

        deserialized = None
        header_dict = {}

        if response.status_code == 202:
            deserialized = self._deserialize('Operation', response)
            header_dict = {
                'Location': 'str',
            }

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

        return deserialized

def
update
(
self
,
kb_id
,
update_kb
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
url
=
self
.
update
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
,
'kbId'
:
self
.
_serialize
.
url
(
"kb_id"
,
kb_id
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
body_content
=
self
.
_serialize
.
body
(
update_kb
,
'UpdateKbOperationDTO'
)
request
=
self
.
_client
.
patch
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
202
]
:
raise
models
.
ErrorResponseException
(
self
.
_deserialize
,
response
)
deserialized
=
header_dict
=
{
}
if
response
.
status_code
==
202
:
deserialized
=
self
.
_deserialize
(
'Operation'
,
response
)
header_dict
=
{
'Location'
:
'str'
,
}
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
client_raw_response
.
add_headers
(
header_dict
)
return
client_raw_response
return
deserialized

Asynchronous operation to modify a knowledgebase .


def get_member_groups(
            self, object_id, security_enabled_only, additional_properties=None, custom_headers=None, raw=False, **operation_config):
        """Gets a collection that contains the object IDs of the groups of which
        the user is a member.

        :param object_id: The object ID of the user for which to get group
         membership.
        :type object_id: str
        :param security_enabled_only: If true, only membership in
         security-enabled groups should be checked. Otherwise, membership in
         all groups should be checked.
        :type security_enabled_only: bool
        :param additional_properties: Unmatched properties from the message
         are deserialized this collection
        :type additional_properties: dict[str, object]
        :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 str
        :rtype: ~azure.graphrbac.models.StrPaged[str]
        :raises:
         :class:`GraphErrorException<azure.graphrbac.models.GraphErrorException>`
        """
        parameters = models.UserGetMemberGroupsParameters(additional_properties=additional_properties, security_enabled_only=security_enabled_only)

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

            if not next_link:
                # Construct URL
                url = self.get_member_groups.metadata['url']
                path_format_arguments = {
                    'objectId': self._serialize.url("object_id", object_id, 'str'),
                    'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_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(parameters, 'UserGetMemberGroupsParameters')

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

            return response

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

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

        return deserialized

def
get_member_groups
(
self
,
object_id
,
security_enabled_only
,
additional_properties
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
UserGetMemberGroupsParameters
(
additional_properties
=
additional_properties
,
security_enabled_only
=
security_enabled_only
)
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
url
=
self
.
get_member_groups
.
metadata
[
'url'
]
path_format_arguments
=
{
'objectId'
:
self
.
_serialize
.
url
(
"object_id"
,
object_id
,
'str'
)
,
'tenantID'
:
self
.
_serialize
.
url
(
"self.config.tenant_id"
,
self
.
config
.
tenant_id
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'UserGetMemberGroupsParameters'
)
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
.
GraphErrorException
(
self
.
_deserialize
,
response
)
return
response
deserialized
=
models
.
StrPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
StrPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

Gets a collection that contains the object IDs of the groups of which the user is a member .


def build_package_from_pr_number(gh_token, sdk_id, pr_number, output_folder, *, with_comment=False):
    """Will clone the given PR branch and vuild the package with the given name."""

    con = Github(gh_token)
    repo = con.get_repo(sdk_id)
    sdk_pr = repo.get_pull(pr_number)
    # "get_files" of Github only download the first 300 files. Might not be enough.
    package_names = {f.filename.split('/')[0] for f in sdk_pr.get_files() if f.filename.startswith("azure")}
    absolute_output_folder = Path(output_folder).resolve()

    with tempfile.TemporaryDirectory() as temp_dir, \
            manage_git_folder(gh_token, Path(temp_dir) / Path("sdk"), sdk_id, pr_number=pr_number) as sdk_folder:

        for package_name in package_names:
            _LOGGER.debug("Build {}".format(package_name))
            execute_simple_command(
                ["python", "./build_package.py", "--dest", str(absolute_output_folder), package_name],
                cwd=sdk_folder
            )
            _LOGGER.debug("Build finished: {}".format(package_name))

    if with_comment:
        files = [f.name for f in absolute_output_folder.iterdir()]
        comment_message = None
        dashboard = DashboardCommentableObject(sdk_pr, "(message created by the CI based on PR content)")
        try:
            installation_message = build_installation_message(sdk_pr)
            download_message = build_download_message(sdk_pr, files)
            comment_message = installation_message + "\n\n" + download_message
            dashboard.create_comment(comment_message)
        except Exception:
            _LOGGER.critical("Unable to do PR comment:\n%s", comment_message)

Will clone the given PR branch and vuild the package with the given name .


def import_data(
            self, resource_group_name, name, files, format=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Import data into Redis cache.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param name: The name of the Redis cache.
        :type name: str
        :param files: files to import.
        :type files: list[str]
        :param format: File format.
        :type format: 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._import_data_initial(
            resource_group_name=resource_group_name,
            name=name,
            files=files,
            format=format,
            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 import_data ( self , resource_group_name , name , files , format = None , custom_headers = None , raw = False , polling = True , ** operation_config ) : raw_result = self . _import_data_initial ( resource_group_name = resource_group_name , name = name , files = files , format = format , 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 publish(
            self, resource_group_name, automation_account_name, runbook_name, custom_headers=None, raw=False, polling=True, **operation_config):
        """Publish runbook draft.

        :param resource_group_name: Name of an Azure Resource group.
        :type resource_group_name: str
        :param automation_account_name: The name of the automation account.
        :type automation_account_name: str
        :param runbook_name: The parameters supplied to the publish runbook
         operation.
        :type runbook_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 None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises:
         :class:`ErrorResponseException<azure.mgmt.automation.models.ErrorResponseException>`
        """
        raw_result = self._publish_initial(
            resource_group_name=resource_group_name,
            automation_account_name=automation_account_name,
            runbook_name=runbook_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            if raw:
                client_raw_response = ClientRawResponse(None, response)
                client_raw_response.add_headers({
                    'location': 'str',
                })
                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 publish ( self , resource_group_name , automation_account_name , runbook_name , custom_headers = None , raw = False , polling = True , ** operation_config ) : raw_result = self . _publish_initial ( resource_group_name = resource_group_name , automation_account_name = automation_account_name , runbook_name = runbook_name , custom_headers = custom_headers , raw = True , ** operation_config ) def get_long_running_output ( response ) : if raw : client_raw_response = ClientRawResponse ( None , response ) client_raw_response . add_headers ( { 'location' : 'str' , } ) 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 )


async def renew_lock(self):
        """Renew the message lock.

        This will maintain the lock on the message to ensure
        it is not returned to the queue to be reprocessed. In order to complete (or otherwise settle)
        the message, the lock must be maintained. Messages received via ReceiveAndDelete mode are not
        locked, and therefore cannot be renewed. This operation can also be performed as an asynchronous
        background task by registering the message with an `azure.servicebus.aio.AutoLockRenew` instance.
        This operation is only available for non-sessionful messages.

        :raises: TypeError if the message is sessionful.
        :raises: ~azure.servicebus.common.errors.MessageLockExpired is message lock has already expired.
        :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired.
        :raises: ~azure.servicebus.common.errors.MessageAlreadySettled is message has already been settled.
        """
        if hasattr(self._receiver, 'locked_until'):
            raise TypeError("Session messages cannot be renewed. Please renew the Session lock instead.")
        self._is_live('renew')
        expiry = await self._receiver._renew_locks(self.lock_token)  # pylint: disable=protected-access
        self._expiry = datetime.datetime.fromtimestamp(expiry[b'expirations'][0]/1000.0)


def replace(
            self, word_alterations, custom_headers=None, raw=False, **operation_config):
        """Replace alterations data.

        :param word_alterations: Collection of word alterations.
        :type word_alterations:
         list[~azure.cognitiveservices.knowledge.qnamaker.models.AlterationsDTO]
        :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:`ErrorResponseException<azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException>`
        """
        word_alterations1 = models.WordAlterationsDTO(word_alterations=word_alterations)

        # Construct URL
        url = self.replace.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # 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(word_alterations1, 'WordAlterationsDTO')

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

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

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

def
replace
(
self
,
word_alterations
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
word_alterations1
=
models
.
WordAlterationsDTO
(
word_alterations
=
word_alterations
)
url
=
self
.
replace
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
body_content
=
self
.
_serialize
.
body
(
word_alterations1
,
'WordAlterationsDTO'
)
request
=
self
.
_client
.
put
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
204
]
:
raise
models
.
ErrorResponseException
(
self
.
_deserialize
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
,
response
)
return
client_raw_response


def add_value(
            self, secret_resource_name, secret_value_resource_name, name, value=None, custom_headers=None, raw=False, **operation_config):
        """Adds the specified value as a new version of the specified secret
        resource.

        Creates a new value of the specified secret resource. The name of the
        value is typically the version identifier. Once created the value
        cannot be changed.

        :param secret_resource_name: The name of the secret resource.
        :type secret_resource_name: str
        :param secret_value_resource_name: The name of the secret resource
         value which is typically the version identifier for the value.
        :type secret_value_resource_name: str
        :param name: Version identifier of the secret value.
        :type name: str
        :param value: The actual value of the secret.
        :type value: 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: SecretValueResourceDescription or ClientRawResponse if
         raw=true
        :rtype: ~azure.servicefabric.models.SecretValueResourceDescription or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`FabricErrorException<azure.servicefabric.models.FabricErrorException>`
        """
        secret_value_resource_description = models.SecretValueResourceDescription(name=name, value=value)

        # Construct URL
        url = self.add_value.metadata['url']
        path_format_arguments = {
            'secretResourceName': self._serialize.url("secret_resource_name", secret_resource_name, 'str', skip_quote=True),
            'secretValueResourceName': self._serialize.url("secret_value_resource_name", secret_value_resource_name, '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['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(secret_value_resource_description, 'SecretValueResourceDescription')

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

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

        deserialized = None

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

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

        return deserialized

def
add_value
(
self
,
secret_resource_name
,
secret_value_resource_name
,
name
,
value
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
secret_value_resource_description
=
models
.
SecretValueResourceDescription
(
name
=
name
,
value
=
value
)
url
=
self
.
add_value
.
metadata
[
'url'
]
path_format_arguments
=
{
'secretResourceName'
:
self
.
_serialize
.
url
(
"secret_resource_name"
,
secret_resource_name
,
'str'
,
skip_quote
=
True
)
,
'secretValueResourceName'
:
self
.
_serialize
.
url
(
"secret_value_resource_name"
,
secret_value_resource_name
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
body_content
=
self
.
_serialize
.
body
(
secret_value_resource_description
,
'SecretValueResourceDescription'
)
request
=
self
.
_client
.
put
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
,
201
,
202
]
:
raise
models
.
FabricErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'SecretValueResourceDescription'
,
response
)
if
response
.
status_code
==
201
:
deserialized
=
self
.
_deserialize
(
'SecretValueResourceDescription'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Adds the specified value as a new version of the specified secret resource .


def get_storage_account_properties(self, service_name):
        '''
        Returns system properties for the specified storage account.

        service_name:
            Name of the storage service account.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_get(self._get_storage_service_path(service_name),
                                 StorageService)

def get_storage_account_properties ( self , service_name ) : _validate_not_none ( 'service_name' , service_name ) return self . _perform_get ( self . _get_storage_service_path ( service_name ) , StorageService )

Returns system properties for the specified storage account .


def get_storage_account_keys(self, service_name):
        '''
        Returns the primary and secondary access keys for the specified
        storage account.

        service_name:
            Name of the storage service account.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_get(
            self._get_storage_service_path(service_name) + '/keys',
            StorageService)

def get_storage_account_keys ( self , service_name ) : _validate_not_none ( 'service_name' , service_name ) return self . _perform_get ( self . _get_storage_service_path ( service_name ) + '/keys' , StorageService )

Returns the primary and secondary access keys for the specified storage account .


def regenerate_storage_account_keys(self, service_name, key_type):
        '''
        Regenerates the primary or secondary access key for the specified
        storage account.

        service_name:
            Name of the storage service account.
        key_type:
            Specifies which key to regenerate. Valid values are:
            Primary, Secondary
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('key_type', key_type)
        return self._perform_post(
            self._get_storage_service_path(
                service_name) + '/keys?action=regenerate',
            _XmlSerializer.regenerate_keys_to_xml(
                key_type),
            StorageService)

def regenerate_storage_account_keys ( self , service_name , key_type ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'key_type' , key_type ) return self . _perform_post ( self . _get_storage_service_path ( service_name ) + '/keys?action=regenerate' , _XmlSerializer . regenerate_keys_to_xml ( key_type ) , StorageService )

Regenerates the primary or secondary access key for the specified storage account .


def create_storage_account(self, service_name, description, label,
                               affinity_group=None, location=None,
                               geo_replication_enabled=None,
                               extended_properties=None,
                               account_type='Standard_GRS'):
        '''
        Creates a new storage account in Windows Azure.

        service_name:
            A name for the storage account that is unique within Windows Azure.
            Storage account names must be between 3 and 24 characters in length
            and use numbers and lower-case letters only.
        description:
            A description for the storage account. The description may be up
            to 1024 characters in length.
        label:
            A name for the storage account. The name may be up to 100
            characters in length. The name can be used to identify the storage
            account for your tracking purposes.
        affinity_group:
            The name of an existing affinity group in the specified
            subscription. You can specify either a location or affinity_group,
            but not both.
        location:
            The location where the storage account is created. You can specify
            either a location or affinity_group, but not both.
        geo_replication_enabled:
            Deprecated. Replaced by the account_type parameter.
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        account_type:
            Specifies whether the account supports locally-redundant storage,
            geo-redundant storage, zone-redundant storage, or read access
            geo-redundant storage.
            Possible values are:
                Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('description', description)
        _validate_not_none('label', label)
        if affinity_group is None and location is None:
            raise ValueError(
                'location or affinity_group must be specified')
        if affinity_group is not None and location is not None:
            raise ValueError(
                'Only one of location or affinity_group needs to be specified')
        if geo_replication_enabled == False:
            account_type = 'Standard_LRS'
        return self._perform_post(
            self._get_storage_service_path(),
            _XmlSerializer.create_storage_service_input_to_xml(
                service_name,
                description,
                label,
                affinity_group,
                location,
                account_type,
                extended_properties),
            as_async=True)

Creates a new storage account in Windows Azure .


def update_storage_account(self, service_name, description=None,
                               label=None, geo_replication_enabled=None,
                               extended_properties=None,
                               account_type='Standard_GRS'):
        '''
        Updates the label, the description, and enables or disables the
        geo-replication status for a storage account in Windows Azure.

        service_name:
            Name of the storage service account.
        description:
            A description for the storage account. The description may be up
            to 1024 characters in length.
        label:
            A name for the storage account. The name may be up to 100
            characters in length. The name can be used to identify the storage
            account for your tracking purposes.
        geo_replication_enabled:
            Deprecated. Replaced by the account_type parameter.
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        account_type:
            Specifies whether the account supports locally-redundant storage,
            geo-redundant storage, zone-redundant storage, or read access
            geo-redundant storage.
            Possible values are:
                Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS
        '''
        _validate_not_none('service_name', service_name)
        if geo_replication_enabled == False:
            account_type = 'Standard_LRS'
        return self._perform_put(
            self._get_storage_service_path(service_name),
            _XmlSerializer.update_storage_service_input_to_xml(
                description,
                label,
                account_type,
                extended_properties))

def update_storage_account ( self , service_name , description = None , label = None , geo_replication_enabled = None , extended_properties = None , account_type = 'Standard_GRS' ) : _validate_not_none ( 'service_name' , service_name ) if geo_replication_enabled == False : account_type = 'Standard_LRS' return self . _perform_put ( self . _get_storage_service_path ( service_name ) , _XmlSerializer . update_storage_service_input_to_xml ( description , label , account_type , extended_properties ) )

Updates the label the description and enables or disables the geo - replication status for a storage account in Windows Azure .


def delete_storage_account(self, service_name):
        '''
        Deletes the specified storage account from Windows Azure.

        service_name:
            Name of the storage service account.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_delete(
            self._get_storage_service_path(service_name),
            as_async=True)

def delete_storage_account ( self , service_name ) : _validate_not_none ( 'service_name' , service_name ) return self . _perform_delete ( self . _get_storage_service_path ( service_name ) , as_async = True )

Deletes the specified storage account from Windows Azure .


def check_storage_account_name_availability(self, service_name):
        '''
        Checks to see if the specified storage account name is available, or
        if it has already been taken.

        service_name:
            Name of the storage service account.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_get(
            self._get_storage_service_path() +
            '/operations/isavailable/' +
            _str(service_name) + '',
            AvailabilityResponse)

def check_storage_account_name_availability ( self , service_name ) : _validate_not_none ( 'service_name' , service_name ) return self . _perform_get ( self . _get_storage_service_path ( ) + '/operations/isavailable/' + _str ( service_name ) + '' , AvailabilityResponse )

Checks to see if the specified storage account name is available or if it has already been taken .


def get_hosted_service_properties(self, service_name, embed_detail=False):
        '''
        Retrieves system properties for the specified hosted service. These
        properties include the service name and service type; the name of the
        affinity group to which the service belongs, or its location if it is
        not part of an affinity group; and optionally, information on the
        service's deployments.

        service_name:
            Name of the hosted service.
        embed_detail:
            When True, the management service returns properties for all
            deployments of the service, as well as for the service itself.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('embed_detail', embed_detail)
        return self._perform_get(
            self._get_hosted_service_path(service_name) +
            '?embed-detail=' +
            _str(embed_detail).lower(),
            HostedService)

def get_hosted_service_properties ( self , service_name , embed_detail = False ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'embed_detail' , embed_detail ) return self . _perform_get ( self . _get_hosted_service_path ( service_name ) + '?embed-detail=' + _str ( embed_detail ) . lower ( ) , HostedService )

Retrieves system properties for the specified hosted service . These properties include the service name and service type ; the name of the affinity group to which the service belongs or its location if it is not part of an affinity group ; and optionally information on the service s deployments .


def create_hosted_service(self, service_name, label, description=None,
                              location=None, affinity_group=None,
                              extended_properties=None):
        '''
        Creates a new hosted service in Windows Azure.

        service_name:
            A name for the hosted service that is unique within Windows Azure.
            This name is the DNS prefix name and can be used to access the
            hosted service.
        label:
            A name for the hosted service. The name can be up to 100 characters
            in length. The name can be used to identify the storage account for
            your tracking purposes.
        description:
            A description for the hosted service. The description can be up to
            1024 characters in length.
        location:
            The location where the hosted service will be created. You can
            specify either a location or affinity_group, but not both.
        affinity_group:
            The name of an existing affinity group associated with this
            subscription. This name is a GUID and can be retrieved by examining
            the name element of the response body returned by
            list_affinity_groups. You can specify either a location or
            affinity_group, but not both.
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('label', label)
        if affinity_group is None and location is None:
            raise ValueError(
                'location or affinity_group must be specified')
        if affinity_group is not None and location is not None:
            raise ValueError(
                'Only one of location or affinity_group needs to be specified')
        return self._perform_post(self._get_hosted_service_path(),
                                  _XmlSerializer.create_hosted_service_to_xml(
                                      service_name,
                                      label,
                                      description,
                                      location,
                                      affinity_group,
                                      extended_properties),
                                  as_async=True)

Creates a new hosted service in Windows Azure .


def delete_hosted_service(self, service_name, complete=False):
        '''
        Deletes the specified hosted service from Windows Azure.

        service_name:
            Name of the hosted service.
        complete:
            True if all OS/data disks and the source blobs for the disks should
            also be deleted from storage.
        '''

        _validate_not_none('service_name', service_name)

        path = self._get_hosted_service_path(service_name)

        if complete == True:
            path = path +'?comp=media'

        return self._perform_delete(path, as_async=True)

def delete_hosted_service ( self , service_name , complete = False ) : _validate_not_none ( 'service_name' , service_name ) path = self . _get_hosted_service_path ( service_name ) if complete == True : path = path + '?comp=media' return self . _perform_delete ( path , as_async = True )

Deletes the specified hosted service from Windows Azure .


def create_deployment(self, service_name, deployment_slot, name,
                          package_url, label, configuration,
                          start_deployment=False,
                          treat_warnings_as_error=False,
                          extended_properties=None):
        '''
        Uploads a new service package and creates a new deployment on staging
        or production.

        service_name:
            Name of the hosted service.
        deployment_slot:
            The environment to which the hosted service is deployed. Valid
            values are: staging, production
        name:
            The name for the deployment. The deployment name must be unique
            among other deployments for the hosted service.
        package_url:
            A URL that refers to the location of the service package in the
            Blob service. The service package can be located either in a
            storage account beneath the same subscription or a Shared Access
            Signature (SAS) URI from any storage account.
        label:
            A name for the hosted service. The name can be up to 100 characters
            in length. It is recommended that the label be unique within the
            subscription. The name can be used to identify the hosted service
            for your tracking purposes.
        configuration:
            The base-64 encoded service configuration file for the deployment.
        start_deployment:
            Indicates whether to start the deployment immediately after it is
            created. If false, the service model is still deployed to the
            virtual machines but the code is not run immediately. Instead, the
            service is Suspended until you call Update Deployment Status and
            set the status to Running, at which time the service will be
            started. A deployed service still incurs charges, even if it is
            suspended.
        treat_warnings_as_error:
            Indicates whether to treat package validation warnings as errors.
            If set to true, the Created Deployment operation fails if there
            are validation warnings on the service package.
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_slot', deployment_slot)
        _validate_not_none('name', name)
        _validate_not_none('package_url', package_url)
        _validate_not_none('label', label)
        _validate_not_none('configuration', configuration)
        return self._perform_post(
            self._get_deployment_path_using_slot(
                service_name, deployment_slot),
            _XmlSerializer.create_deployment_to_xml(
                name,
                package_url,
                label,
                configuration,
                start_deployment,
                treat_warnings_as_error,
                extended_properties),
            as_async=True)

def create_deployment ( self , service_name , deployment_slot , name , package_url , label , configuration , start_deployment = False , treat_warnings_as_error = False , extended_properties = None ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_slot' , deployment_slot ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'package_url' , package_url ) _validate_not_none ( 'label' , label ) _validate_not_none ( 'configuration' , configuration ) return self . _perform_post ( self . _get_deployment_path_using_slot ( service_name , deployment_slot ) , _XmlSerializer . create_deployment_to_xml ( name , package_url , label , configuration , start_deployment , treat_warnings_as_error , extended_properties ) , as_async = True )

Uploads a new service package and creates a new deployment on staging or production .


def delete_deployment(self, service_name, deployment_name,delete_vhd=False):
        '''
        Deletes the specified deployment.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        path= self._get_deployment_path_using_name(service_name, deployment_name)
        if delete_vhd:
            path += '?comp=media'
        return self._perform_delete(
                path,
            as_async=True)

def delete_deployment ( self , service_name , deployment_name , delete_vhd = False ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) path = self . _get_deployment_path_using_name ( service_name , deployment_name ) if delete_vhd : path += '?comp=media' return self . _perform_delete ( path , as_async = True )


def swap_deployment(self, service_name, production, source_deployment):
        '''
        Initiates a virtual IP swap between the staging and production
        deployment environments for a service. If the service is currently
        running in the staging environment, it will be swapped to the
        production environment. If it is running in the production
        environment, it will be swapped to staging.

        service_name:
            Name of the hosted service.
        production:
            The name of the production deployment.
        source_deployment:
            The name of the source deployment.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('production', production)
        _validate_not_none('source_deployment', source_deployment)
        return self._perform_post(self._get_hosted_service_path(service_name),
                                  _XmlSerializer.swap_deployment_to_xml(
                                      production, source_deployment),
                                  as_async=True)

def swap_deployment ( self , service_name , production , source_deployment ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'production' , production ) _validate_not_none ( 'source_deployment' , source_deployment ) return self . _perform_post ( self . _get_hosted_service_path ( service_name ) , _XmlSerializer . swap_deployment_to_xml ( production , source_deployment ) , as_async = True )

Initiates a virtual IP swap between the staging and production deployment environments for a service . If the service is currently running in the staging environment it will be swapped to the production environment . If it is running in the production environment it will be swapped to staging .


def change_deployment_configuration(self, service_name, deployment_name,
                                        configuration,
                                        treat_warnings_as_error=False,
                                        mode='Auto', extended_properties=None):
        '''
        Initiates a change to the deployment configuration.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        configuration:
            The base-64 encoded service configuration file for the deployment.
        treat_warnings_as_error:
            Indicates whether to treat package validation warnings as errors.
            If set to true, the Created Deployment operation fails if there
            are validation warnings on the service package.
        mode:
            If set to Manual, WalkUpgradeDomain must be called to apply the
            update. If set to Auto, the Windows Azure platform will
            automatically apply the update To each upgrade domain for the
            service. Possible values are: Auto, Manual
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('configuration', configuration)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + '/?comp=config',
            _XmlSerializer.change_deployment_to_xml(
                configuration,
                treat_warnings_as_error,
                mode,
                extended_properties),
            as_async=True)

def change_deployment_configuration ( self , service_name , deployment_name , configuration , treat_warnings_as_error = False , mode = 'Auto' , extended_properties = None ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) _validate_not_none ( 'configuration' , configuration ) return self . _perform_post ( self . _get_deployment_path_using_name ( service_name , deployment_name ) + '/?comp=config' , _XmlSerializer . change_deployment_to_xml ( configuration , treat_warnings_as_error , mode , extended_properties ) , as_async = True )

Initiates a change to the deployment configuration .


def update_deployment_status(self, service_name, deployment_name, status):
        '''
        Initiates a change in deployment status.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        status:
            The change to initiate to the deployment status. Possible values
            include:
                Running, Suspended
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('status', status)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + '/?comp=status',
            _XmlSerializer.update_deployment_status_to_xml(
                status),
            as_async=True)

def update_deployment_status ( self , service_name , deployment_name , status ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) _validate_not_none ( 'status' , status ) return self . _perform_post ( self . _get_deployment_path_using_name ( service_name , deployment_name ) + '/?comp=status' , _XmlSerializer . update_deployment_status_to_xml ( status ) , as_async = True )

Initiates a change in deployment status .


def upgrade_deployment(self, service_name, deployment_name, mode,
                           package_url, configuration, label, force,
                           role_to_upgrade=None, extended_properties=None):
        '''
        Initiates an upgrade.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        mode:
            If set to Manual, WalkUpgradeDomain must be called to apply the
            update. If set to Auto, the Windows Azure platform will
            automatically apply the update To each upgrade domain for the
            service. Possible values are: Auto, Manual
        package_url:
            A URL that refers to the location of the service package in the
            Blob service. The service package can be located either in a
            storage account beneath the same subscription or a Shared Access
            Signature (SAS) URI from any storage account.
        configuration:
            The base-64 encoded service configuration file for the deployment.
        label:
            A name for the hosted service. The name can be up to 100 characters
            in length. It is recommended that the label be unique within the
            subscription. The name can be used to identify the hosted service
            for your tracking purposes.
        force:
            Specifies whether the rollback should proceed even when it will
            cause local data to be lost from some role instances. True if the
            rollback should proceed; otherwise false if the rollback should
            fail.
        role_to_upgrade:
            The name of the specific role to upgrade.
        extended_properties:
            Dictionary containing name/value pairs of storage account
            properties. You can have a maximum of 50 extended property
            name/value pairs. The maximum length of the Name element is 64
            characters, only alphanumeric characters and underscores are valid
            in the Name, and the name must start with a letter. The value has
            a maximum length of 255 characters.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('mode', mode)
        _validate_not_none('package_url', package_url)
        _validate_not_none('configuration', configuration)
        _validate_not_none('label', label)
        _validate_not_none('force', force)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + '/?comp=upgrade',
            _XmlSerializer.upgrade_deployment_to_xml(
                mode,
                package_url,
                configuration,
                label,
                role_to_upgrade,
                force,
                extended_properties),
            as_async=True)

def upgrade_deployment ( self , service_name , deployment_name , mode , package_url , configuration , label , force , role_to_upgrade = None , extended_properties = None ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) _validate_not_none ( 'mode' , mode ) _validate_not_none ( 'package_url' , package_url ) _validate_not_none ( 'configuration' , configuration ) _validate_not_none ( 'label' , label ) _validate_not_none ( 'force' , force ) return self . _perform_post ( self . _get_deployment_path_using_name ( service_name , deployment_name ) + '/?comp=upgrade' , _XmlSerializer . upgrade_deployment_to_xml ( mode , package_url , configuration , label , role_to_upgrade , force , extended_properties ) , as_async = True )


def walk_upgrade_domain(self, service_name, deployment_name,
                            upgrade_domain):
        '''
        Specifies the next upgrade domain to be walked during manual in-place
        upgrade or configuration change.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        upgrade_domain:
            An integer value that identifies the upgrade domain to walk.
            Upgrade domains are identified with a zero-based index: the first
            upgrade domain has an ID of 0, the second has an ID of 1, and so on.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('upgrade_domain', upgrade_domain)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + '/?comp=walkupgradedomain',
            _XmlSerializer.walk_upgrade_domain_to_xml(
                upgrade_domain),
            as_async=True)

Specifies the next upgrade domain to be walked during manual in - place upgrade or configuration change .


def reboot_role_instance(self, service_name, deployment_name,
                             role_instance_name):
        '''
        Requests a reboot of a role instance that is running in a deployment.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        role_instance_name:
            The name of the role instance.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_instance_name', role_instance_name)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + \
                    '/roleinstances/' + _str(role_instance_name) + \
                    '?comp=reboot',
            '',
            as_async=True)

Requests a reboot of a role instance that is running in a deployment .


def delete_role_instances(self, service_name, deployment_name,
                             role_instance_names):
        '''
        Reinstalls the operating system on instances of web roles or worker
        roles and initializes the storage resources that are used by them. If
        you do not want to initialize storage resources, you can use
        reimage_role_instance.

        service_name:
            Name of the hosted service.
        deployment_name:
            The name of the deployment.
        role_instance_names:
            List of role instance names.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_instance_names', role_instance_names)
        return self._perform_post(
            self._get_deployment_path_using_name(
                service_name, deployment_name) + '/roleinstances/?comp=delete',
            _XmlSerializer.role_instances_to_xml(role_instance_names),
            as_async=True)

Reinstalls the operating system on instances of web roles or worker roles and initializes the storage resources that are used by them . If you do not want to initialize storage resources you can use reimage_role_instance .


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

        service_name:
            Name of the hosted service.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_get(
            '/' + self.subscription_id +
            '/services/hostedservices/operations/isavailable/' +
            _str(service_name) + '',
            AvailabilityResponse)

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


def list_service_certificates(self, service_name):
        '''
        Lists all of the service certificates associated with the specified
        hosted service.

        service_name:
            Name of the hosted service.
        '''
        _validate_not_none('service_name', service_name)
        return self._perform_get(
            '/' + self.subscription_id + '/services/hostedservices/' +
            _str(service_name) + '/certificates',
            Certificates)

def list_service_certificates ( self , service_name ) : _validate_not_none ( 'service_name' , service_name ) return self . _perform_get ( '/' + self . subscription_id + '/services/hostedservices/' + _str ( service_name ) + '/certificates' , Certificates )

Lists all of the service certificates associated with the specified hosted service .