def download(
            self, resource_group_name, virtual_wan_name, vpn_sites=None, output_blob_sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Gives the sas-url to download the configurations for vpn-sites in a
        resource group.

        :param resource_group_name: The resource group name.
        :type resource_group_name: str
        :param virtual_wan_name: The name of the VirtualWAN for which
         configuration of all vpn-sites is needed.
        :type virtual_wan_name: str
        :param vpn_sites: List of resource-ids of the vpn-sites for which
         config is to be downloaded.
        :type vpn_sites:
         list[~azure.mgmt.network.v2018_04_01.models.SubResource]
        :param output_blob_sas_url: The sas-url to download the configurations
         for vpn-sites
        :type output_blob_sas_url: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises:
         :class:`ErrorException<azure.mgmt.network.v2018_04_01.models.ErrorException>`
        """
        raw_result = self._download_initial(
            resource_group_name=resource_group_name,
            virtual_wan_name=virtual_wan_name,
            vpn_sites=vpn_sites,
            output_blob_sas_url=output_blob_sas_url,
            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 download ( self , resource_group_name , virtual_wan_name , vpn_sites = None , output_blob_sas_url = None , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _download_initial ( resource_group_name = resource_group_name , virtual_wan_name = virtual_wan_name , vpn_sites = vpn_sites , output_blob_sas_url = output_blob_sas_url , 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 )

Gives the sas - url to download the configurations for vpn - sites in a resource group .


def guess_service_info_from_path(spec_path):
    """Guess Python Autorest options based on the spec path.

    Expected path:
    specification/compute/resource-manager/readme.md
    """
    spec_path = spec_path.lower()
    spec_path = spec_path[spec_path.index("specification"):] # Might raise and it's ok
    split_spec_path = spec_path.split("/")

    rp_name = split_spec_path[1]
    is_arm = split_spec_path[2] == "resource-manager"

    return {
        "rp_name": rp_name,
        "is_arm": is_arm
    }

def
guess_service_info_from_path
(
spec_path
)
:
spec_path
=
spec_path
.
lower
(
)
spec_path
=
spec_path
[
spec_path
.
index
(
"specification"
)
:
]
# Might raise and it's ok
split_spec_path
=
spec_path
.
split
(
"/"
)
rp_name
=
split_spec_path
[
1
]
is_arm
=
split_spec_path
[
2
]
==
"resource-manager"
return
{
"rp_name"
:
rp_name
,
"is_arm"
:
is_arm
}

Guess Python Autorest options based on the spec path .


def update_command(
            self, resource_group_name, node_name, session, pssession, custom_headers=None, raw=False, polling=True, **operation_config):
        """Updates a running PowerShell command with more data.

        :param resource_group_name: The resource group name uniquely
         identifies the resource group within the user subscriptionId.
        :type resource_group_name: str
        :param node_name: The node name (256 characters maximum).
        :type node_name: str
        :param session: The sessionId from the user.
        :type session: str
        :param pssession: The PowerShell sessionId from the user.
        :type pssession: 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
         PowerShellCommandResults or
         ClientRawResponse<PowerShellCommandResults> if raw==True
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.PowerShellCommandResults]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.PowerShellCommandResults]]
        :raises:
         :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>`
        """
        raw_result = self._update_command_initial(
            resource_group_name=resource_group_name,
            node_name=node_name,
            session=session,
            pssession=pssession,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

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

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

            return deserialized

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

def update_command ( self , resource_group_name , node_name , session , pssession , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _update_command_initial ( resource_group_name = resource_group_name , node_name = node_name , session = session , pssession = pssession , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( 'PowerShellCommandResults' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) return client_raw_response return deserialized lro_delay = operation_config . get ( 'long_running_operation_timeout' , self . config . long_running_operation_timeout ) if polling is True : polling_method = ARMPolling ( lro_delay , * * operation_config ) elif polling is False : polling_method = NoPolling ( ) else : polling_method = polling return LROPoller ( self . _client , raw_result , get_long_running_output , polling_method )

Updates a running PowerShell command with more data .


def delete_by_id(
            self, application_definition_id, custom_headers=None, raw=False, polling=True, **operation_config):
        """Deletes the managed application definition.

        :param application_definition_id: The fully qualified ID of the
         managed application definition, including the managed application name
         and the managed application definition resource type. Use the format,
         /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}
        :type application_definition_id: 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.resource.managedapplications.models.ErrorResponseException>`
        """
        raw_result = self._delete_by_id_initial(
            application_definition_id=application_definition_id,
            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 delete_by_id ( self , application_definition_id , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _delete_by_id_initial ( application_definition_id = application_definition_id , 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 )

Deletes the managed application definition .


def create_or_update_by_id(
            self, application_definition_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
        """Creates a new managed application definition.

        :param application_definition_id: The fully qualified ID of the
         managed application definition, including the managed application name
         and the managed application definition resource type. Use the format,
         /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}
        :type application_definition_id: str
        :param parameters: Parameters supplied to the create or update a
         managed application definition.
        :type parameters:
         ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition
        :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 ApplicationDefinition
         or ClientRawResponse<ApplicationDefinition> if raw==True
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]]
        :raises:
         :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>`
        """
        raw_result = self._create_or_update_by_id_initial(
            application_definition_id=application_definition_id,
            parameters=parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

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

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

            return deserialized

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

def create_or_update_by_id ( self , application_definition_id , parameters , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _create_or_update_by_id_initial ( application_definition_id = application_definition_id , parameters = parameters , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( 'ApplicationDefinition' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) return client_raw_response return deserialized lro_delay = operation_config . get ( 'long_running_operation_timeout' , self . config . long_running_operation_timeout ) if polling is True : polling_method = ARMPolling ( lro_delay , * * operation_config ) elif polling is False : polling_method = NoPolling ( ) else : polling_method = polling return LROPoller ( self . _client , raw_result , get_long_running_output , polling_method )

Creates a new managed application definition .


def get_uri(self, request):
        ''' Return the target uri for the request.'''
        protocol = request.protocol_override \
            if request.protocol_override else self.protocol
        protocol = protocol.lower()
        port = HTTP_PORT if protocol == 'http' else HTTPS_PORT
        return protocol + '://' + request.host + ':' + str(port) + request.path

def get_uri ( self , request ) : protocol = request . protocol_override if request . protocol_override else self . protocol protocol = protocol . lower ( ) port = HTTP_PORT if protocol == 'http' else HTTPS_PORT return protocol + '://' + request . host + ':' + str ( port ) + request . path


def get_connection(self, request):
        ''' Create connection for the request. '''
        protocol = request.protocol_override \
            if request.protocol_override else self.protocol
        protocol = protocol.lower()
        target_host = request.host
        # target_port = HTTP_PORT if protocol == 'http' else HTTPS_PORT

        connection = _RequestsConnection(
            target_host, protocol, self.request_session, self.timeout)
        proxy_host = self.proxy_host
        proxy_port = self.proxy_port

        if self.proxy_host:
            headers = None
            if self.proxy_user and self.proxy_password:
                auth = base64.b64encode("{0}:{1}".format(self.proxy_user, self.proxy_password).encode())
                headers = {'Proxy-Authorization': 'Basic {0}'.format(auth.decode())}
            connection.set_tunnel(proxy_host, int(proxy_port), headers)

        return connection


def perform_request(self, request):
        ''' Sends request to cloud service server and return the response. '''
        connection = self.get_connection(request)
        try:
            connection.putrequest(request.method, request.path)

            self.send_request_headers(connection, request.headers)
            self.send_request_body(connection, request.body)

            if DEBUG_REQUESTS and request.body:
                print('request:')
                try:
                    print(request.body)
                except:  # pylint: disable=bare-except
                    pass

            resp = connection.getresponse()
            status = int(resp.status)
            message = resp.reason
            respheaders = resp.getheaders()

            # for consistency across platforms, make header names lowercase
            for i, value in enumerate(respheaders):
                respheaders[i] = (value[0].lower(), value[1])

            respbody = None
            if resp.length is None:
                respbody = resp.read()
            elif resp.length > 0:
                respbody = resp.read(resp.length)

            if DEBUG_RESPONSES and respbody:
                print('response:')
                try:
                    print(respbody)
                except:  # pylint: disable=bare-except
                    pass

            response = HTTPResponse(
                status, resp.reason, respheaders, respbody)
            if status == 307:
                new_url = urlparse(dict(respheaders)['location'])
                request.host = new_url.hostname
                request.path = new_url.path
                request.path, request.query = self._update_request_uri_query(request)
                return self.perform_request(request)
            if status >= 300:
                raise HTTPError(status, message, respheaders, respbody)

            return response
        finally:
            connection.close()

Sends request to cloud service server and return the response .


def execute_script_actions(
            self, resource_group_name, cluster_name, persist_on_success, script_actions=None, custom_headers=None, raw=False, polling=True, **operation_config):
        """Executes script actions on the specified HDInsight cluster.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param cluster_name: The name of the cluster.
        :type cluster_name: str
        :param persist_on_success: Gets or sets if the scripts needs to be
         persisted.
        :type persist_on_success: bool
        :param script_actions: The list of run time script actions.
        :type script_actions:
         list[~azure.mgmt.hdinsight.models.RuntimeScriptAction]
        :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.hdinsight.models.ErrorResponseException>`
        """
        raw_result = self._execute_script_actions_initial(
            resource_group_name=resource_group_name,
            cluster_name=cluster_name,
            persist_on_success=persist_on_success,
            script_actions=script_actions,
            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 execute_script_actions ( self , resource_group_name , cluster_name , persist_on_success , script_actions = None , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _execute_script_actions_initial ( resource_group_name = resource_group_name , cluster_name = cluster_name , persist_on_success = persist_on_success , script_actions = script_actions , 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 )

Executes script actions on the specified HDInsight cluster .


def check_front_door_name_availability(
            self, name, type, custom_headers=None, raw=False, **operation_config):
        """Check the availability of a Front Door resource name.

        :param name: The resource name to validate.
        :type name: str
        :param type: The type of the resource whose name is to be validated.
         Possible values include: 'Microsoft.Network/frontDoors',
         'Microsoft.Network/frontDoors/frontendEndpoints'
        :type type: str or ~azure.mgmt.frontdoor.models.ResourceType
        :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: CheckNameAvailabilityOutput or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>`
        """
        check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type)

        api_version = "2018-08-01"

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

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

        # 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(check_front_door_name_availability_input, 'CheckNameAvailabilityInput')

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

        deserialized = None

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

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

        return deserialized

Check the availability of a Front Door resource name .


def purge_deleted(
            self, vault_name, location, custom_headers=None, raw=False, polling=True, **operation_config):
        """Permanently deletes the specified vault. aka Purges the deleted Azure
        key vault.

        :param vault_name: The name of the soft-deleted vault.
        :type vault_name: str
        :param location: The location of the soft-deleted vault.
        :type location: 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._purge_deleted_initial(
            vault_name=vault_name,
            location=location,
            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 purge_deleted ( self , vault_name , location , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _purge_deleted_initial ( vault_name = vault_name , location = location , 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 )

Permanently deletes the specified vault . aka Purges the deleted Azure key vault .


def get_authorization_server(self):
        """ Returns the URI for the authorization server if present, otherwise empty string. """
        value = ''
        for key in ['authorization_uri', 'authorization']:
            value = self.get_value(key) or ''
            if value:
                break
        return value

def get_authorization_server ( self ) : value = '' for key in [ 'authorization_uri' , 'authorization' ] : value = self . get_value ( key ) or '' if value : break return value

Returns the URI for the authorization server if present otherwise empty string .


def _validate_request_uri(self, uri):
        """ Extracts the host authority from the given URI. """
        if not uri:
            raise ValueError('request_uri cannot be empty')

        uri = parse.urlparse(uri)
        if not uri.netloc:
            raise ValueError('request_uri must be an absolute URI')

        if uri.scheme.lower() not in ['http', 'https']:
            raise ValueError('request_uri must be HTTP or HTTPS')

        return uri.netloc

def
_validate_request_uri
(
self
,
uri
)
:
if
not
uri
:
raise
ValueError
(
'request_uri cannot be empty'
)
uri
=
parse
.
urlparse
(
uri
)
if
not
uri
.
netloc
:
raise
ValueError
(
'request_uri must be an absolute URI'
)
if
uri
.
scheme
.
lower
(
)
not
in
[
'http'
,
'https'
]
:
raise
ValueError
(
'request_uri must be HTTP or HTTPS'
)
return
uri
.
netloc

Extracts the host authority from the given URI .


def get_cli_profile():
    """Return a CLI profile class.

    .. versionadded:: 1.1.6

    :return: A CLI Profile
    :rtype: azure.cli.core._profile.Profile
    :raises: ImportError if azure-cli-core package is not available
    """

    try:
        from azure.cli.core._profile import Profile
        from azure.cli.core._session import ACCOUNT
        from azure.cli.core._environment import get_config_dir
    except ImportError:
        raise ImportError("You need to install 'azure-cli-core' to load CLI credentials")

    azure_folder = get_config_dir()
    ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json'))
    return Profile(storage=ACCOUNT)


def get_azure_cli_credentials(resource=None, with_tenant=False):
    """Return Credentials and default SubscriptionID of current loaded profile of the CLI.

    Credentials will be the "az login" command:
    https://docs.microsoft.com/cli/azure/authenticate-azure-cli

    Default subscription ID is either the only one you have, or you can define it:
    https://docs.microsoft.com/cli/azure/manage-azure-subscriptions-azure-cli

    .. versionadded:: 1.1.6

    :param str resource: The alternative resource for credentials if not ARM (GraphRBac, etc.)
    :param bool with_tenant: If True, return a three-tuple with last as tenant ID
    :return: tuple of Credentials and SubscriptionID (and tenant ID if with_tenant)
    :rtype: tuple
    """
    profile = get_cli_profile()
    cred, subscription_id, tenant_id = profile.get_login_credentials(resource=resource)
    if with_tenant:
        return cred, subscription_id, tenant_id
    else:
        return cred, subscription_id

def get_azure_cli_credentials ( resource = None , with_tenant = False ) : profile = get_cli_profile ( ) cred , subscription_id , tenant_id = profile . get_login_credentials ( resource = resource ) if with_tenant : return cred , subscription_id , tenant_id else : return cred , subscription_id

Return Credentials and default SubscriptionID of current loaded profile of the CLI .


def resolve(
            self, app_id, query, timezone_offset=None, verbose=None, staging=None, spell_check=None, bing_spell_check_subscription_key=None, log=None, custom_headers=None, raw=False, **operation_config):
        """Gets predictions for a given utterance, in the form of intents and
        entities. The current maximum query size is 500 characters.

        :param app_id: The LUIS application ID (Guid).
        :type app_id: str
        :param query: The utterance to predict.
        :type query: str
        :param timezone_offset: The timezone offset for the location of the
         request.
        :type timezone_offset: float
        :param verbose: If true, return all intents instead of just the top
         scoring intent.
        :type verbose: bool
        :param staging: Use the staging endpoint slot.
        :type staging: bool
        :param spell_check: Enable spell checking.
        :type spell_check: bool
        :param bing_spell_check_subscription_key: The subscription key to use
         when enabling Bing spell check
        :type bing_spell_check_subscription_key: str
        :param log: Log query (default is true)
        :type log: bool
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: LuisResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.luis.runtime.models.LuisResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.language.luis.runtime.models.APIErrorException>`
        """
        # Construct URL
        url = self.resolve.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'appId': self._serialize.url("app_id", app_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if timezone_offset is not None:
            query_parameters['timezoneOffset'] = self._serialize.query("timezone_offset", timezone_offset, 'float')
        if verbose is not None:
            query_parameters['verbose'] = self._serialize.query("verbose", verbose, 'bool')
        if staging is not None:
            query_parameters['staging'] = self._serialize.query("staging", staging, 'bool')
        if spell_check is not None:
            query_parameters['spellCheck'] = self._serialize.query("spell_check", spell_check, 'bool')
        if bing_spell_check_subscription_key is not None:
            query_parameters['bing-spell-check-subscription-key'] = self._serialize.query("bing_spell_check_subscription_key", bing_spell_check_subscription_key, 'str')
        if log is not None:
            query_parameters['log'] = self._serialize.query("log", log, 'bool')

        # 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(query, 'str')

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

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

        return deserialized

def
resolve
(
self
,
app_id
,
query
,
timezone_offset
=
,
verbose
=
,
staging
=
,
spell_check
=
,
bing_spell_check_subscription_key
=
,
log
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
# Construct URL
url
=
self
.
resolve
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
,
'appId'
:
self
.
_serialize
.
url
(
"app_id"
,
app_id
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
if
timezone_offset
is
not
:
query_parameters
[
'timezoneOffset'
]
=
self
.
_serialize
.
query
(
"timezone_offset"
,
timezone_offset
,
'float'
)
if
verbose
is
not
:
query_parameters
[
'verbose'
]
=
self
.
_serialize
.
query
(
"verbose"
,
verbose
,
'bool'
)
if
staging
is
not
:
query_parameters
[
'staging'
]
=
self
.
_serialize
.
query
(
"staging"
,
staging
,
'bool'
)
if
spell_check
is
not
:
query_parameters
[
'spellCheck'
]
=
self
.
_serialize
.
query
(
"spell_check"
,
spell_check
,
'bool'
)
if
bing_spell_check_subscription_key
is
not
:
query_parameters
[
'bing-spell-check-subscription-key'
]
=
self
.
_serialize
.
query
(
"bing_spell_check_subscription_key"
,
bing_spell_check_subscription_key
,
'str'
)
if
log
is
not
:
query_parameters
[
'log'
]
=
self
.
_serialize
.
query
(
"log"
,
log
,
'bool'
)
# 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
(
query
,
'str'
)
# Construct and send request
request
=
self
.
_client
.
post
(
url
,
query_parameters
,
header_parameters
,
body_content
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
APIErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'LuisResult'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Gets predictions for a given utterance in the form of intents and entities . The current maximum query size is 500 characters .


def check_name_availability_local(
            self, location, name, type, custom_headers=None, raw=False, **operation_config):
        """Check Name Availability for global uniqueness.

        :param location: The location in which uniqueness will be verified.
        :type location: str
        :param name: Resource Name To Verify
        :type name: str
        :param type: Fully qualified resource type which includes provider
         namespace
        :type type: 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: CheckNameAvailabilityResponse or ClientRawResponse if
         raw=true
        :rtype: ~azure.mgmt.mixedreality.models.CheckNameAvailabilityResponse
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.mixedreality.models.ErrorResponseException>`
        """
        check_name_availability = models.CheckNameAvailabilityRequest(name=name, type=type)

        # Construct URL
        url = self.check_name_availability_local.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'location': self._serialize.url("location", location, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$')
        }
        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 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(check_name_availability, 'CheckNameAvailabilityRequest')

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

        deserialized = None

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

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

        return deserialized

def
check_name_availability_local
(
self
,
location
,
name
,
type
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
check_name_availability
=
models
.
CheckNameAvailabilityRequest
(
name
=
name
,
type
=
type
)
# Construct URL
url
=
self
.
check_name_availability_local
.
metadata
[
'url'
]
path_format_arguments
=
{
'subscriptionId'
:
self
.
_serialize
.
url
(
"self.config.subscription_id"
,
self
.
config
.
subscription_id
,
'str'
)
,
'location'
:
self
.
_serialize
.
url
(
"location"
,
location
,
'str'
,
max_length
=
90
,
min_length
=
1
,
pattern
=
r'^[-\w\._\(\)]+$'
)
}
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
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
check_name_availability
,
'CheckNameAvailabilityRequest'
)
# 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
.
ErrorResponseException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'CheckNameAvailabilityResponse'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Check Name Availability for global uniqueness .


def open(self, method, url):
        '''
        Opens the request.

        method:
            the request VERB 'GET', 'POST', etc.
        url:
            the url to connect
        '''
        flag = VARIANT.create_bool_false()
        _method = BSTR(method)
        _url = BSTR(url)
        _WinHttpRequest._Open(self, _method, _url, flag)

def open ( self , method , url ) : flag = VARIANT . create_bool_false ( ) _method = BSTR ( method ) _url = BSTR ( url ) _WinHttpRequest . _Open ( self , _method , _url , flag )


def set_timeout(self, timeout_in_seconds):
        ''' Sets up the timeout for the request. '''
        timeout_in_ms = int(timeout_in_seconds * 1000)
        _WinHttpRequest._SetTimeouts(
            self, 0, timeout_in_ms, timeout_in_ms, timeout_in_ms)


def set_request_header(self, name, value):
        ''' Sets the request header. '''

        _name = BSTR(name)
        _value = BSTR(value)
        _WinHttpRequest._SetRequestHeader(self, _name, _value)

def set_request_header ( self , name , value ) : _name = BSTR ( name ) _value = BSTR ( value ) _WinHttpRequest . _SetRequestHeader ( self , _name , _value )


def get_all_response_headers(self):
        ''' Gets back all response headers. '''

        bstr_headers = c_void_p()
        _WinHttpRequest._GetAllResponseHeaders(self, byref(bstr_headers))
        bstr_headers = ctypes.cast(bstr_headers, c_wchar_p)
        headers = bstr_headers.value
        _SysFreeString(bstr_headers)
        return headers

def get_all_response_headers ( self ) : bstr_headers = c_void_p ( ) _WinHttpRequest . _GetAllResponseHeaders ( self , byref ( bstr_headers ) ) bstr_headers = ctypes . cast ( bstr_headers , c_wchar_p ) headers = bstr_headers . value _SysFreeString ( bstr_headers ) return headers


def send(self, request=None):
        ''' Sends the request body. '''

        # Sends VT_EMPTY if it is GET, HEAD request.
        if request is None:
            var_empty = VARIANT.create_empty()
            _WinHttpRequest._Send(self, var_empty)
        else:  # Sends request body as SAFEArray.
            _request = VARIANT.create_safearray_from_str(request)
            _WinHttpRequest._Send(self, _request)


def status(self):
        ''' Gets status of response. '''

        status = c_long()
        _WinHttpRequest._Status(self, byref(status))
        return int(status.value)

def status ( self ) : status = c_long ( ) _WinHttpRequest . _Status ( self , byref ( status ) ) return int ( status . value )


def status_text(self):
        ''' Gets status text of response. '''

        bstr_status_text = c_void_p()
        _WinHttpRequest._StatusText(self, byref(bstr_status_text))
        bstr_status_text = ctypes.cast(bstr_status_text, c_wchar_p)
        status_text = bstr_status_text.value
        _SysFreeString(bstr_status_text)
        return status_text

def status_text ( self ) : bstr_status_text = c_void_p ( ) _WinHttpRequest . _StatusText ( self , byref ( bstr_status_text ) ) bstr_status_text = ctypes . cast ( bstr_status_text , c_wchar_p ) status_text = bstr_status_text . value _SysFreeString ( bstr_status_text ) return status_text


def response_body(self):
        '''
        Gets response body as a SAFEARRAY and converts the SAFEARRAY to str.
        '''
        var_respbody = VARIANT()
        _WinHttpRequest._ResponseBody(self, byref(var_respbody))
        if var_respbody.is_safearray_of_bytes():
            respbody = var_respbody.str_from_safearray()
            return respbody
        else:
            return ''

def response_body ( self ) : var_respbody = VARIANT ( ) _WinHttpRequest . _ResponseBody ( self , byref ( var_respbody ) ) if var_respbody . is_safearray_of_bytes ( ) : respbody = var_respbody . str_from_safearray ( ) return respbody else : return ''

Gets response body as a SAFEARRAY and converts the SAFEARRAY to str .


def set_client_certificate(self, certificate):
        '''Sets client certificate for the request. '''
        _certificate = BSTR(certificate)
        _WinHttpRequest._SetClientCertificate(self, _certificate)

def set_client_certificate ( self , certificate ) : _certificate = BSTR ( certificate ) _WinHttpRequest . _SetClientCertificate ( self , _certificate )

Sets client certificate for the request .


def putrequest(self, method, uri):
        ''' Connects to host and sends the request. '''

        protocol = unicode(self.protocol + '://')
        url = protocol + self.host + unicode(uri)
        self._httprequest.set_timeout(self.timeout)
        self._httprequest.open(unicode(method), url)

        # sets certificate for the connection if cert_file is set.
        if self.cert_file is not None:
            self._httprequest.set_client_certificate(unicode(self.cert_file))

Connects to host and sends the request .


def putheader(self, name, value):
        ''' Sends the headers of request. '''
        if sys.version_info < (3,):
            name = str(name).decode('utf-8')
            value = str(value).decode('utf-8')
        self._httprequest.set_request_header(name, value)

def putheader ( self , name , value ) : if sys . version_info < ( 3 , ) : name = str ( name ) . decode ( 'utf-8' ) value = str ( value ) . decode ( 'utf-8' ) self . _httprequest . set_request_header ( name , value )


def send(self, request_body):
        ''' Sends request body. '''
        if not request_body:
            self._httprequest.send()
        else:
            self._httprequest.send(request_body)

def send ( self , request_body ) : if not request_body : self . _httprequest . send ( ) else : self . _httprequest . send ( request_body )


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
:
# 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 _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_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
)
# 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
=
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
=
,
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
:
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_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
)
:
# 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

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
:
# 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
:
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

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
)
:
# 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
=
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
:
# 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
:
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

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 .