def convert_to_single_placement_group(
            self, resource_group_name, vm_scale_set_name, active_placement_group_id=None, custom_headers=None, raw=False, **operation_config):
        """Converts SinglePlacementGroup property to false for a existing virtual
        machine scale set.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param vm_scale_set_name: The name of the virtual machine scale set to
         create or update.
        :type vm_scale_set_name: str
        :param active_placement_group_id: Id of the placement group in which
         you want future virtual machine instances to be placed. To query
         placement group Id, please use Virtual Machine Scale Set VMs - Get
         API. If not provided, the platform will choose one with maximum number
         of virtual machine instances.
        :type active_placement_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: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        parameters = models.VMScaleSetConvertToSinglePlacementGroupInput(active_placement_group_id=active_placement_group_id)

        # Construct URL
        url = self.convert_to_single_placement_group.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput')

        # 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]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

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

Converts SinglePlacementGroup property to false for a existing virtual machine scale set .


def screen_text(
            self, text_content_type, text_content, language=None, autocorrect=False, pii=False, list_id=None, classify=False, custom_headers=None, raw=False, callback=None, **operation_config):
        """Detect profanity and match against custom and shared blacklists.

        Detects profanity in more than 100 languages and match against custom
        and shared blacklists.

        :param text_content_type: The content type. Possible values include:
         'text/plain', 'text/html', 'text/xml', 'text/markdown'
        :type text_content_type: str
        :param text_content: Content to screen.
        :type text_content: Generator
        :param language: Language of the text.
        :type language: str
        :param autocorrect: Autocorrect text.
        :type autocorrect: bool
        :param pii: Detect personal identifiable information.
        :type pii: bool
        :param list_id: The list Id.
        :type list_id: str
        :param classify: Classify input.
        :type classify: 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 callback: When specified, will be called with each chunk of
         data that is streamed. The callback should take two arguments, the
         bytes of the current chunk of data and the response object. If the
         data is uploading, response will be None.
        :type callback: Callable[Bytes, response=None]
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: Screen or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.Screen
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.screen_text.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 = {}
        if language is not None:
            query_parameters['language'] = self._serialize.query("language", language, 'str')
        if autocorrect is not None:
            query_parameters['autocorrect'] = self._serialize.query("autocorrect", autocorrect, 'bool')
        if pii is not None:
            query_parameters['PII'] = self._serialize.query("pii", pii, 'bool')
        if list_id is not None:
            query_parameters['listId'] = self._serialize.query("list_id", list_id, 'str')
        if classify is not None:
            query_parameters['classify'] = self._serialize.query("classify", classify, 'bool')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'text/plain'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("text_content_type", text_content_type, 'str')

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

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

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

        deserialized = None

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

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

        return deserialized

def screen_text ( self , text_content_type , text_content , language = None , autocorrect = False , pii = False , list_id = None , classify = False , custom_headers = None , raw = False , callback = None , ** operation_config ) : url = self . screen_text . metadata [ 'url' ] path_format_arguments = { 'Endpoint' : self . _serialize . url ( "self.config.endpoint" , self . config . endpoint , 'str' , skip_quote = True ) } url = self . _client . format_url ( url , ** path_format_arguments ) query_parameters = { } if language is not None : query_parameters [ 'language' ] = self . _serialize . query ( "language" , language , 'str' ) if autocorrect is not None : query_parameters [ 'autocorrect' ] = self . _serialize . query ( "autocorrect" , autocorrect , 'bool' ) if pii is not None : query_parameters [ 'PII' ] = self . _serialize . query ( "pii" , pii , 'bool' ) if list_id is not None : query_parameters [ 'listId' ] = self . _serialize . query ( "list_id" , list_id , 'str' ) if classify is not None : query_parameters [ 'classify' ] = self . _serialize . query ( "classify" , classify , 'bool' ) header_parameters = { } header_parameters [ 'Accept' ] = 'application/json' header_parameters [ 'Content-Type' ] = 'text/plain' if custom_headers : header_parameters . update ( custom_headers ) header_parameters [ 'Content-Type' ] = self . _serialize . header ( "text_content_type" , text_content_type , 'str' ) body_content = self . _client . stream_upload ( text_content , callback ) 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 ( 'Screen' , response ) if raw : client_raw_response = ClientRawResponse ( deserialized , response ) return client_raw_response return deserialized

Detect profanity and match against custom and shared blacklists .


def create_key(
            self, vault_base_url, key_name, kty, key_size=None, key_ops=None, key_attributes=None, tags=None, curve=None, custom_headers=None, raw=False, **operation_config):
        """Creates a new key, stores it, then returns key parameters and
        attributes to the client.

        The create key operation can be used to create any key type in Azure
        Key Vault. If the named key already exists, Azure Key Vault creates a
        new version of the key. It requires the keys/create permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: The name for the new key. The system will generate
         the version name for the new key.
        :type key_name: str
        :param kty: The type of key to create. For valid values, see
         JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA',
         'RSA-HSM', 'oct'
        :type kty: str or ~azure.keyvault.v2016_10_01.models.JsonWebKeyType
        :param key_size: The key size in bits. For example: 2048, 3072, or
         4096 for RSA.
        :type key_size: int
        :param key_ops:
        :type key_ops: list[str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyOperation]
        :param key_attributes:
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, str]
        :param curve: Elliptic curve name. For valid values, see
         JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384',
         'P-521', 'SECP256K1'
        :type curve: str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyCurveName
        :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: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyCreateParameters(kty=kty, key_size=key_size, key_ops=key_ops, key_attributes=key_attributes, tags=tags, curve=curve)

        # Construct URL
        url = self.create_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if 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, 'KeyCreateParameters')

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

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

        deserialized = None

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

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

        return deserialized

def
create_key
(
self
,
vault_base_url
,
key_name
,
kty
,
key_size
=
,
key_ops
=
,
key_attributes
=
,
tags
=
,
curve
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
KeyCreateParameters
(
kty
=
kty
,
key_size
=
key_size
,
key_ops
=
key_ops
,
key_attributes
=
key_attributes
,
tags
=
tags
,
curve
=
curve
)
url
=
self
.
create_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyCreateParameters'
)
request
=
self
.
_client
.
post
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Creates a new key stores it then returns key parameters and attributes to the client .


def import_key(
            self, vault_base_url, key_name, key, hsm=None, key_attributes=None, tags=None, custom_headers=None, raw=False, **operation_config):
        """Imports an externally created key, stores it, and returns key
        parameters and attributes to the client.

        The import key operation may be used to import any key type into an
        Azure Key Vault. If the named key already exists, Azure Key Vault
        creates a new version of the key. This operation requires the
        keys/import permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: Name for the imported key.
        :type key_name: str
        :param key: The Json web key
        :type key: ~azure.keyvault.v2016_10_01.models.JsonWebKey
        :param hsm: Whether to import as a hardware key (HSM) or software key.
        :type hsm: bool
        :param key_attributes: The key management attributes.
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, 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: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyImportParameters(hsm=hsm, key=key, key_attributes=key_attributes, tags=tags)

        # Construct URL
        url = self.import_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if 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, 'KeyImportParameters')

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

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

        deserialized = None

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

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

        return deserialized

def
import_key
(
self
,
vault_base_url
,
key_name
,
key
,
hsm
=
,
key_attributes
=
,
tags
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
KeyImportParameters
(
hsm
=
hsm
,
key
=
key
,
key_attributes
=
key_attributes
,
tags
=
tags
)
url
=
self
.
import_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyImportParameters'
)
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Imports an externally created key stores it and returns key parameters and attributes to the client .


def update_key(
            self, vault_base_url, key_name, key_version, key_ops=None, key_attributes=None, tags=None, custom_headers=None, raw=False, **operation_config):
        """The update key operation changes specified attributes of a stored key
        and can be applied to any key type and key version stored in Azure Key
        Vault.

        In order to perform this operation, the key must already exist in the
        Key Vault. Note: The cryptographic material of a key itself cannot be
        changed. This operation requires the keys/update permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: The name of key to update.
        :type key_name: str
        :param key_version: The version of the key to update.
        :type key_version: str
        :param key_ops: Json web key operations. For more information on
         possible key operations, see JsonWebKeyOperation.
        :type key_ops: list[str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyOperation]
        :param key_attributes:
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, 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: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyUpdateParameters(key_ops=key_ops, key_attributes=key_attributes, tags=tags)

        # Construct URL
        url = self.update_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str'),
            'key-version': self._serialize.url("key_version", key_version, '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')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(parameters, 'KeyUpdateParameters')

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

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

        deserialized = None

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

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

        return deserialized

def
update_key
(
self
,
vault_base_url
,
key_name
,
key_version
,
key_ops
=
,
key_attributes
=
,
tags
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
KeyUpdateParameters
(
key_ops
=
key_ops
,
key_attributes
=
key_attributes
,
tags
=
tags
)
url
=
self
.
update_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
)
,
'key-version'
:
self
.
_serialize
.
url
(
"key_version"
,
key_version
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyUpdateParameters'
)
request
=
self
.
_client
.
patch
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault .


def set_secret(
            self, vault_base_url, secret_name, value, tags=None, content_type=None, secret_attributes=None, custom_headers=None, raw=False, **operation_config):
        """Sets a secret in a specified key vault.

        The SET operation adds a secret to the Azure Key Vault. If the named
        secret already exists, Azure Key Vault creates a new version of that
        secret. This operation requires the secrets/set permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param secret_name: The name of the secret.
        :type secret_name: str
        :param value: The value of the secret.
        :type value: str
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, str]
        :param content_type: Type of the secret value such as a password.
        :type content_type: str
        :param secret_attributes: The secret management attributes.
        :type secret_attributes:
         ~azure.keyvault.v2016_10_01.models.SecretAttributes
        :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: SecretBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.SecretBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.SecretSetParameters(value=value, tags=tags, content_type=content_type, secret_attributes=secret_attributes)

        # Construct URL
        url = self.set_secret.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'secret-name': self._serialize.url("secret_name", secret_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if 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, 'SecretSetParameters')

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

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

        deserialized = None

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

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

        return deserialized

def
set_secret
(
self
,
vault_base_url
,
secret_name
,
value
,
tags
=
,
content_type
=
,
secret_attributes
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameters
=
models
.
SecretSetParameters
(
value
=
value
,
tags
=
tags
,
content_type
=
content_type
,
secret_attributes
=
secret_attributes
)
url
=
self
.
set_secret
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'secret-name'
:
self
.
_serialize
.
url
(
"secret_name"
,
secret_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameters
,
'SecretSetParameters'
)
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'SecretBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Sets a secret in a specified key vault .


def set_certificate_issuer(
            self, vault_base_url, issuer_name, provider, credentials=None, organization_details=None, attributes=None, custom_headers=None, raw=False, **operation_config):
        """Sets the specified certificate issuer.

        The SetCertificateIssuer operation adds or updates the specified
        certificate issuer. This operation requires the certificates/setissuers
        permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param issuer_name: The name of the issuer.
        :type issuer_name: str
        :param provider: The issuer provider.
        :type provider: str
        :param credentials: The credentials to be used for the issuer.
        :type credentials:
         ~azure.keyvault.v2016_10_01.models.IssuerCredentials
        :param organization_details: Details of the organization as provided
         to the issuer.
        :type organization_details:
         ~azure.keyvault.v2016_10_01.models.OrganizationDetails
        :param attributes: Attributes of the issuer object.
        :type attributes: ~azure.keyvault.v2016_10_01.models.IssuerAttributes
        :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: IssuerBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.IssuerBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameter = models.CertificateIssuerSetParameters(provider=provider, credentials=credentials, organization_details=organization_details, attributes=attributes)

        # Construct URL
        url = self.set_certificate_issuer.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'issuer-name': self._serialize.url("issuer_name", issuer_name, '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')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(parameter, 'CertificateIssuerSetParameters')

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

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

        deserialized = None

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

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

        return deserialized

def
set_certificate_issuer
(
self
,
vault_base_url
,
issuer_name
,
provider
,
credentials
=
,
organization_details
=
,
attributes
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
parameter
=
models
.
CertificateIssuerSetParameters
(
provider
=
provider
,
credentials
=
credentials
,
organization_details
=
organization_details
,
attributes
=
attributes
)
url
=
self
.
set_certificate_issuer
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'issuer-name'
:
self
.
_serialize
.
url
(
"issuer_name"
,
issuer_name
,
'str'
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
body_content
=
self
.
_serialize
.
body
(
parameter
,
'CertificateIssuerSetParameters'
)
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'IssuerBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized


def from_connection_string(cls, conn_str, *, loop=None, **kwargs):
        """Create a Service Bus client from a connection string.

        :param conn_str: The connection string.
        :type conn_str: str

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START create_async_servicebus_client_connstr]
                :end-before: [END create_async_servicebus_client_connstr]
                :language: python
                :dedent: 4
                :caption: Create a ServiceBusClient via a connection string.

        """
        address, policy, key, _ = parse_conn_str(conn_str)
        parsed_namespace = urlparse(address)
        namespace, _, base = parsed_namespace.hostname.partition('.')
        return cls(
            service_namespace=namespace,
            shared_access_key_name=policy,
            shared_access_key_value=key,
            host_base='.' + base,
            loop=loop,
            **kwargs)

def from_connection_string ( cls , conn_str , * , loop = None , ** kwargs ) : address , policy , key , _ = parse_conn_str ( conn_str ) parsed_namespace = urlparse ( address ) namespace , _ , base = parsed_namespace . hostname . partition ( '.' ) return cls ( service_namespace = namespace , shared_access_key_name = policy , shared_access_key_value = key , host_base = '.' + base , loop = loop , ** kwargs )

Create a Service Bus client from a connection string .


def get_subscription(self, topic_name, subscription_name):
        """Get an async client for a subscription entity.

        :param topic_name: The name of the topic.
        :type topic_name: str
        :param subscription_name: The name of the subscription.
        :type subscription_name: str
        :rtype: ~azure.servicebus.aio.async_client.SubscriptionClient
        :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found.
        :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the subscription is not found.

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START get_async_subscription_client]
                :end-before: [END get_async_subscription_client]
                :language: python
                :dedent: 4
                :caption: Get a TopicClient for the specified topic.

        """
        try:
            subscription = self.mgmt_client.get_subscription(topic_name, subscription_name)
        except requests.exceptions.ConnectionError as e:
            raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
        except AzureServiceBusResourceNotFound:
            raise ServiceBusResourceNotFound("Specificed subscription does not exist.")
        return SubscriptionClient.from_entity(
            self._get_host(), topic_name, subscription,
            shared_access_key_name=self.shared_access_key_name,
            shared_access_key_value=self.shared_access_key_value,
            loop=self.loop,
            debug=self.debug)

Get an async client for a subscription entity .


def list_subscriptions(self, topic_name):
        """Get an async client for all subscription entities in the topic.

        :param topic_name: The topic to list subscriptions for.
        :type topic_name: str
        :rtype: list[~azure.servicebus.aio.async_client.SubscriptionClient]
        :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found.
        :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the topic is not found.
        """
        try:
            subs = self.mgmt_client.list_subscriptions(topic_name)
        except requests.exceptions.ConnectionError as e:
            raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
        except AzureServiceBusResourceNotFound:
            raise ServiceBusResourceNotFound("Specificed topic does not exist.")
        sub_clients = []
        for sub in subs:
            sub_clients.append(SubscriptionClient.from_entity(
                self._get_host(), topic_name, sub,
                shared_access_key_name=self.shared_access_key_name,
                shared_access_key_value=self.shared_access_key_value,
                loop=self.loop,
                debug=self.debug))
        return sub_clients

def
list_subscriptions
(
self
,
topic_name
)
:
try
:
subs
=
self
.
mgmt_client
.
list_subscriptions
(
topic_name
)
except
requests
.
exceptions
.
ConnectionError
as
e
:
raise
ServiceBusConnectionError
(
"Namespace: {} not found"
.
format
(
self
.
service_namespace
)
,
e
)
except
AzureServiceBusResourceNotFound
:
raise
ServiceBusResourceNotFound
(
"Specificed topic does not exist."
)
sub_clients
=
[
]
for
sub
in
subs
:
sub_clients
.
append
(
SubscriptionClient
.
from_entity
(
self
.
_get_host
(
)
,
topic_name
,
sub
,
shared_access_key_name
=
self
.
shared_access_key_name
,
shared_access_key_value
=
self
.
shared_access_key_value
,
loop
=
self
.
loop
,
debug
=
self
.
debug
)
)
return
sub_clients

Get an async client for all subscription entities in the topic .


async def send(self, messages, message_timeout=0, session=None, **kwargs):
        """Send one or more messages to the current entity.

        This operation will open a single-use connection, send the supplied messages, and close
        connection. If the entity requires sessions, a session ID must be either
        provided here, or set on each outgoing message.

        :param messages: One or more messages to be sent.
        :type messages: ~azure.servicebus.aio.async_message.Message or
         list[~azure.servicebus.aio.async_message.Message]
        :param message_timeout: The period in seconds during which the Message must be
         sent. If the send is not completed in this time it will return a failure result.
        :type message_timeout: int
        :param session: An optional session ID. If supplied this session ID will be
         applied to every outgoing message sent with this Sender.
         If an individual message already has a session ID, that will be
         used instead. If no session ID is supplied here, nor set on an outgoing
         message, a ValueError will be raised if the entity is sessionful.
        :type session: str or ~uuid.Guid
        :raises: ~azure.servicebus.common.errors.MessageSendFailed
        :returns: A list of the send results of all the messages. Each
         send result is a tuple with two values. The first is a boolean, indicating `True`
         if the message sent, or `False` if it failed. The second is an error if the message
         failed, otherwise it will be `None`.
        :rtype: list[tuple[bool, ~azure.servicebus.common.errors.MessageSendFailed]]

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START queue_client_send]
                :end-before: [END queue_client_send]
                :language: python
                :dedent: 4
                :caption: Send a single message.

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

        """
        async with self.get_sender(message_timeout=message_timeout, session=session, **kwargs) as sender:
            if isinstance(messages, Message):
                sender.queue_message(messages)
            else:
                try:
                    messages = list(messages)
                except TypeError:
                    raise TypeError(
                        "Value of messages must be a 'Message' object or a synchronous iterable of 'Message' objects.")

                for m in messages:
                    if not isinstance(m, Message):
                        raise TypeError("Item in iterator is not of type 'Message'.")
                    sender.queue_message(m)

            return await sender.send_pending_messages()

Send one or more messages to the current entity .


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

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

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

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

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

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

Get a Sender for the Service Bus endpoint .


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

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

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

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

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

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

Get a Receiver for the Service Bus endpoint .


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

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

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

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

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

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

Get a Receiver for the deadletter endpoint of the entity .


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

    if response is None:
        return None

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

    return result

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

Extracts request id from response header .


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

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

        return response

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

Performs a GET request and returns the response .


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

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

        return response

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

Performs a PUT request and returns the response .


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

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

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

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

Waits for an asynchronous operation to complete .


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

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

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

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


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

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

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

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

        return request.headers

def _update_management_header ( self , request , x_ms_version ) : if request . method in [ 'PUT' , 'POST' , 'MERGE' , 'DELETE' ] : request . headers . append ( ( 'Content-Length' , str ( len ( request . body ) ) ) ) request . headers . append ( ( 'x-ms-version' , x_ms_version or self . x_ms_version ) ) if not request . method in [ 'GET' , 'HEAD' ] : for name , _ in request . headers : if 'content-type' == name . lower ( ) : break else : request . headers . append ( ( 'Content-Type' , self . content_type ) ) return request . headers


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

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

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

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

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

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

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

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

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

Assumed called on Travis to prepare a package to be deployed


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

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

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param maxresults: Maximum number of results to return in a page. If
         not specified the service will return up to 25 results.
        :type maxresults: int
        :param include_pending: Specifies whether to include certificates
         which are not completely provisioned.
        :type include_pending: bool
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: An iterator like instance of CertificateItem
        :rtype:
         ~azure.keyvault.v7_0.models.CertificateItemPaged[~azure.keyvault.v7_0.models.CertificateItem]
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v7_0.models.KeyVaultErrorException>`
        """
        def internal_paging(next_link=None, raw=False):

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

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

            else:
                url = next_link
                query_parameters = {}

            # Construct headers
            header_parameters = {}
            header_parameters['Content-Type'] = 'application/json; charset=utf-8'
            if self.config.generate_client_request_id:
                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
            if custom_headers:
                header_parameters.update(custom_headers)
            if self.config.accept_language is not None:
                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

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

            return response

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

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

        return deserialized

def
get_certificates
(
self
,
vault_base_url
,
maxresults
=
,
include_pending
=
,
custom_headers
=
,
raw
=
False
,
**
operation_config
)
:
def
internal_paging
(
next_link
=
,
raw
=
False
)
:
if
not
next_link
:
url
=
self
.
get_certificates
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
**
path_format_arguments
)
query_parameters
=
{
}
if
maxresults
is
not
:
query_parameters
[
'maxresults'
]
=
self
.
_serialize
.
query
(
"maxresults"
,
maxresults
,
'int'
,
maximum
=
25
,
minimum
=
1
)
if
include_pending
is
not
:
query_parameters
[
'includePending'
]
=
self
.
_serialize
.
query
(
"include_pending"
,
include_pending
,
'bool'
)
query_parameters
[
'api-version'
]
=
self
.
_serialize
.
query
(
"self.api_version"
,
self
.
api_version
,
'str'
)
else
:
url
=
next_link
query_parameters
=
{
}
header_parameters
=
{
}
header_parameters
[
'Content-Type'
]
=
'application/json; charset=utf-8'
if
self
.
config
.
generate_client_request_id
:
header_parameters
[
'x-ms-client-request-id'
]
=
str
(
uuid
.
uuid1
(
)
)
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
if
self
.
config
.
accept_language
is
not
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
request
=
self
.
_client
.
get
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
stream
=
False
,
**
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
return
response
deserialized
=
models
.
CertificateItemPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
)
if
raw
:
header_dict
=
{
}
client_raw_response
=
models
.
CertificateItemPaged
(
internal_paging
,
self
.
_deserialize
.
dependencies
,
header_dict
)
return
client_raw_response
return
deserialized

List certificates in a specified key vault .


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

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            _ServiceBusManagementXmlSerializer.xml_to_region)

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

Get list of available service bus regions .


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

        return _MinidomXmlToObject.convert_response_to_feeds(
            response,
            _ServiceBusManagementXmlSerializer.xml_to_namespace)

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

List the service bus namespaces defined on the account .


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

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

        return _ServiceBusManagementXmlSerializer.xml_to_namespace(
            response.body)

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

Get details about a specific namespace .


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

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

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

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


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

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

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

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


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

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

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

        return _ServiceBusManagementXmlSerializer.xml_to_namespace_availability(
            response.body)

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


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

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

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

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

Retrieves the topics in the service namespace .


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

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

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

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

Retrieves the notification hubs in the service namespace .


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

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

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

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

Retrieves the relays in the service namespace .


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

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

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

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

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


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

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

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

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

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


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

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

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

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

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


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

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

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

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

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


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

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

Create a virtual environment in a directory .


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

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

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

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


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

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

        return _SqlManagementXmlSerializer.xml_to_create_server_response(
            response.body)

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

Create a new Azure SQL Database server .


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

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

Reset the administrator password for a server .


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

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

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

Gets quotas for an Azure SQL Database Server .


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

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

Gets the event logs for an Azure SQL Database Server .


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

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

Creates an Azure SQL Database server firewall rule .


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

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

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

Update a firewall rule for an Azure SQL Database server .


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

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

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

Deletes an Azure SQL Database server firewall rule .


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

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

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

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


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

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

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

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


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

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

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