partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
Message.defer
Defer the message. This message will remain in the queue but must be received specifically by its sequence number in order to be processed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails.
azure-servicebus/azure/servicebus/common/message.py
def defer(self): """Defer the message. This message will remain in the queue but must be received specifically by its sequence number in order to be processed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('defer') try: self.message.modify(True, True) except Exception as e: raise MessageSettleFailed("defer", e)
def defer(self): """Defer the message. This message will remain in the queue but must be received specifically by its sequence number in order to be processed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('defer') try: self.message.modify(True, True) except Exception as e: raise MessageSettleFailed("defer", e)
[ "Defer", "the", "message", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/message.py#L360-L375
[ "def", "defer", "(", "self", ")", ":", "self", ".", "_is_live", "(", "'defer'", ")", "try", ":", "self", ".", "message", ".", "modify", "(", "True", ",", "True", ")", "except", "Exception", "as", "e", ":", "raise", "MessageSettleFailed", "(", "\"defer\"", ",", "e", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DeferredMessage.dead_letter
Move the message to the Dead Letter queue. The Dead Letter queue is a sub-queue that can be used to store messages that failed to process correctly, or otherwise require further inspection or processing. The queue can also be configured to send expired messages to the Dead Letter queue. To receive dead-lettered messages, use `QueueClient.get_deadletter_receiver()` or `SubscriptionClient.get_deadletter_receiver()`. :param description: The reason for dead-lettering the message. :type description: str :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails.
azure-servicebus/azure/servicebus/common/message.py
def dead_letter(self, description=None): """Move the message to the Dead Letter queue. The Dead Letter queue is a sub-queue that can be used to store messages that failed to process correctly, or otherwise require further inspection or processing. The queue can also be configured to send expired messages to the Dead Letter queue. To receive dead-lettered messages, use `QueueClient.get_deadletter_receiver()` or `SubscriptionClient.get_deadletter_receiver()`. :param description: The reason for dead-lettering the message. :type description: str :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('dead-letter') details = { 'deadletter-reason': str(description) if description else "", 'deadletter-description': str(description) if description else ""} self._receiver._settle_deferred( # pylint: disable=protected-access 'suspended', [self.lock_token], dead_letter_details=details) self._settled = True
def dead_letter(self, description=None): """Move the message to the Dead Letter queue. The Dead Letter queue is a sub-queue that can be used to store messages that failed to process correctly, or otherwise require further inspection or processing. The queue can also be configured to send expired messages to the Dead Letter queue. To receive dead-lettered messages, use `QueueClient.get_deadletter_receiver()` or `SubscriptionClient.get_deadletter_receiver()`. :param description: The reason for dead-lettering the message. :type description: str :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('dead-letter') details = { 'deadletter-reason': str(description) if description else "", 'deadletter-description': str(description) if description else ""} self._receiver._settle_deferred( # pylint: disable=protected-access 'suspended', [self.lock_token], dead_letter_details=details) self._settled = True
[ "Move", "the", "message", "to", "the", "Dead", "Letter", "queue", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/message.py#L495-L517
[ "def", "dead_letter", "(", "self", ",", "description", "=", "None", ")", ":", "self", ".", "_is_live", "(", "'dead-letter'", ")", "details", "=", "{", "'deadletter-reason'", ":", "str", "(", "description", ")", "if", "description", "else", "\"\"", ",", "'deadletter-description'", ":", "str", "(", "description", ")", "if", "description", "else", "\"\"", "}", "self", ".", "_receiver", ".", "_settle_deferred", "(", "# pylint: disable=protected-access", "'suspended'", ",", "[", "self", ".", "lock_token", "]", ",", "dead_letter_details", "=", "details", ")", "self", ".", "_settled", "=", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DeferredMessage.abandon
Abandon the message. This message will be returned to the queue to be reprocessed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails.
azure-servicebus/azure/servicebus/common/message.py
def abandon(self): """Abandon the message. This message will be returned to the queue to be reprocessed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('abandon') self._receiver._settle_deferred('abandoned', [self.lock_token]) # pylint: disable=protected-access self._settled = True
def abandon(self): """Abandon the message. This message will be returned to the queue to be reprocessed. :raises: ~azure.servicebus.common.errors.MessageAlreadySettled if the message has been settled. :raises: ~azure.servicebus.common.errors.MessageLockExpired if message lock has already expired. :raises: ~azure.servicebus.common.errors.SessionLockExpired if session lock has already expired. :raises: ~azure.servicebus.common.errors.MessageSettleFailed if message settle operation fails. """ self._is_live('abandon') self._receiver._settle_deferred('abandoned', [self.lock_token]) # pylint: disable=protected-access self._settled = True
[ "Abandon", "the", "message", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/common/message.py#L519-L531
[ "def", "abandon", "(", "self", ")", ":", "self", ".", "_is_live", "(", "'abandon'", ")", "self", ".", "_receiver", ".", "_settle_deferred", "(", "'abandoned'", ",", "[", "self", ".", "lock_token", "]", ")", "# pylint: disable=protected-access", "self", ".", "_settled", "=", "True" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
VpnSitesConfigurationOperations.download
Gives the sas-url to download the configurations for vpn-sites in a resource group. :param resource_group_name: The resource group name. :type resource_group_name: str :param virtual_wan_name: The name of the VirtualWAN for which configuration of all vpn-sites is needed. :type virtual_wan_name: str :param vpn_sites: List of resource-ids of the vpn-sites for which config is to be downloaded. :type vpn_sites: list[~azure.mgmt.network.v2018_04_01.models.SubResource] :param output_blob_sas_url: The sas-url to download the configurations for vpn-sites :type output_blob_sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorException<azure.mgmt.network.v2018_04_01.models.ErrorException>`
azure-mgmt-network/azure/mgmt/network/v2018_04_01/operations/vpn_sites_configuration_operations.py
def download( self, resource_group_name, virtual_wan_name, vpn_sites=None, output_blob_sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config): """Gives the sas-url to download the configurations for vpn-sites in a resource group. :param resource_group_name: The resource group name. :type resource_group_name: str :param virtual_wan_name: The name of the VirtualWAN for which configuration of all vpn-sites is needed. :type virtual_wan_name: str :param vpn_sites: List of resource-ids of the vpn-sites for which config is to be downloaded. :type vpn_sites: list[~azure.mgmt.network.v2018_04_01.models.SubResource] :param output_blob_sas_url: The sas-url to download the configurations for vpn-sites :type output_blob_sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorException<azure.mgmt.network.v2018_04_01.models.ErrorException>` """ raw_result = self._download_initial( resource_group_name=resource_group_name, virtual_wan_name=virtual_wan_name, vpn_sites=vpn_sites, output_blob_sas_url=output_blob_sas_url, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def download( self, resource_group_name, virtual_wan_name, vpn_sites=None, output_blob_sas_url=None, custom_headers=None, raw=False, polling=True, **operation_config): """Gives the sas-url to download the configurations for vpn-sites in a resource group. :param resource_group_name: The resource group name. :type resource_group_name: str :param virtual_wan_name: The name of the VirtualWAN for which configuration of all vpn-sites is needed. :type virtual_wan_name: str :param vpn_sites: List of resource-ids of the vpn-sites for which config is to be downloaded. :type vpn_sites: list[~azure.mgmt.network.v2018_04_01.models.SubResource] :param output_blob_sas_url: The sas-url to download the configurations for vpn-sites :type output_blob_sas_url: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorException<azure.mgmt.network.v2018_04_01.models.ErrorException>` """ raw_result = self._download_initial( resource_group_name=resource_group_name, virtual_wan_name=virtual_wan_name, vpn_sites=vpn_sites, output_blob_sas_url=output_blob_sas_url, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Gives", "the", "sas", "-", "url", "to", "download", "the", "configurations", "for", "vpn", "-", "sites", "in", "a", "resource", "group", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-network/azure/mgmt/network/v2018_04_01/operations/vpn_sites_configuration_operations.py#L83-L133
[ "def", "download", "(", "self", ",", "resource_group_name", ",", "virtual_wan_name", ",", "vpn_sites", "=", "None", ",", "output_blob_sas_url", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_download_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "virtual_wan_name", "=", "virtual_wan_name", ",", "vpn_sites", "=", "vpn_sites", ",", "output_blob_sas_url", "=", "output_blob_sas_url", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.models
Module depends on the API version: * 2015-06-15: :mod:`v2015_06_15.models<azure.mgmt.compute.v2015_06_15.models>` * 2016-03-30: :mod:`v2016_03_30.models<azure.mgmt.compute.v2016_03_30.models>` * 2016-04-30-preview: :mod:`v2016_04_30_preview.models<azure.mgmt.compute.v2016_04_30_preview.models>` * 2017-03-30: :mod:`v2017_03_30.models<azure.mgmt.compute.v2017_03_30.models>` * 2017-09-01: :mod:`v2017_09_01.models<azure.mgmt.compute.v2017_09_01.models>` * 2017-12-01: :mod:`v2017_12_01.models<azure.mgmt.compute.v2017_12_01.models>` * 2018-04-01: :mod:`v2018_04_01.models<azure.mgmt.compute.v2018_04_01.models>` * 2018-06-01: :mod:`v2018_06_01.models<azure.mgmt.compute.v2018_06_01.models>` * 2018-09-30: :mod:`v2018_09_30.models<azure.mgmt.compute.v2018_09_30.models>` * 2018-10-01: :mod:`v2018_10_01.models<azure.mgmt.compute.v2018_10_01.models>` * 2019-03-01: :mod:`v2019_03_01.models<azure.mgmt.compute.v2019_03_01.models>` * 2019-04-01: :mod:`v2019_04_01.models<azure.mgmt.compute.v2019_04_01.models>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-15: :mod:`v2015_06_15.models<azure.mgmt.compute.v2015_06_15.models>` * 2016-03-30: :mod:`v2016_03_30.models<azure.mgmt.compute.v2016_03_30.models>` * 2016-04-30-preview: :mod:`v2016_04_30_preview.models<azure.mgmt.compute.v2016_04_30_preview.models>` * 2017-03-30: :mod:`v2017_03_30.models<azure.mgmt.compute.v2017_03_30.models>` * 2017-09-01: :mod:`v2017_09_01.models<azure.mgmt.compute.v2017_09_01.models>` * 2017-12-01: :mod:`v2017_12_01.models<azure.mgmt.compute.v2017_12_01.models>` * 2018-04-01: :mod:`v2018_04_01.models<azure.mgmt.compute.v2018_04_01.models>` * 2018-06-01: :mod:`v2018_06_01.models<azure.mgmt.compute.v2018_06_01.models>` * 2018-09-30: :mod:`v2018_09_30.models<azure.mgmt.compute.v2018_09_30.models>` * 2018-10-01: :mod:`v2018_10_01.models<azure.mgmt.compute.v2018_10_01.models>` * 2019-03-01: :mod:`v2019_03_01.models<azure.mgmt.compute.v2019_03_01.models>` * 2019-04-01: :mod:`v2019_04_01.models<azure.mgmt.compute.v2019_04_01.models>` """ if api_version == '2015-06-15': from .v2015_06_15 import models return models elif api_version == '2016-03-30': from .v2016_03_30 import models return models elif api_version == '2016-04-30-preview': from .v2016_04_30_preview import models return models elif api_version == '2017-03-30': from .v2017_03_30 import models return models elif api_version == '2017-09-01': from .v2017_09_01 import models return models elif api_version == '2017-12-01': from .v2017_12_01 import models return models elif api_version == '2018-04-01': from .v2018_04_01 import models return models elif api_version == '2018-06-01': from .v2018_06_01 import models return models elif api_version == '2018-09-30': from .v2018_09_30 import models return models elif api_version == '2018-10-01': from .v2018_10_01 import models return models elif api_version == '2019-03-01': from .v2019_03_01 import models return models elif api_version == '2019-04-01': from .v2019_04_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-15: :mod:`v2015_06_15.models<azure.mgmt.compute.v2015_06_15.models>` * 2016-03-30: :mod:`v2016_03_30.models<azure.mgmt.compute.v2016_03_30.models>` * 2016-04-30-preview: :mod:`v2016_04_30_preview.models<azure.mgmt.compute.v2016_04_30_preview.models>` * 2017-03-30: :mod:`v2017_03_30.models<azure.mgmt.compute.v2017_03_30.models>` * 2017-09-01: :mod:`v2017_09_01.models<azure.mgmt.compute.v2017_09_01.models>` * 2017-12-01: :mod:`v2017_12_01.models<azure.mgmt.compute.v2017_12_01.models>` * 2018-04-01: :mod:`v2018_04_01.models<azure.mgmt.compute.v2018_04_01.models>` * 2018-06-01: :mod:`v2018_06_01.models<azure.mgmt.compute.v2018_06_01.models>` * 2018-09-30: :mod:`v2018_09_30.models<azure.mgmt.compute.v2018_09_30.models>` * 2018-10-01: :mod:`v2018_10_01.models<azure.mgmt.compute.v2018_10_01.models>` * 2019-03-01: :mod:`v2019_03_01.models<azure.mgmt.compute.v2019_03_01.models>` * 2019-04-01: :mod:`v2019_04_01.models<azure.mgmt.compute.v2019_04_01.models>` """ if api_version == '2015-06-15': from .v2015_06_15 import models return models elif api_version == '2016-03-30': from .v2016_03_30 import models return models elif api_version == '2016-04-30-preview': from .v2016_04_30_preview import models return models elif api_version == '2017-03-30': from .v2017_03_30 import models return models elif api_version == '2017-09-01': from .v2017_09_01 import models return models elif api_version == '2017-12-01': from .v2017_12_01 import models return models elif api_version == '2018-04-01': from .v2018_04_01 import models return models elif api_version == '2018-06-01': from .v2018_06_01 import models return models elif api_version == '2018-09-30': from .v2018_09_30 import models return models elif api_version == '2018-10-01': from .v2018_10_01 import models return models elif api_version == '2019-03-01': from .v2019_03_01 import models return models elif api_version == '2019-04-01': from .v2019_04_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L111-L163
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2015-06-15'", ":", "from", ".", "v2015_06_15", "import", "models", "return", "models", "elif", "api_version", "==", "'2016-03-30'", ":", "from", ".", "v2016_03_30", "import", "models", "return", "models", "elif", "api_version", "==", "'2016-04-30-preview'", ":", "from", ".", "v2016_04_30_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2017-03-30'", ":", "from", ".", "v2017_03_30", "import", "models", "return", "models", "elif", "api_version", "==", "'2017-09-01'", ":", "from", ".", "v2017_09_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2017-12-01'", ":", "from", ".", "v2017_12_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-04-01'", ":", "from", ".", "v2018_04_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-09-30'", ":", "from", ".", "v2018_09_30", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-10-01'", ":", "from", ".", "v2018_10_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2019-04-01'", ":", "from", ".", "v2019_04_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.disks
Instance depends on the API version: * 2016-04-30-preview: :class:`DisksOperations<azure.mgmt.compute.v2016_04_30_preview.operations.DisksOperations>` * 2017-03-30: :class:`DisksOperations<azure.mgmt.compute.v2017_03_30.operations.DisksOperations>` * 2018-04-01: :class:`DisksOperations<azure.mgmt.compute.v2018_04_01.operations.DisksOperations>` * 2018-06-01: :class:`DisksOperations<azure.mgmt.compute.v2018_06_01.operations.DisksOperations>` * 2018-09-30: :class:`DisksOperations<azure.mgmt.compute.v2018_09_30.operations.DisksOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def disks(self): """Instance depends on the API version: * 2016-04-30-preview: :class:`DisksOperations<azure.mgmt.compute.v2016_04_30_preview.operations.DisksOperations>` * 2017-03-30: :class:`DisksOperations<azure.mgmt.compute.v2017_03_30.operations.DisksOperations>` * 2018-04-01: :class:`DisksOperations<azure.mgmt.compute.v2018_04_01.operations.DisksOperations>` * 2018-06-01: :class:`DisksOperations<azure.mgmt.compute.v2018_06_01.operations.DisksOperations>` * 2018-09-30: :class:`DisksOperations<azure.mgmt.compute.v2018_09_30.operations.DisksOperations>` """ api_version = self._get_api_version('disks') if api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import DisksOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import DisksOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import DisksOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import DisksOperations as OperationClass elif api_version == '2018-09-30': from .v2018_09_30.operations import DisksOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def disks(self): """Instance depends on the API version: * 2016-04-30-preview: :class:`DisksOperations<azure.mgmt.compute.v2016_04_30_preview.operations.DisksOperations>` * 2017-03-30: :class:`DisksOperations<azure.mgmt.compute.v2017_03_30.operations.DisksOperations>` * 2018-04-01: :class:`DisksOperations<azure.mgmt.compute.v2018_04_01.operations.DisksOperations>` * 2018-06-01: :class:`DisksOperations<azure.mgmt.compute.v2018_06_01.operations.DisksOperations>` * 2018-09-30: :class:`DisksOperations<azure.mgmt.compute.v2018_09_30.operations.DisksOperations>` """ api_version = self._get_api_version('disks') if api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import DisksOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import DisksOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import DisksOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import DisksOperations as OperationClass elif api_version == '2018-09-30': from .v2018_09_30.operations import DisksOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L203-L225
[ "def", "disks", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'disks'", ")", "if", "api_version", "==", "'2016-04-30-preview'", ":", "from", ".", "v2016_04_30_preview", ".", "operations", "import", "DisksOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-03-30'", ":", "from", ".", "v2017_03_30", ".", "operations", "import", "DisksOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-04-01'", ":", "from", ".", "v2018_04_01", ".", "operations", "import", "DisksOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "DisksOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-09-30'", ":", "from", ".", "v2018_09_30", ".", "operations", "import", "DisksOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.galleries
Instance depends on the API version: * 2018-06-01: :class:`GalleriesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleriesOperations>` * 2019-03-01: :class:`GalleriesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleriesOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def galleries(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleriesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleriesOperations>` * 2019-03-01: :class:`GalleriesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleriesOperations>` """ api_version = self._get_api_version('galleries') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleriesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleriesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def galleries(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleriesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleriesOperations>` * 2019-03-01: :class:`GalleriesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleriesOperations>` """ api_version = self._get_api_version('galleries') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleriesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleriesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L228-L241
[ "def", "galleries", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'galleries'", ")", "if", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "GalleriesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "GalleriesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.gallery_image_versions
Instance depends on the API version: * 2018-06-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImageVersionsOperations>` * 2019-03-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImageVersionsOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def gallery_image_versions(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImageVersionsOperations>` * 2019-03-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImageVersionsOperations>` """ api_version = self._get_api_version('gallery_image_versions') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleryImageVersionsOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleryImageVersionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def gallery_image_versions(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImageVersionsOperations>` * 2019-03-01: :class:`GalleryImageVersionsOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImageVersionsOperations>` """ api_version = self._get_api_version('gallery_image_versions') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleryImageVersionsOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleryImageVersionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L244-L257
[ "def", "gallery_image_versions", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'gallery_image_versions'", ")", "if", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "GalleryImageVersionsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "GalleryImageVersionsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.gallery_images
Instance depends on the API version: * 2018-06-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImagesOperations>` * 2019-03-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImagesOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def gallery_images(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImagesOperations>` * 2019-03-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImagesOperations>` """ api_version = self._get_api_version('gallery_images') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleryImagesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleryImagesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def gallery_images(self): """Instance depends on the API version: * 2018-06-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2018_06_01.operations.GalleryImagesOperations>` * 2019-03-01: :class:`GalleryImagesOperations<azure.mgmt.compute.v2019_03_01.operations.GalleryImagesOperations>` """ api_version = self._get_api_version('gallery_images') if api_version == '2018-06-01': from .v2018_06_01.operations import GalleryImagesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import GalleryImagesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L260-L273
[ "def", "gallery_images", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'gallery_images'", ")", "if", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "GalleryImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "GalleryImagesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.images
Instance depends on the API version: * 2016-04-30-preview: :class:`ImagesOperations<azure.mgmt.compute.v2016_04_30_preview.operations.ImagesOperations>` * 2017-03-30: :class:`ImagesOperations<azure.mgmt.compute.v2017_03_30.operations.ImagesOperations>` * 2017-12-01: :class:`ImagesOperations<azure.mgmt.compute.v2017_12_01.operations.ImagesOperations>` * 2018-04-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_04_01.operations.ImagesOperations>` * 2018-06-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_06_01.operations.ImagesOperations>` * 2018-10-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_10_01.operations.ImagesOperations>` * 2019-03-01: :class:`ImagesOperations<azure.mgmt.compute.v2019_03_01.operations.ImagesOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def images(self): """Instance depends on the API version: * 2016-04-30-preview: :class:`ImagesOperations<azure.mgmt.compute.v2016_04_30_preview.operations.ImagesOperations>` * 2017-03-30: :class:`ImagesOperations<azure.mgmt.compute.v2017_03_30.operations.ImagesOperations>` * 2017-12-01: :class:`ImagesOperations<azure.mgmt.compute.v2017_12_01.operations.ImagesOperations>` * 2018-04-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_04_01.operations.ImagesOperations>` * 2018-06-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_06_01.operations.ImagesOperations>` * 2018-10-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_10_01.operations.ImagesOperations>` * 2019-03-01: :class:`ImagesOperations<azure.mgmt.compute.v2019_03_01.operations.ImagesOperations>` """ api_version = self._get_api_version('images') if api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import ImagesOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import ImagesOperations as OperationClass elif api_version == '2017-12-01': from .v2017_12_01.operations import ImagesOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import ImagesOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import ImagesOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import ImagesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import ImagesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def images(self): """Instance depends on the API version: * 2016-04-30-preview: :class:`ImagesOperations<azure.mgmt.compute.v2016_04_30_preview.operations.ImagesOperations>` * 2017-03-30: :class:`ImagesOperations<azure.mgmt.compute.v2017_03_30.operations.ImagesOperations>` * 2017-12-01: :class:`ImagesOperations<azure.mgmt.compute.v2017_12_01.operations.ImagesOperations>` * 2018-04-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_04_01.operations.ImagesOperations>` * 2018-06-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_06_01.operations.ImagesOperations>` * 2018-10-01: :class:`ImagesOperations<azure.mgmt.compute.v2018_10_01.operations.ImagesOperations>` * 2019-03-01: :class:`ImagesOperations<azure.mgmt.compute.v2019_03_01.operations.ImagesOperations>` """ api_version = self._get_api_version('images') if api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import ImagesOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import ImagesOperations as OperationClass elif api_version == '2017-12-01': from .v2017_12_01.operations import ImagesOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import ImagesOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import ImagesOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import ImagesOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import ImagesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L276-L304
[ "def", "images", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'images'", ")", "if", "api_version", "==", "'2016-04-30-preview'", ":", "from", ".", "v2016_04_30_preview", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-03-30'", ":", "from", ".", "v2017_03_30", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-12-01'", ":", "from", ".", "v2017_12_01", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-04-01'", ":", "from", ".", "v2018_04_01", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-10-01'", ":", "from", ".", "v2018_10_01", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "ImagesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.log_analytics
Instance depends on the API version: * 2017-12-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2017_12_01.operations.LogAnalyticsOperations>` * 2018-04-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_04_01.operations.LogAnalyticsOperations>` * 2018-06-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_06_01.operations.LogAnalyticsOperations>` * 2018-10-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_10_01.operations.LogAnalyticsOperations>` * 2019-03-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2019_03_01.operations.LogAnalyticsOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def log_analytics(self): """Instance depends on the API version: * 2017-12-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2017_12_01.operations.LogAnalyticsOperations>` * 2018-04-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_04_01.operations.LogAnalyticsOperations>` * 2018-06-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_06_01.operations.LogAnalyticsOperations>` * 2018-10-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_10_01.operations.LogAnalyticsOperations>` * 2019-03-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2019_03_01.operations.LogAnalyticsOperations>` """ api_version = self._get_api_version('log_analytics') if api_version == '2017-12-01': from .v2017_12_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import LogAnalyticsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def log_analytics(self): """Instance depends on the API version: * 2017-12-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2017_12_01.operations.LogAnalyticsOperations>` * 2018-04-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_04_01.operations.LogAnalyticsOperations>` * 2018-06-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_06_01.operations.LogAnalyticsOperations>` * 2018-10-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2018_10_01.operations.LogAnalyticsOperations>` * 2019-03-01: :class:`LogAnalyticsOperations<azure.mgmt.compute.v2019_03_01.operations.LogAnalyticsOperations>` """ api_version = self._get_api_version('log_analytics') if api_version == '2017-12-01': from .v2017_12_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import LogAnalyticsOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import LogAnalyticsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L307-L329
[ "def", "log_analytics", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'log_analytics'", ")", "if", "api_version", "==", "'2017-12-01'", ":", "from", ".", "v2017_12_01", ".", "operations", "import", "LogAnalyticsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-04-01'", ":", "from", ".", "v2018_04_01", ".", "operations", "import", "LogAnalyticsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "LogAnalyticsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-10-01'", ":", "from", ".", "v2018_10_01", ".", "operations", "import", "LogAnalyticsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "LogAnalyticsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.resource_skus
Instance depends on the API version: * 2017-03-30: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_03_30.operations.ResourceSkusOperations>` * 2017-09-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_09_01.operations.ResourceSkusOperations>` * 2019-04-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2019_04_01.operations.ResourceSkusOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def resource_skus(self): """Instance depends on the API version: * 2017-03-30: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_03_30.operations.ResourceSkusOperations>` * 2017-09-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_09_01.operations.ResourceSkusOperations>` * 2019-04-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2019_04_01.operations.ResourceSkusOperations>` """ api_version = self._get_api_version('resource_skus') if api_version == '2017-03-30': from .v2017_03_30.operations import ResourceSkusOperations as OperationClass elif api_version == '2017-09-01': from .v2017_09_01.operations import ResourceSkusOperations as OperationClass elif api_version == '2019-04-01': from .v2019_04_01.operations import ResourceSkusOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def resource_skus(self): """Instance depends on the API version: * 2017-03-30: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_03_30.operations.ResourceSkusOperations>` * 2017-09-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2017_09_01.operations.ResourceSkusOperations>` * 2019-04-01: :class:`ResourceSkusOperations<azure.mgmt.compute.v2019_04_01.operations.ResourceSkusOperations>` """ api_version = self._get_api_version('resource_skus') if api_version == '2017-03-30': from .v2017_03_30.operations import ResourceSkusOperations as OperationClass elif api_version == '2017-09-01': from .v2017_09_01.operations import ResourceSkusOperations as OperationClass elif api_version == '2019-04-01': from .v2019_04_01.operations import ResourceSkusOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L379-L395
[ "def", "resource_skus", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'resource_skus'", ")", "if", "api_version", "==", "'2017-03-30'", ":", "from", ".", "v2017_03_30", ".", "operations", "import", "ResourceSkusOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-09-01'", ":", "from", ".", "v2017_09_01", ".", "operations", "import", "ResourceSkusOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-04-01'", ":", "from", ".", "v2019_04_01", ".", "operations", "import", "ResourceSkusOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ComputeManagementClient.usage
Instance depends on the API version: * 2015-06-15: :class:`UsageOperations<azure.mgmt.compute.v2015_06_15.operations.UsageOperations>` * 2016-03-30: :class:`UsageOperations<azure.mgmt.compute.v2016_03_30.operations.UsageOperations>` * 2016-04-30-preview: :class:`UsageOperations<azure.mgmt.compute.v2016_04_30_preview.operations.UsageOperations>` * 2017-03-30: :class:`UsageOperations<azure.mgmt.compute.v2017_03_30.operations.UsageOperations>` * 2017-12-01: :class:`UsageOperations<azure.mgmt.compute.v2017_12_01.operations.UsageOperations>` * 2018-04-01: :class:`UsageOperations<azure.mgmt.compute.v2018_04_01.operations.UsageOperations>` * 2018-06-01: :class:`UsageOperations<azure.mgmt.compute.v2018_06_01.operations.UsageOperations>` * 2018-10-01: :class:`UsageOperations<azure.mgmt.compute.v2018_10_01.operations.UsageOperations>` * 2019-03-01: :class:`UsageOperations<azure.mgmt.compute.v2019_03_01.operations.UsageOperations>`
azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py
def usage(self): """Instance depends on the API version: * 2015-06-15: :class:`UsageOperations<azure.mgmt.compute.v2015_06_15.operations.UsageOperations>` * 2016-03-30: :class:`UsageOperations<azure.mgmt.compute.v2016_03_30.operations.UsageOperations>` * 2016-04-30-preview: :class:`UsageOperations<azure.mgmt.compute.v2016_04_30_preview.operations.UsageOperations>` * 2017-03-30: :class:`UsageOperations<azure.mgmt.compute.v2017_03_30.operations.UsageOperations>` * 2017-12-01: :class:`UsageOperations<azure.mgmt.compute.v2017_12_01.operations.UsageOperations>` * 2018-04-01: :class:`UsageOperations<azure.mgmt.compute.v2018_04_01.operations.UsageOperations>` * 2018-06-01: :class:`UsageOperations<azure.mgmt.compute.v2018_06_01.operations.UsageOperations>` * 2018-10-01: :class:`UsageOperations<azure.mgmt.compute.v2018_10_01.operations.UsageOperations>` * 2019-03-01: :class:`UsageOperations<azure.mgmt.compute.v2019_03_01.operations.UsageOperations>` """ api_version = self._get_api_version('usage') if api_version == '2015-06-15': from .v2015_06_15.operations import UsageOperations as OperationClass elif api_version == '2016-03-30': from .v2016_03_30.operations import UsageOperations as OperationClass elif api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import UsageOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import UsageOperations as OperationClass elif api_version == '2017-12-01': from .v2017_12_01.operations import UsageOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import UsageOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import UsageOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import UsageOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import UsageOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def usage(self): """Instance depends on the API version: * 2015-06-15: :class:`UsageOperations<azure.mgmt.compute.v2015_06_15.operations.UsageOperations>` * 2016-03-30: :class:`UsageOperations<azure.mgmt.compute.v2016_03_30.operations.UsageOperations>` * 2016-04-30-preview: :class:`UsageOperations<azure.mgmt.compute.v2016_04_30_preview.operations.UsageOperations>` * 2017-03-30: :class:`UsageOperations<azure.mgmt.compute.v2017_03_30.operations.UsageOperations>` * 2017-12-01: :class:`UsageOperations<azure.mgmt.compute.v2017_12_01.operations.UsageOperations>` * 2018-04-01: :class:`UsageOperations<azure.mgmt.compute.v2018_04_01.operations.UsageOperations>` * 2018-06-01: :class:`UsageOperations<azure.mgmt.compute.v2018_06_01.operations.UsageOperations>` * 2018-10-01: :class:`UsageOperations<azure.mgmt.compute.v2018_10_01.operations.UsageOperations>` * 2019-03-01: :class:`UsageOperations<azure.mgmt.compute.v2019_03_01.operations.UsageOperations>` """ api_version = self._get_api_version('usage') if api_version == '2015-06-15': from .v2015_06_15.operations import UsageOperations as OperationClass elif api_version == '2016-03-30': from .v2016_03_30.operations import UsageOperations as OperationClass elif api_version == '2016-04-30-preview': from .v2016_04_30_preview.operations import UsageOperations as OperationClass elif api_version == '2017-03-30': from .v2017_03_30.operations import UsageOperations as OperationClass elif api_version == '2017-12-01': from .v2017_12_01.operations import UsageOperations as OperationClass elif api_version == '2018-04-01': from .v2018_04_01.operations import UsageOperations as OperationClass elif api_version == '2018-06-01': from .v2018_06_01.operations import UsageOperations as OperationClass elif api_version == '2018-10-01': from .v2018_10_01.operations import UsageOperations as OperationClass elif api_version == '2019-03-01': from .v2019_03_01.operations import UsageOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py#L423-L457
[ "def", "usage", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'usage'", ")", "if", "api_version", "==", "'2015-06-15'", ":", "from", ".", "v2015_06_15", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2016-03-30'", ":", "from", ".", "v2016_03_30", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2016-04-30-preview'", ":", "from", ".", "v2016_04_30_preview", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-03-30'", ":", "from", ".", "v2017_03_30", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-12-01'", ":", "from", ".", "v2017_12_01", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-04-01'", ":", "from", ".", "v2018_04_01", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-06-01'", ":", "from", ".", "v2018_06_01", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-10-01'", ":", "from", ".", "v2018_10_01", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "elif", "api_version", "==", "'2019-03-01'", ":", "from", ".", "v2019_03_01", ".", "operations", "import", "UsageOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
guess_service_info_from_path
Guess Python Autorest options based on the spec path. Expected path: specification/compute/resource-manager/readme.md
scripts/build_sdk.py
def guess_service_info_from_path(spec_path): """Guess Python Autorest options based on the spec path. Expected path: specification/compute/resource-manager/readme.md """ spec_path = spec_path.lower() spec_path = spec_path[spec_path.index("specification"):] # Might raise and it's ok split_spec_path = spec_path.split("/") rp_name = split_spec_path[1] is_arm = split_spec_path[2] == "resource-manager" return { "rp_name": rp_name, "is_arm": is_arm }
def guess_service_info_from_path(spec_path): """Guess Python Autorest options based on the spec path. Expected path: specification/compute/resource-manager/readme.md """ spec_path = spec_path.lower() spec_path = spec_path[spec_path.index("specification"):] # Might raise and it's ok split_spec_path = spec_path.split("/") rp_name = split_spec_path[1] is_arm = split_spec_path[2] == "resource-manager" return { "rp_name": rp_name, "is_arm": is_arm }
[ "Guess", "Python", "Autorest", "options", "based", "on", "the", "spec", "path", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/scripts/build_sdk.py#L19-L35
[ "def", "guess_service_info_from_path", "(", "spec_path", ")", ":", "spec_path", "=", "spec_path", ".", "lower", "(", ")", "spec_path", "=", "spec_path", "[", "spec_path", ".", "index", "(", "\"specification\"", ")", ":", "]", "# Might raise and it's ok", "split_spec_path", "=", "spec_path", ".", "split", "(", "\"/\"", ")", "rp_name", "=", "split_spec_path", "[", "1", "]", "is_arm", "=", "split_spec_path", "[", "2", "]", "==", "\"resource-manager\"", "return", "{", "\"rp_name\"", ":", "rp_name", ",", "\"is_arm\"", ":", "is_arm", "}" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
BaseHandler.open
Open handler connection and authenticate session. If the handler is already open, this operation will do nothing. A handler opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe.
azure-servicebus/azure/servicebus/base_handler.py
def open(self): """Open handler connection and authenticate session. If the handler is already open, this operation will do nothing. A handler opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. """ if self.running: return self.running = True try: self._handler.open(connection=self.connection) while not self._handler.client_ready(): time.sleep(0.05) except Exception as e: # pylint: disable=broad-except try: self._handle_exception(e) except: self.running = False raise
def open(self): """Open handler connection and authenticate session. If the handler is already open, this operation will do nothing. A handler opened with this method must be explicitly closed. It is recommended to open a handler within a context manager as opposed to calling the method directly. .. note:: This operation is not thread-safe. """ if self.running: return self.running = True try: self._handler.open(connection=self.connection) while not self._handler.client_ready(): time.sleep(0.05) except Exception as e: # pylint: disable=broad-except try: self._handle_exception(e) except: self.running = False raise
[ "Open", "handler", "connection", "and", "authenticate", "session", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/base_handler.py#L139-L162
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "running", ":", "return", "self", ".", "running", "=", "True", "try", ":", "self", ".", "_handler", ".", "open", "(", "connection", "=", "self", ".", "connection", ")", "while", "not", "self", ".", "_handler", ".", "client_ready", "(", ")", ":", "time", ".", "sleep", "(", "0.05", ")", "except", "Exception", "as", "e", ":", "# pylint: disable=broad-except", "try", ":", "self", ".", "_handle_exception", "(", "e", ")", "except", ":", "self", ".", "running", "=", "False", "raise" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
PowerShellOperations.update_command
Updates a running PowerShell command with more data. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param pssession: The PowerShell sessionId from the user. :type pssession: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns PowerShellCommandResults or ClientRawResponse<PowerShellCommandResults> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.PowerShellCommandResults] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.PowerShellCommandResults]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>`
azure-mgmt-servermanager/azure/mgmt/servermanager/operations/power_shell_operations.py
def update_command( self, resource_group_name, node_name, session, pssession, custom_headers=None, raw=False, polling=True, **operation_config): """Updates a running PowerShell command with more data. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param pssession: The PowerShell sessionId from the user. :type pssession: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns PowerShellCommandResults or ClientRawResponse<PowerShellCommandResults> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.PowerShellCommandResults] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.PowerShellCommandResults]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>` """ raw_result = self._update_command_initial( resource_group_name=resource_group_name, node_name=node_name, session=session, pssession=pssession, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('PowerShellCommandResults', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def update_command( self, resource_group_name, node_name, session, pssession, custom_headers=None, raw=False, polling=True, **operation_config): """Updates a running PowerShell command with more data. :param resource_group_name: The resource group name uniquely identifies the resource group within the user subscriptionId. :type resource_group_name: str :param node_name: The node name (256 characters maximum). :type node_name: str :param session: The sessionId from the user. :type session: str :param pssession: The PowerShell sessionId from the user. :type pssession: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns PowerShellCommandResults or ClientRawResponse<PowerShellCommandResults> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.servermanager.models.PowerShellCommandResults] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.servermanager.models.PowerShellCommandResults]] :raises: :class:`ErrorException<azure.mgmt.servermanager.models.ErrorException>` """ raw_result = self._update_command_initial( resource_group_name=resource_group_name, node_name=node_name, session=session, pssession=pssession, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('PowerShellCommandResults', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Updates", "a", "running", "PowerShell", "command", "with", "more", "data", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-servermanager/azure/mgmt/servermanager/operations/power_shell_operations.py#L328-L381
[ "def", "update_command", "(", "self", ",", "resource_group_name", ",", "node_name", ",", "session", ",", "pssession", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_update_command_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "node_name", "=", "node_name", ",", "session", "=", "session", ",", "pssession", "=", "pssession", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'PowerShellCommandResults'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ApplicationDefinitionsOperations.delete_by_id
Deletes the managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>`
azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/application_definitions_operations.py
def delete_by_id( self, application_definition_id, custom_headers=None, raw=False, polling=True, **operation_config): """Deletes the managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>` """ raw_result = self._delete_by_id_initial( application_definition_id=application_definition_id, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def delete_by_id( self, application_definition_id, custom_headers=None, raw=False, polling=True, **operation_config): """Deletes the managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>` """ raw_result = self._delete_by_id_initial( application_definition_id=application_definition_id, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Deletes", "the", "managed", "application", "definition", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/application_definitions_operations.py#L452-L491
[ "def", "delete_by_id", "(", "self", ",", "application_definition_id", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_delete_by_id_initial", "(", "application_definition_id", "=", "application_definition_id", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ApplicationDefinitionsOperations.create_or_update_by_id
Creates a new managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param parameters: Parameters supplied to the create or update a managed application definition. :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns ApplicationDefinition or ClientRawResponse<ApplicationDefinition> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>`
azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/application_definitions_operations.py
def create_or_update_by_id( self, application_definition_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config): """Creates a new managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param parameters: Parameters supplied to the create or update a managed application definition. :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns ApplicationDefinition or ClientRawResponse<ApplicationDefinition> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>` """ raw_result = self._create_or_update_by_id_initial( application_definition_id=application_definition_id, parameters=parameters, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('ApplicationDefinition', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def create_or_update_by_id( self, application_definition_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config): """Creates a new managed application definition. :param application_definition_id: The fully qualified ID of the managed application definition, including the managed application name and the managed application definition resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} :type application_definition_id: str :param parameters: Parameters supplied to the create or update a managed application definition. :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns ApplicationDefinition or ClientRawResponse<ApplicationDefinition> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]] :raises: :class:`ErrorResponseException<azure.mgmt.resource.managedapplications.models.ErrorResponseException>` """ raw_result = self._create_or_update_by_id_initial( application_definition_id=application_definition_id, parameters=parameters, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): deserialized = self._deserialize('ApplicationDefinition', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Creates", "a", "new", "managed", "application", "definition", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/application_definitions_operations.py#L542-L592
[ "def", "create_or_update_by_id", "(", "self", ",", "application_definition_id", ",", "parameters", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_create_or_update_by_id_initial", "(", "application_definition_id", "=", "application_definition_id", ",", "parameters", "=", "parameters", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'ApplicationDefinition'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DnsManagementClient.models
Module depends on the API version: * 2016-04-01: :mod:`v2016_04_01.models<azure.mgmt.dns.v2016_04_01.models>` * 2018-03-01-preview: :mod:`v2018_03_01_preview.models<azure.mgmt.dns.v2018_03_01_preview.models>` * 2018-05-01: :mod:`v2018_05_01.models<azure.mgmt.dns.v2018_05_01.models>`
azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-04-01: :mod:`v2016_04_01.models<azure.mgmt.dns.v2016_04_01.models>` * 2018-03-01-preview: :mod:`v2018_03_01_preview.models<azure.mgmt.dns.v2018_03_01_preview.models>` * 2018-05-01: :mod:`v2018_05_01.models<azure.mgmt.dns.v2018_05_01.models>` """ if api_version == '2016-04-01': from .v2016_04_01 import models return models elif api_version == '2018-03-01-preview': from .v2018_03_01_preview import models return models elif api_version == '2018-05-01': from .v2018_05_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-04-01: :mod:`v2016_04_01.models<azure.mgmt.dns.v2016_04_01.models>` * 2018-03-01-preview: :mod:`v2018_03_01_preview.models<azure.mgmt.dns.v2018_03_01_preview.models>` * 2018-05-01: :mod:`v2018_05_01.models<azure.mgmt.dns.v2018_05_01.models>` """ if api_version == '2016-04-01': from .v2016_04_01 import models return models elif api_version == '2018-03-01-preview': from .v2018_03_01_preview import models return models elif api_version == '2018-05-01': from .v2018_05_01 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py#L104-L120
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2016-04-01'", ":", "from", ".", "v2016_04_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-03-01-preview'", ":", "from", ".", "v2018_03_01_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-05-01'", ":", "from", ".", "v2018_05_01", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DnsManagementClient.dns_resource_reference
Instance depends on the API version: * 2018-05-01: :class:`DnsResourceReferenceOperations<azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations>`
azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py
def dns_resource_reference(self): """Instance depends on the API version: * 2018-05-01: :class:`DnsResourceReferenceOperations<azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations>` """ api_version = self._get_api_version('dns_resource_reference') if api_version == '2018-05-01': from .v2018_05_01.operations import DnsResourceReferenceOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def dns_resource_reference(self): """Instance depends on the API version: * 2018-05-01: :class:`DnsResourceReferenceOperations<azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations>` """ api_version = self._get_api_version('dns_resource_reference') if api_version == '2018-05-01': from .v2018_05_01.operations import DnsResourceReferenceOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py#L123-L133
[ "def", "dns_resource_reference", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'dns_resource_reference'", ")", "if", "api_version", "==", "'2018-05-01'", ":", "from", ".", "v2018_05_01", ".", "operations", "import", "DnsResourceReferenceOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DnsManagementClient.record_sets
Instance depends on the API version: * 2016-04-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations>` * 2018-03-01-preview: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations>` * 2018-05-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_05_01.operations.RecordSetsOperations>`
azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py
def record_sets(self): """Instance depends on the API version: * 2016-04-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations>` * 2018-03-01-preview: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations>` * 2018-05-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_05_01.operations.RecordSetsOperations>` """ api_version = self._get_api_version('record_sets') if api_version == '2016-04-01': from .v2016_04_01.operations import RecordSetsOperations as OperationClass elif api_version == '2018-03-01-preview': from .v2018_03_01_preview.operations import RecordSetsOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import RecordSetsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def record_sets(self): """Instance depends on the API version: * 2016-04-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations>` * 2018-03-01-preview: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations>` * 2018-05-01: :class:`RecordSetsOperations<azure.mgmt.dns.v2018_05_01.operations.RecordSetsOperations>` """ api_version = self._get_api_version('record_sets') if api_version == '2016-04-01': from .v2016_04_01.operations import RecordSetsOperations as OperationClass elif api_version == '2018-03-01-preview': from .v2018_03_01_preview.operations import RecordSetsOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import RecordSetsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py#L136-L152
[ "def", "record_sets", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'record_sets'", ")", "if", "api_version", "==", "'2016-04-01'", ":", "from", ".", "v2016_04_01", ".", "operations", "import", "RecordSetsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-03-01-preview'", ":", "from", ".", "v2018_03_01_preview", ".", "operations", "import", "RecordSetsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-05-01'", ":", "from", ".", "v2018_05_01", ".", "operations", "import", "RecordSetsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
DnsManagementClient.zones
Instance depends on the API version: * 2016-04-01: :class:`ZonesOperations<azure.mgmt.dns.v2016_04_01.operations.ZonesOperations>` * 2018-03-01-preview: :class:`ZonesOperations<azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations>` * 2018-05-01: :class:`ZonesOperations<azure.mgmt.dns.v2018_05_01.operations.ZonesOperations>`
azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py
def zones(self): """Instance depends on the API version: * 2016-04-01: :class:`ZonesOperations<azure.mgmt.dns.v2016_04_01.operations.ZonesOperations>` * 2018-03-01-preview: :class:`ZonesOperations<azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations>` * 2018-05-01: :class:`ZonesOperations<azure.mgmt.dns.v2018_05_01.operations.ZonesOperations>` """ api_version = self._get_api_version('zones') if api_version == '2016-04-01': from .v2016_04_01.operations import ZonesOperations as OperationClass elif api_version == '2018-03-01-preview': from .v2018_03_01_preview.operations import ZonesOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import ZonesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def zones(self): """Instance depends on the API version: * 2016-04-01: :class:`ZonesOperations<azure.mgmt.dns.v2016_04_01.operations.ZonesOperations>` * 2018-03-01-preview: :class:`ZonesOperations<azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations>` * 2018-05-01: :class:`ZonesOperations<azure.mgmt.dns.v2018_05_01.operations.ZonesOperations>` """ api_version = self._get_api_version('zones') if api_version == '2016-04-01': from .v2016_04_01.operations import ZonesOperations as OperationClass elif api_version == '2018-03-01-preview': from .v2018_03_01_preview.operations import ZonesOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import ZonesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-dns/azure/mgmt/dns/dns_management_client.py#L155-L171
[ "def", "zones", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'zones'", ")", "if", "api_version", "==", "'2016-04-01'", ":", "from", ".", "v2016_04_01", ".", "operations", "import", "ZonesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-03-01-preview'", ":", "from", ".", "v2018_03_01_preview", ".", "operations", "import", "ZonesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-05-01'", ":", "from", ".", "v2018_05_01", ".", "operations", "import", "ZonesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
KeyVaultManagementClient.models
Module depends on the API version: * 2016-10-01: :mod:`v2016_10_01.models<azure.mgmt.keyvault.v2016_10_01.models>` * 2018-02-14: :mod:`v2018_02_14.models<azure.mgmt.keyvault.v2018_02_14.models>`
azure-mgmt-keyvault/azure/mgmt/keyvault/key_vault_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-10-01: :mod:`v2016_10_01.models<azure.mgmt.keyvault.v2016_10_01.models>` * 2018-02-14: :mod:`v2018_02_14.models<azure.mgmt.keyvault.v2018_02_14.models>` """ if api_version == '2016-10-01': from .v2016_10_01 import models return models elif api_version == '2018-02-14': from .v2018_02_14 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2016-10-01: :mod:`v2016_10_01.models<azure.mgmt.keyvault.v2016_10_01.models>` * 2018-02-14: :mod:`v2018_02_14.models<azure.mgmt.keyvault.v2018_02_14.models>` """ if api_version == '2016-10-01': from .v2016_10_01 import models return models elif api_version == '2018-02-14': from .v2018_02_14 import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-keyvault/azure/mgmt/keyvault/key_vault_management_client.py#L100-L112
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2016-10-01'", ":", "from", ".", "v2016_10_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-02-14'", ":", "from", ".", "v2018_02_14", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SpellCheckAPI.spell_checker
The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. :param text: The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. :type text: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. :type accept_language: str :param pragma: By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). :type pragma: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are strongly encouraged to always specify this header. The user-agent should be the same string that any commonly used browser would send. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. :type location: str :param action_type: A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' :type action_type: str or ~azure.cognitiveservices.language.spellcheck.models.ActionType :param app_name: The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. :type app_name: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param client_machine_name: A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type client_machine_name: str :param doc_id: A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type doc_id: str :param market: The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. :type market: str :param session_id: A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections :type session_id: str :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: str :param user_id: A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type user_id: str :param mode: The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' :type mode: str :param pre_context_text: A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type pre_context_text: str :param post_context_text: A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type post_context_text: 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: SpellCheck or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.spellcheck.models.SpellCheck or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.spellcheck.models.ErrorResponseException>`
azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_api.py
def spell_checker( self, text, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, action_type=None, app_name=None, country_code=None, client_machine_name=None, doc_id=None, market=None, session_id=None, set_lang=None, user_id=None, mode=None, pre_context_text=None, post_context_text=None, custom_headers=None, raw=False, **operation_config): """The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. :param text: The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. :type text: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. :type accept_language: str :param pragma: By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). :type pragma: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are strongly encouraged to always specify this header. The user-agent should be the same string that any commonly used browser would send. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. :type location: str :param action_type: A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' :type action_type: str or ~azure.cognitiveservices.language.spellcheck.models.ActionType :param app_name: The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. :type app_name: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param client_machine_name: A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type client_machine_name: str :param doc_id: A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type doc_id: str :param market: The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. :type market: str :param session_id: A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections :type session_id: str :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: str :param user_id: A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type user_id: str :param mode: The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' :type mode: str :param pre_context_text: A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type pre_context_text: str :param post_context_text: A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type post_context_text: 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: SpellCheck or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.spellcheck.models.SpellCheck or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.spellcheck.models.ErrorResponseException>` """ x_bing_apis_sdk = "true" # Construct URL url = self.spell_checker.metadata['url'] # Construct parameters query_parameters = {} if action_type is not None: query_parameters['ActionType'] = self._serialize.query("action_type", action_type, 'str') if app_name is not None: query_parameters['AppName'] = self._serialize.query("app_name", app_name, 'str') if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if client_machine_name is not None: query_parameters['ClientMachineName'] = self._serialize.query("client_machine_name", client_machine_name, 'str') if doc_id is not None: query_parameters['DocId'] = self._serialize.query("doc_id", doc_id, 'str') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') if session_id is not None: query_parameters['SessionId'] = self._serialize.query("session_id", session_id, 'str') if set_lang is not None: query_parameters['SetLang'] = self._serialize.query("set_lang", set_lang, 'str') if user_id is not None: query_parameters['UserId'] = self._serialize.query("user_id", user_id, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("x_bing_apis_sdk", x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if pragma is not None: header_parameters['Pragma'] = self._serialize.header("pragma", pragma, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, 'str') # Construct form data form_data_content = { 'Text': text, 'Mode': mode, 'PreContextText': pre_context_text, 'PostContextText': post_context_text, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SpellCheck', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def spell_checker( self, text, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, action_type=None, app_name=None, country_code=None, client_machine_name=None, doc_id=None, market=None, session_id=None, set_lang=None, user_id=None, mode=None, pre_context_text=None, post_context_text=None, custom_headers=None, raw=False, **operation_config): """The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. :param text: The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. :type text: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. :type accept_language: str :param pragma: By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). :type pragma: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are strongly encouraged to always specify this header. The user-agent should be the same string that any commonly used browser would send. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. :type location: str :param action_type: A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' :type action_type: str or ~azure.cognitiveservices.language.spellcheck.models.ActionType :param app_name: The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. :type app_name: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param client_machine_name: A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type client_machine_name: str :param doc_id: A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type doc_id: str :param market: The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. :type market: str :param session_id: A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections :type session_id: str :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: str :param user_id: A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. :type user_id: str :param mode: The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' :type mode: str :param pre_context_text: A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type pre_context_text: str :param post_context_text: A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. :type post_context_text: 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: SpellCheck or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.spellcheck.models.SpellCheck or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.spellcheck.models.ErrorResponseException>` """ x_bing_apis_sdk = "true" # Construct URL url = self.spell_checker.metadata['url'] # Construct parameters query_parameters = {} if action_type is not None: query_parameters['ActionType'] = self._serialize.query("action_type", action_type, 'str') if app_name is not None: query_parameters['AppName'] = self._serialize.query("app_name", app_name, 'str') if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if client_machine_name is not None: query_parameters['ClientMachineName'] = self._serialize.query("client_machine_name", client_machine_name, 'str') if doc_id is not None: query_parameters['DocId'] = self._serialize.query("doc_id", doc_id, 'str') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') if session_id is not None: query_parameters['SessionId'] = self._serialize.query("session_id", session_id, 'str') if set_lang is not None: query_parameters['SetLang'] = self._serialize.query("set_lang", set_lang, 'str') if user_id is not None: query_parameters['UserId'] = self._serialize.query("user_id", user_id, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("x_bing_apis_sdk", x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if pragma is not None: header_parameters['Pragma'] = self._serialize.header("pragma", pragma, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, 'str') # Construct form data form_data_content = { 'Text': text, 'Mode': mode, 'PreContextText': pre_context_text, 'PostContextText': post_context_text, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_content, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SpellCheck', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "The", "Bing", "Spell", "Check", "API", "lets", "you", "perform", "contextual", "grammar", "and", "spell", "checking", ".", "Bing", "has", "developed", "a", "web", "-", "based", "spell", "-", "checker", "that", "leverages", "machine", "learning", "and", "statistical", "machine", "translation", "to", "dynamically", "train", "a", "constantly", "evolving", "and", "highly", "contextual", "algorithm", ".", "The", "spell", "-", "checker", "is", "based", "on", "a", "massive", "corpus", "of", "web", "searches", "and", "documents", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-language-spellcheck/azure/cognitiveservices/language/spellcheck/spell_check_api.py#L69-L371
[ "def", "spell_checker", "(", "self", ",", "text", ",", "accept_language", "=", "None", ",", "pragma", "=", "None", ",", "user_agent", "=", "None", ",", "client_id", "=", "None", ",", "client_ip", "=", "None", ",", "location", "=", "None", ",", "action_type", "=", "None", ",", "app_name", "=", "None", ",", "country_code", "=", "None", ",", "client_machine_name", "=", "None", ",", "doc_id", "=", "None", ",", "market", "=", "None", ",", "session_id", "=", "None", ",", "set_lang", "=", "None", ",", "user_id", "=", "None", ",", "mode", "=", "None", ",", "pre_context_text", "=", "None", ",", "post_context_text", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "x_bing_apis_sdk", "=", "\"true\"", "# Construct URL", "url", "=", "self", ".", "spell_checker", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "action_type", "is", "not", "None", ":", "query_parameters", "[", "'ActionType'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"action_type\"", ",", "action_type", ",", "'str'", ")", "if", "app_name", "is", "not", "None", ":", "query_parameters", "[", "'AppName'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"app_name\"", ",", "app_name", ",", "'str'", ")", "if", "country_code", "is", "not", "None", ":", "query_parameters", "[", "'cc'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"country_code\"", ",", "country_code", ",", "'str'", ")", "if", "client_machine_name", "is", "not", "None", ":", "query_parameters", "[", "'ClientMachineName'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"client_machine_name\"", ",", "client_machine_name", ",", "'str'", ")", "if", "doc_id", "is", "not", "None", ":", "query_parameters", "[", "'DocId'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"doc_id\"", ",", "doc_id", ",", "'str'", ")", "if", "market", "is", "not", "None", ":", "query_parameters", "[", "'mkt'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"market\"", ",", "market", ",", "'str'", ")", "if", "session_id", "is", "not", "None", ":", "query_parameters", "[", "'SessionId'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"session_id\"", ",", "session_id", ",", "'str'", ")", "if", "set_lang", "is", "not", "None", ":", "query_parameters", "[", "'SetLang'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"set_lang\"", ",", "set_lang", ",", "'str'", ")", "if", "user_id", "is", "not", "None", ":", "query_parameters", "[", "'UserId'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"user_id\"", ",", "user_id", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/x-www-form-urlencoded'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "header_parameters", "[", "'X-BingApis-SDK'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"x_bing_apis_sdk\"", ",", "x_bing_apis_sdk", ",", "'str'", ")", "if", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'Accept-Language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"accept_language\"", ",", "accept_language", ",", "'str'", ")", "if", "pragma", "is", "not", "None", ":", "header_parameters", "[", "'Pragma'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"pragma\"", ",", "pragma", ",", "'str'", ")", "if", "user_agent", "is", "not", "None", ":", "header_parameters", "[", "'User-Agent'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"user_agent\"", ",", "user_agent", ",", "'str'", ")", "if", "client_id", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientID'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_id\"", ",", "client_id", ",", "'str'", ")", "if", "client_ip", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientIP'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_ip\"", ",", "client_ip", ",", "'str'", ")", "if", "location", "is", "not", "None", ":", "header_parameters", "[", "'X-Search-Location'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"location\"", ",", "location", ",", "'str'", ")", "# Construct form data", "form_data_content", "=", "{", "'Text'", ":", "text", ",", "'Mode'", ":", "mode", ",", "'PreContextText'", ":", "pre_context_text", ",", "'PostContextText'", ":", "post_context_text", ",", "}", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ")", "response", "=", "self", ".", "_client", ".", "send_formdata", "(", "request", ",", "header_parameters", ",", "form_data_content", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'SpellCheck'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPClient.set_proxy
Sets the proxy server host and port for the HTTP CONNECT Tunnelling. host: Address of the proxy. Ex: '192.168.0.100' port: Port of the proxy. Ex: 6000 user: User for proxy authorization. password: Password for proxy authorization.
azure-servicebus/azure/servicebus/control_client/_http/httpclient.py
def set_proxy(self, host, port, user, password): ''' Sets the proxy server host and port for the HTTP CONNECT Tunnelling. host: Address of the proxy. Ex: '192.168.0.100' port: Port of the proxy. Ex: 6000 user: User for proxy authorization. password: Password for proxy authorization. ''' self.proxy_host = host self.proxy_port = port self.proxy_user = user self.proxy_password = password
def set_proxy(self, host, port, user, password): ''' Sets the proxy server host and port for the HTTP CONNECT Tunnelling. host: Address of the proxy. Ex: '192.168.0.100' port: Port of the proxy. Ex: 6000 user: User for proxy authorization. password: Password for proxy authorization. ''' self.proxy_host = host self.proxy_port = port self.proxy_user = user self.proxy_password = password
[ "Sets", "the", "proxy", "server", "host", "and", "port", "for", "the", "HTTP", "CONNECT", "Tunnelling", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/_http/httpclient.py#L64-L80
[ "def", "set_proxy", "(", "self", ",", "host", ",", "port", ",", "user", ",", "password", ")", ":", "self", ".", "proxy_host", "=", "host", "self", ".", "proxy_port", "=", "port", "self", ".", "proxy_user", "=", "user", "self", ".", "proxy_password", "=", "password" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPClient.get_uri
Return the target uri for the request.
azure-servicebus/azure/servicebus/control_client/_http/httpclient.py
def get_uri(self, request): ''' Return the target uri for the request.''' protocol = request.protocol_override \ if request.protocol_override else self.protocol protocol = protocol.lower() port = HTTP_PORT if protocol == 'http' else HTTPS_PORT return protocol + '://' + request.host + ':' + str(port) + request.path
def get_uri(self, request): ''' Return the target uri for the request.''' protocol = request.protocol_override \ if request.protocol_override else self.protocol protocol = protocol.lower() port = HTTP_PORT if protocol == 'http' else HTTPS_PORT return protocol + '://' + request.host + ':' + str(port) + request.path
[ "Return", "the", "target", "uri", "for", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/_http/httpclient.py#L82-L88
[ "def", "get_uri", "(", "self", ",", "request", ")", ":", "protocol", "=", "request", ".", "protocol_override", "if", "request", ".", "protocol_override", "else", "self", ".", "protocol", "protocol", "=", "protocol", ".", "lower", "(", ")", "port", "=", "HTTP_PORT", "if", "protocol", "==", "'http'", "else", "HTTPS_PORT", "return", "protocol", "+", "'://'", "+", "request", ".", "host", "+", "':'", "+", "str", "(", "port", ")", "+", "request", ".", "path" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPClient.get_connection
Create connection for the request.
azure-servicebus/azure/servicebus/control_client/_http/httpclient.py
def get_connection(self, request): ''' Create connection for the request. ''' protocol = request.protocol_override \ if request.protocol_override else self.protocol protocol = protocol.lower() target_host = request.host # target_port = HTTP_PORT if protocol == 'http' else HTTPS_PORT connection = _RequestsConnection( target_host, protocol, self.request_session, self.timeout) proxy_host = self.proxy_host proxy_port = self.proxy_port if self.proxy_host: headers = None if self.proxy_user and self.proxy_password: auth = base64.b64encode("{0}:{1}".format(self.proxy_user, self.proxy_password).encode()) headers = {'Proxy-Authorization': 'Basic {0}'.format(auth.decode())} connection.set_tunnel(proxy_host, int(proxy_port), headers) return connection
def get_connection(self, request): ''' Create connection for the request. ''' protocol = request.protocol_override \ if request.protocol_override else self.protocol protocol = protocol.lower() target_host = request.host # target_port = HTTP_PORT if protocol == 'http' else HTTPS_PORT connection = _RequestsConnection( target_host, protocol, self.request_session, self.timeout) proxy_host = self.proxy_host proxy_port = self.proxy_port if self.proxy_host: headers = None if self.proxy_user and self.proxy_password: auth = base64.b64encode("{0}:{1}".format(self.proxy_user, self.proxy_password).encode()) headers = {'Proxy-Authorization': 'Basic {0}'.format(auth.decode())} connection.set_tunnel(proxy_host, int(proxy_port), headers) return connection
[ "Create", "connection", "for", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/_http/httpclient.py#L90-L110
[ "def", "get_connection", "(", "self", ",", "request", ")", ":", "protocol", "=", "request", ".", "protocol_override", "if", "request", ".", "protocol_override", "else", "self", ".", "protocol", "protocol", "=", "protocol", ".", "lower", "(", ")", "target_host", "=", "request", ".", "host", "# target_port = HTTP_PORT if protocol == 'http' else HTTPS_PORT", "connection", "=", "_RequestsConnection", "(", "target_host", ",", "protocol", ",", "self", ".", "request_session", ",", "self", ".", "timeout", ")", "proxy_host", "=", "self", ".", "proxy_host", "proxy_port", "=", "self", ".", "proxy_port", "if", "self", ".", "proxy_host", ":", "headers", "=", "None", "if", "self", ".", "proxy_user", "and", "self", ".", "proxy_password", ":", "auth", "=", "base64", ".", "b64encode", "(", "\"{0}:{1}\"", ".", "format", "(", "self", ".", "proxy_user", ",", "self", ".", "proxy_password", ")", ".", "encode", "(", ")", ")", "headers", "=", "{", "'Proxy-Authorization'", ":", "'Basic {0}'", ".", "format", "(", "auth", ".", "decode", "(", ")", ")", "}", "connection", ".", "set_tunnel", "(", "proxy_host", ",", "int", "(", "proxy_port", ")", ",", "headers", ")", "return", "connection" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPClient.perform_request
Sends request to cloud service server and return the response.
azure-servicebus/azure/servicebus/control_client/_http/httpclient.py
def perform_request(self, request): ''' Sends request to cloud service server and return the response. ''' connection = self.get_connection(request) try: connection.putrequest(request.method, request.path) self.send_request_headers(connection, request.headers) self.send_request_body(connection, request.body) if DEBUG_REQUESTS and request.body: print('request:') try: print(request.body) except: # pylint: disable=bare-except pass resp = connection.getresponse() status = int(resp.status) message = resp.reason respheaders = resp.getheaders() # for consistency across platforms, make header names lowercase for i, value in enumerate(respheaders): respheaders[i] = (value[0].lower(), value[1]) respbody = None if resp.length is None: respbody = resp.read() elif resp.length > 0: respbody = resp.read(resp.length) if DEBUG_RESPONSES and respbody: print('response:') try: print(respbody) except: # pylint: disable=bare-except pass response = HTTPResponse( status, resp.reason, respheaders, respbody) if status == 307: new_url = urlparse(dict(respheaders)['location']) request.host = new_url.hostname request.path = new_url.path request.path, request.query = self._update_request_uri_query(request) return self.perform_request(request) if status >= 300: raise HTTPError(status, message, respheaders, respbody) return response finally: connection.close()
def perform_request(self, request): ''' Sends request to cloud service server and return the response. ''' connection = self.get_connection(request) try: connection.putrequest(request.method, request.path) self.send_request_headers(connection, request.headers) self.send_request_body(connection, request.body) if DEBUG_REQUESTS and request.body: print('request:') try: print(request.body) except: # pylint: disable=bare-except pass resp = connection.getresponse() status = int(resp.status) message = resp.reason respheaders = resp.getheaders() # for consistency across platforms, make header names lowercase for i, value in enumerate(respheaders): respheaders[i] = (value[0].lower(), value[1]) respbody = None if resp.length is None: respbody = resp.read() elif resp.length > 0: respbody = resp.read(resp.length) if DEBUG_RESPONSES and respbody: print('response:') try: print(respbody) except: # pylint: disable=bare-except pass response = HTTPResponse( status, resp.reason, respheaders, respbody) if status == 307: new_url = urlparse(dict(respheaders)['location']) request.host = new_url.hostname request.path = new_url.path request.path, request.query = self._update_request_uri_query(request) return self.perform_request(request) if status >= 300: raise HTTPError(status, message, respheaders, respbody) return response finally: connection.close()
[ "Sends", "request", "to", "cloud", "service", "server", "and", "return", "the", "response", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/_http/httpclient.py#L164-L215
[ "def", "perform_request", "(", "self", ",", "request", ")", ":", "connection", "=", "self", ".", "get_connection", "(", "request", ")", "try", ":", "connection", ".", "putrequest", "(", "request", ".", "method", ",", "request", ".", "path", ")", "self", ".", "send_request_headers", "(", "connection", ",", "request", ".", "headers", ")", "self", ".", "send_request_body", "(", "connection", ",", "request", ".", "body", ")", "if", "DEBUG_REQUESTS", "and", "request", ".", "body", ":", "print", "(", "'request:'", ")", "try", ":", "print", "(", "request", ".", "body", ")", "except", ":", "# pylint: disable=bare-except", "pass", "resp", "=", "connection", ".", "getresponse", "(", ")", "status", "=", "int", "(", "resp", ".", "status", ")", "message", "=", "resp", ".", "reason", "respheaders", "=", "resp", ".", "getheaders", "(", ")", "# for consistency across platforms, make header names lowercase", "for", "i", ",", "value", "in", "enumerate", "(", "respheaders", ")", ":", "respheaders", "[", "i", "]", "=", "(", "value", "[", "0", "]", ".", "lower", "(", ")", ",", "value", "[", "1", "]", ")", "respbody", "=", "None", "if", "resp", ".", "length", "is", "None", ":", "respbody", "=", "resp", ".", "read", "(", ")", "elif", "resp", ".", "length", ">", "0", ":", "respbody", "=", "resp", ".", "read", "(", "resp", ".", "length", ")", "if", "DEBUG_RESPONSES", "and", "respbody", ":", "print", "(", "'response:'", ")", "try", ":", "print", "(", "respbody", ")", "except", ":", "# pylint: disable=bare-except", "pass", "response", "=", "HTTPResponse", "(", "status", ",", "resp", ".", "reason", ",", "respheaders", ",", "respbody", ")", "if", "status", "==", "307", ":", "new_url", "=", "urlparse", "(", "dict", "(", "respheaders", ")", "[", "'location'", "]", ")", "request", ".", "host", "=", "new_url", ".", "hostname", "request", ".", "path", "=", "new_url", ".", "path", "request", ".", "path", ",", "request", ".", "query", "=", "self", ".", "_update_request_uri_query", "(", "request", ")", "return", "self", ".", "perform_request", "(", "request", ")", "if", "status", ">=", "300", ":", "raise", "HTTPError", "(", "status", ",", "message", ",", "respheaders", ",", "respbody", ")", "return", "response", "finally", ":", "connection", ".", "close", "(", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ClustersOperations.execute_script_actions
Executes script actions on the specified HDInsight cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param cluster_name: The name of the cluster. :type cluster_name: str :param persist_on_success: Gets or sets if the scripts needs to be persisted. :type persist_on_success: bool :param script_actions: The list of run time script actions. :type script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.hdinsight.models.ErrorResponseException>`
azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/clusters_operations.py
def execute_script_actions( self, resource_group_name, cluster_name, persist_on_success, script_actions=None, custom_headers=None, raw=False, polling=True, **operation_config): """Executes script actions on the specified HDInsight cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param cluster_name: The name of the cluster. :type cluster_name: str :param persist_on_success: Gets or sets if the scripts needs to be persisted. :type persist_on_success: bool :param script_actions: The list of run time script actions. :type script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.hdinsight.models.ErrorResponseException>` """ raw_result = self._execute_script_actions_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, persist_on_success=persist_on_success, script_actions=script_actions, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def execute_script_actions( self, resource_group_name, cluster_name, persist_on_success, script_actions=None, custom_headers=None, raw=False, polling=True, **operation_config): """Executes script actions on the specified HDInsight cluster. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param cluster_name: The name of the cluster. :type cluster_name: str :param persist_on_success: Gets or sets if the scripts needs to be persisted. :type persist_on_success: bool :param script_actions: The list of run time script actions. :type script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`ErrorResponseException<azure.mgmt.hdinsight.models.ErrorResponseException>` """ raw_result = self._execute_script_actions_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, persist_on_success=persist_on_success, script_actions=script_actions, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Executes", "script", "actions", "on", "the", "specified", "HDInsight", "cluster", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/clusters_operations.py#L844-L891
[ "def", "execute_script_actions", "(", "self", ",", "resource_group_name", ",", "cluster_name", ",", "persist_on_success", ",", "script_actions", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_execute_script_actions_initial", "(", "resource_group_name", "=", "resource_group_name", ",", "cluster_name", "=", "cluster_name", ",", "persist_on_success", "=", "persist_on_success", ",", "script_actions", "=", "script_actions", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.models
Module depends on the API version: * 2015-08-01: :mod:`v2015_08_01.models<azure.mgmt.eventhub.v2015_08_01.models>` * 2017-04-01: :mod:`v2017_04_01.models<azure.mgmt.eventhub.v2017_04_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.eventhub.v2018_01_01_preview.models>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-08-01: :mod:`v2015_08_01.models<azure.mgmt.eventhub.v2015_08_01.models>` * 2017-04-01: :mod:`v2017_04_01.models<azure.mgmt.eventhub.v2017_04_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.eventhub.v2018_01_01_preview.models>` """ if api_version == '2015-08-01': from .v2015_08_01 import models return models elif api_version == '2017-04-01': from .v2017_04_01 import models return models elif api_version == '2018-01-01-preview': from .v2018_01_01_preview import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-08-01: :mod:`v2015_08_01.models<azure.mgmt.eventhub.v2015_08_01.models>` * 2017-04-01: :mod:`v2017_04_01.models<azure.mgmt.eventhub.v2017_04_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.eventhub.v2018_01_01_preview.models>` """ if api_version == '2015-08-01': from .v2015_08_01 import models return models elif api_version == '2017-04-01': from .v2017_04_01 import models return models elif api_version == '2018-01-01-preview': from .v2018_01_01_preview import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L109-L125
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2015-08-01'", ":", "from", ".", "v2015_08_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.clusters
Instance depends on the API version: * 2018-01-01-preview: :class:`ClustersOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ClustersOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def clusters(self): """Instance depends on the API version: * 2018-01-01-preview: :class:`ClustersOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ClustersOperations>` """ api_version = self._get_api_version('clusters') if api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ClustersOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def clusters(self): """Instance depends on the API version: * 2018-01-01-preview: :class:`ClustersOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ClustersOperations>` """ api_version = self._get_api_version('clusters') if api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ClustersOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L128-L138
[ "def", "clusters", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'clusters'", ")", "if", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "ClustersOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.configuration
Instance depends on the API version: * 2018-01-01-preview: :class:`ConfigurationOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ConfigurationOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def configuration(self): """Instance depends on the API version: * 2018-01-01-preview: :class:`ConfigurationOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ConfigurationOperations>` """ api_version = self._get_api_version('configuration') if api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ConfigurationOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def configuration(self): """Instance depends on the API version: * 2018-01-01-preview: :class:`ConfigurationOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.ConfigurationOperations>` """ api_version = self._get_api_version('configuration') if api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ConfigurationOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L141-L151
[ "def", "configuration", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'configuration'", ")", "if", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "ConfigurationOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.consumer_groups
Instance depends on the API version: * 2015-08-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2015_08_01.operations.ConsumerGroupsOperations>` * 2017-04-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2017_04_01.operations.ConsumerGroupsOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def consumer_groups(self): """Instance depends on the API version: * 2015-08-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2015_08_01.operations.ConsumerGroupsOperations>` * 2017-04-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2017_04_01.operations.ConsumerGroupsOperations>` """ api_version = self._get_api_version('consumer_groups') if api_version == '2015-08-01': from .v2015_08_01.operations import ConsumerGroupsOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import ConsumerGroupsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def consumer_groups(self): """Instance depends on the API version: * 2015-08-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2015_08_01.operations.ConsumerGroupsOperations>` * 2017-04-01: :class:`ConsumerGroupsOperations<azure.mgmt.eventhub.v2017_04_01.operations.ConsumerGroupsOperations>` """ api_version = self._get_api_version('consumer_groups') if api_version == '2015-08-01': from .v2015_08_01.operations import ConsumerGroupsOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import ConsumerGroupsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L154-L167
[ "def", "consumer_groups", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'consumer_groups'", ")", "if", "api_version", "==", "'2015-08-01'", ":", "from", ".", "v2015_08_01", ".", "operations", "import", "ConsumerGroupsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", ".", "operations", "import", "ConsumerGroupsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.disaster_recovery_configs
Instance depends on the API version: * 2017-04-01: :class:`DisasterRecoveryConfigsOperations<azure.mgmt.eventhub.v2017_04_01.operations.DisasterRecoveryConfigsOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def disaster_recovery_configs(self): """Instance depends on the API version: * 2017-04-01: :class:`DisasterRecoveryConfigsOperations<azure.mgmt.eventhub.v2017_04_01.operations.DisasterRecoveryConfigsOperations>` """ api_version = self._get_api_version('disaster_recovery_configs') if api_version == '2017-04-01': from .v2017_04_01.operations import DisasterRecoveryConfigsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def disaster_recovery_configs(self): """Instance depends on the API version: * 2017-04-01: :class:`DisasterRecoveryConfigsOperations<azure.mgmt.eventhub.v2017_04_01.operations.DisasterRecoveryConfigsOperations>` """ api_version = self._get_api_version('disaster_recovery_configs') if api_version == '2017-04-01': from .v2017_04_01.operations import DisasterRecoveryConfigsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L170-L180
[ "def", "disaster_recovery_configs", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'disaster_recovery_configs'", ")", "if", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", ".", "operations", "import", "DisasterRecoveryConfigsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.event_hubs
Instance depends on the API version: * 2015-08-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2015_08_01.operations.EventHubsOperations>` * 2017-04-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2017_04_01.operations.EventHubsOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def event_hubs(self): """Instance depends on the API version: * 2015-08-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2015_08_01.operations.EventHubsOperations>` * 2017-04-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2017_04_01.operations.EventHubsOperations>` """ api_version = self._get_api_version('event_hubs') if api_version == '2015-08-01': from .v2015_08_01.operations import EventHubsOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import EventHubsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def event_hubs(self): """Instance depends on the API version: * 2015-08-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2015_08_01.operations.EventHubsOperations>` * 2017-04-01: :class:`EventHubsOperations<azure.mgmt.eventhub.v2017_04_01.operations.EventHubsOperations>` """ api_version = self._get_api_version('event_hubs') if api_version == '2015-08-01': from .v2015_08_01.operations import EventHubsOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import EventHubsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L183-L196
[ "def", "event_hubs", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'event_hubs'", ")", "if", "api_version", "==", "'2015-08-01'", ":", "from", ".", "v2015_08_01", ".", "operations", "import", "EventHubsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", ".", "operations", "import", "EventHubsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.namespaces
Instance depends on the API version: * 2015-08-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2015_08_01.operations.NamespacesOperations>` * 2017-04-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2017_04_01.operations.NamespacesOperations>` * 2018-01-01-preview: :class:`NamespacesOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.NamespacesOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def namespaces(self): """Instance depends on the API version: * 2015-08-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2015_08_01.operations.NamespacesOperations>` * 2017-04-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2017_04_01.operations.NamespacesOperations>` * 2018-01-01-preview: :class:`NamespacesOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.NamespacesOperations>` """ api_version = self._get_api_version('namespaces') if api_version == '2015-08-01': from .v2015_08_01.operations import NamespacesOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import NamespacesOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import NamespacesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def namespaces(self): """Instance depends on the API version: * 2015-08-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2015_08_01.operations.NamespacesOperations>` * 2017-04-01: :class:`NamespacesOperations<azure.mgmt.eventhub.v2017_04_01.operations.NamespacesOperations>` * 2018-01-01-preview: :class:`NamespacesOperations<azure.mgmt.eventhub.v2018_01_01_preview.operations.NamespacesOperations>` """ api_version = self._get_api_version('namespaces') if api_version == '2015-08-01': from .v2015_08_01.operations import NamespacesOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import NamespacesOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import NamespacesOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L199-L215
[ "def", "namespaces", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'namespaces'", ")", "if", "api_version", "==", "'2015-08-01'", ":", "from", ".", "v2015_08_01", ".", "operations", "import", "NamespacesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", ".", "operations", "import", "NamespacesOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "NamespacesOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
EventHubManagementClient.regions
Instance depends on the API version: * 2017-04-01: :class:`RegionsOperations<azure.mgmt.eventhub.v2017_04_01.operations.RegionsOperations>`
azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py
def regions(self): """Instance depends on the API version: * 2017-04-01: :class:`RegionsOperations<azure.mgmt.eventhub.v2017_04_01.operations.RegionsOperations>` """ api_version = self._get_api_version('regions') if api_version == '2017-04-01': from .v2017_04_01.operations import RegionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def regions(self): """Instance depends on the API version: * 2017-04-01: :class:`RegionsOperations<azure.mgmt.eventhub.v2017_04_01.operations.RegionsOperations>` """ api_version = self._get_api_version('regions') if api_version == '2017-04-01': from .v2017_04_01.operations import RegionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-eventhub/azure/mgmt/eventhub/event_hub_management_client.py#L237-L247
[ "def", "regions", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'regions'", ")", "if", "api_version", "==", "'2017-04-01'", ":", "from", ".", "v2017_04_01", ".", "operations", "import", "RegionsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FrontDoorManagementClient.check_front_door_name_availability
Check the availability of a Front Door resource name. :param name: The resource name to validate. :type name: str :param type: The type of the resource whose name is to be validated. Possible values include: 'Microsoft.Network/frontDoors', 'Microsoft.Network/frontDoors/frontendEndpoints' :type type: str or ~azure.mgmt.frontdoor.models.ResourceType :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>`
azure-mgmt-frontdoor/azure/mgmt/frontdoor/front_door_management_client.py
def check_front_door_name_availability( self, name, type, custom_headers=None, raw=False, **operation_config): """Check the availability of a Front Door resource name. :param name: The resource name to validate. :type name: str :param type: The type of the resource whose name is to be validated. Possible values include: 'Microsoft.Network/frontDoors', 'Microsoft.Network/frontDoors/frontendEndpoints' :type type: str or ~azure.mgmt.frontdoor.models.ResourceType :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>` """ check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type) api_version = "2018-08-01" # Construct URL url = self.check_front_door_name_availability.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def check_front_door_name_availability( self, name, type, custom_headers=None, raw=False, **operation_config): """Check the availability of a Front Door resource name. :param name: The resource name to validate. :type name: str :param type: The type of the resource whose name is to be validated. Possible values include: 'Microsoft.Network/frontDoors', 'Microsoft.Network/frontDoors/frontendEndpoints' :type type: str or ~azure.mgmt.frontdoor.models.ResourceType :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>` """ check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type) api_version = "2018-08-01" # Construct URL url = self.check_front_door_name_availability.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Check", "the", "availability", "of", "a", "Front", "Door", "resource", "name", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-frontdoor/azure/mgmt/frontdoor/front_door_management_client.py#L126-L188
[ "def", "check_front_door_name_availability", "(", "self", ",", "name", ",", "type", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "check_front_door_name_availability_input", "=", "models", ".", "CheckNameAvailabilityInput", "(", "name", "=", "name", ",", "type", "=", "type", ")", "api_version", "=", "\"2018-08-01\"", "# Construct URL", "url", "=", "self", ".", "check_front_door_name_availability", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"api_version\"", ",", "api_version", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'x-ms-client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "check_front_door_name_availability_input", ",", "'CheckNameAvailabilityInput'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'CheckNameAvailabilityOutput'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
VaultsOperations.purge_deleted
Permanently deletes the specified vault. aka Purges the deleted Azure key vault. :param vault_name: The name of the soft-deleted vault. :type vault_name: str :param location: The location of the soft-deleted vault. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/vaults_operations.py
def purge_deleted( self, vault_name, location, custom_headers=None, raw=False, polling=True, **operation_config): """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. :param vault_name: The name of the soft-deleted vault. :type vault_name: str :param location: The location of the soft-deleted vault. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._purge_deleted_initial( vault_name=vault_name, location=location, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
def purge_deleted( self, vault_name, location, custom_headers=None, raw=False, polling=True, **operation_config): """Permanently deletes the specified vault. aka Purges the deleted Azure key vault. :param vault_name: The name of the soft-deleted vault. :type vault_name: str :param location: The location of the soft-deleted vault. :type location: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response :param polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :return: An instance of LROPoller that returns None or ClientRawResponse<None> if raw==True :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ raw_result = self._purge_deleted_initial( vault_name=vault_name, location=location, custom_headers=custom_headers, raw=True, **operation_config ) def get_long_running_output(response): if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
[ "Permanently", "deletes", "the", "specified", "vault", ".", "aka", "Purges", "the", "deleted", "Azure", "key", "vault", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-keyvault/azure/mgmt/keyvault/v2016_10_01/operations/vaults_operations.py#L718-L757
[ "def", "purge_deleted", "(", "self", ",", "vault_name", ",", "location", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "polling", "=", "True", ",", "*", "*", "operation_config", ")", ":", "raw_result", "=", "self", ".", "_purge_deleted_initial", "(", "vault_name", "=", "vault_name", ",", "location", "=", "location", ",", "custom_headers", "=", "custom_headers", ",", "raw", "=", "True", ",", "*", "*", "operation_config", ")", "def", "get_long_running_output", "(", "response", ")", ":", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "return", "client_raw_response", "lro_delay", "=", "operation_config", ".", "get", "(", "'long_running_operation_timeout'", ",", "self", ".", "config", ".", "long_running_operation_timeout", ")", "if", "polling", "is", "True", ":", "polling_method", "=", "ARMPolling", "(", "lro_delay", ",", "*", "*", "operation_config", ")", "elif", "polling", "is", "False", ":", "polling_method", "=", "NoPolling", "(", ")", "else", ":", "polling_method", "=", "polling", "return", "LROPoller", "(", "self", ".", "_client", ",", "raw_result", ",", "get_long_running_output", ",", "polling_method", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
HttpChallenge.get_authorization_server
Returns the URI for the authorization server if present, otherwise empty string.
azure-keyvault/azure/keyvault/http_challenge.py
def get_authorization_server(self): """ Returns the URI for the authorization server if present, otherwise empty string. """ value = '' for key in ['authorization_uri', 'authorization']: value = self.get_value(key) or '' if value: break return value
def get_authorization_server(self): """ Returns the URI for the authorization server if present, otherwise empty string. """ value = '' for key in ['authorization_uri', 'authorization']: value = self.get_value(key) or '' if value: break return value
[ "Returns", "the", "URI", "for", "the", "authorization", "server", "if", "present", "otherwise", "empty", "string", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_challenge.py#L70-L77
[ "def", "get_authorization_server", "(", "self", ")", ":", "value", "=", "''", "for", "key", "in", "[", "'authorization_uri'", ",", "'authorization'", "]", ":", "value", "=", "self", ".", "get_value", "(", "key", ")", "or", "''", "if", "value", ":", "break", "return", "value" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
HttpChallenge._validate_request_uri
Extracts the host authority from the given URI.
azure-keyvault/azure/keyvault/http_challenge.py
def _validate_request_uri(self, uri): """ Extracts the host authority from the given URI. """ if not uri: raise ValueError('request_uri cannot be empty') uri = parse.urlparse(uri) if not uri.netloc: raise ValueError('request_uri must be an absolute URI') if uri.scheme.lower() not in ['http', 'https']: raise ValueError('request_uri must be HTTP or HTTPS') return uri.netloc
def _validate_request_uri(self, uri): """ Extracts the host authority from the given URI. """ if not uri: raise ValueError('request_uri cannot be empty') uri = parse.urlparse(uri) if not uri.netloc: raise ValueError('request_uri must be an absolute URI') if uri.scheme.lower() not in ['http', 'https']: raise ValueError('request_uri must be HTTP or HTTPS') return uri.netloc
[ "Extracts", "the", "host", "authority", "from", "the", "given", "URI", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_challenge.py#L103-L115
[ "def", "_validate_request_uri", "(", "self", ",", "uri", ")", ":", "if", "not", "uri", ":", "raise", "ValueError", "(", "'request_uri cannot be empty'", ")", "uri", "=", "parse", ".", "urlparse", "(", "uri", ")", "if", "not", "uri", ".", "netloc", ":", "raise", "ValueError", "(", "'request_uri must be an absolute URI'", ")", "if", "uri", ".", "scheme", ".", "lower", "(", ")", "not", "in", "[", "'http'", ",", "'https'", "]", ":", "raise", "ValueError", "(", "'request_uri must be HTTP or HTTPS'", ")", "return", "uri", ".", "netloc" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
get_cli_profile
Return a CLI profile class. .. versionadded:: 1.1.6 :return: A CLI Profile :rtype: azure.cli.core._profile.Profile :raises: ImportError if azure-cli-core package is not available
azure-common/azure/common/credentials.py
def get_cli_profile(): """Return a CLI profile class. .. versionadded:: 1.1.6 :return: A CLI Profile :rtype: azure.cli.core._profile.Profile :raises: ImportError if azure-cli-core package is not available """ try: from azure.cli.core._profile import Profile from azure.cli.core._session import ACCOUNT from azure.cli.core._environment import get_config_dir except ImportError: raise ImportError("You need to install 'azure-cli-core' to load CLI credentials") azure_folder = get_config_dir() ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) return Profile(storage=ACCOUNT)
def get_cli_profile(): """Return a CLI profile class. .. versionadded:: 1.1.6 :return: A CLI Profile :rtype: azure.cli.core._profile.Profile :raises: ImportError if azure-cli-core package is not available """ try: from azure.cli.core._profile import Profile from azure.cli.core._session import ACCOUNT from azure.cli.core._environment import get_config_dir except ImportError: raise ImportError("You need to install 'azure-cli-core' to load CLI credentials") azure_folder = get_config_dir() ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json')) return Profile(storage=ACCOUNT)
[ "Return", "a", "CLI", "profile", "class", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-common/azure/common/credentials.py#L9-L29
[ "def", "get_cli_profile", "(", ")", ":", "try", ":", "from", "azure", ".", "cli", ".", "core", ".", "_profile", "import", "Profile", "from", "azure", ".", "cli", ".", "core", ".", "_session", "import", "ACCOUNT", "from", "azure", ".", "cli", ".", "core", ".", "_environment", "import", "get_config_dir", "except", "ImportError", ":", "raise", "ImportError", "(", "\"You need to install 'azure-cli-core' to load CLI credentials\"", ")", "azure_folder", "=", "get_config_dir", "(", ")", "ACCOUNT", ".", "load", "(", "os", ".", "path", ".", "join", "(", "azure_folder", ",", "'azureProfile.json'", ")", ")", "return", "Profile", "(", "storage", "=", "ACCOUNT", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
get_azure_cli_credentials
Return Credentials and default SubscriptionID of current loaded profile of the CLI. Credentials will be the "az login" command: https://docs.microsoft.com/cli/azure/authenticate-azure-cli Default subscription ID is either the only one you have, or you can define it: https://docs.microsoft.com/cli/azure/manage-azure-subscriptions-azure-cli .. versionadded:: 1.1.6 :param str resource: The alternative resource for credentials if not ARM (GraphRBac, etc.) :param bool with_tenant: If True, return a three-tuple with last as tenant ID :return: tuple of Credentials and SubscriptionID (and tenant ID if with_tenant) :rtype: tuple
azure-common/azure/common/credentials.py
def get_azure_cli_credentials(resource=None, with_tenant=False): """Return Credentials and default SubscriptionID of current loaded profile of the CLI. Credentials will be the "az login" command: https://docs.microsoft.com/cli/azure/authenticate-azure-cli Default subscription ID is either the only one you have, or you can define it: https://docs.microsoft.com/cli/azure/manage-azure-subscriptions-azure-cli .. versionadded:: 1.1.6 :param str resource: The alternative resource for credentials if not ARM (GraphRBac, etc.) :param bool with_tenant: If True, return a three-tuple with last as tenant ID :return: tuple of Credentials and SubscriptionID (and tenant ID if with_tenant) :rtype: tuple """ profile = get_cli_profile() cred, subscription_id, tenant_id = profile.get_login_credentials(resource=resource) if with_tenant: return cred, subscription_id, tenant_id else: return cred, subscription_id
def get_azure_cli_credentials(resource=None, with_tenant=False): """Return Credentials and default SubscriptionID of current loaded profile of the CLI. Credentials will be the "az login" command: https://docs.microsoft.com/cli/azure/authenticate-azure-cli Default subscription ID is either the only one you have, or you can define it: https://docs.microsoft.com/cli/azure/manage-azure-subscriptions-azure-cli .. versionadded:: 1.1.6 :param str resource: The alternative resource for credentials if not ARM (GraphRBac, etc.) :param bool with_tenant: If True, return a three-tuple with last as tenant ID :return: tuple of Credentials and SubscriptionID (and tenant ID if with_tenant) :rtype: tuple """ profile = get_cli_profile() cred, subscription_id, tenant_id = profile.get_login_credentials(resource=resource) if with_tenant: return cred, subscription_id, tenant_id else: return cred, subscription_id
[ "Return", "Credentials", "and", "default", "SubscriptionID", "of", "current", "loaded", "profile", "of", "the", "CLI", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-common/azure/common/credentials.py#L31-L52
[ "def", "get_azure_cli_credentials", "(", "resource", "=", "None", ",", "with_tenant", "=", "False", ")", ":", "profile", "=", "get_cli_profile", "(", ")", "cred", ",", "subscription_id", ",", "tenant_id", "=", "profile", ".", "get_login_credentials", "(", "resource", "=", "resource", ")", "if", "with_tenant", ":", "return", "cred", ",", "subscription_id", ",", "tenant_id", "else", ":", "return", "cred", ",", "subscription_id" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AlertsOperations.get_all
List all the existing alerts, where the results can be selective by passing multiple filter parameters including time range and sorted on specific fields. . :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param smart_group_id: Filter the alerts list by the Smart Group Id. Default value is none. :type smart_group_id: str :param include_context: Include context which has data contextual to the monitor service. Default value is false' :type include_context: bool :param include_egress_config: Include egress config which would be used for displaying the content in portal. Default value is 'false'. :type include_egress_config: bool :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. :type page_count: int :param sort_by: Sort the query results by input field, Default value is 'lastModifiedDateTime'. Possible values include: 'name', 'severity', 'alertState', 'monitorCondition', 'targetResource', 'targetResourceName', 'targetResourceGroup', 'targetResourceType', 'startDateTime', 'lastModifiedDateTime' :type sort_by: str or ~azure.mgmt.alertsmanagement.models.AlertsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. Possible values include: 'asc', 'desc' :type sort_order: str :param select: This filter allows to selection of the fields(comma seperated) which would be part of the the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section. :type select: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: An iterator like instance of Alert :rtype: ~azure.mgmt.alertsmanagement.models.AlertPaged[~azure.mgmt.alertsmanagement.models.Alert] :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>`
azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/alerts_operations.py
def get_all( self, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, smart_group_id=None, include_context=None, include_egress_config=None, page_count=None, sort_by=None, sort_order=None, select=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): """List all the existing alerts, where the results can be selective by passing multiple filter parameters including time range and sorted on specific fields. . :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param smart_group_id: Filter the alerts list by the Smart Group Id. Default value is none. :type smart_group_id: str :param include_context: Include context which has data contextual to the monitor service. Default value is false' :type include_context: bool :param include_egress_config: Include egress config which would be used for displaying the content in portal. Default value is 'false'. :type include_egress_config: bool :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. :type page_count: int :param sort_by: Sort the query results by input field, Default value is 'lastModifiedDateTime'. Possible values include: 'name', 'severity', 'alertState', 'monitorCondition', 'targetResource', 'targetResourceName', 'targetResourceGroup', 'targetResourceType', 'startDateTime', 'lastModifiedDateTime' :type sort_by: str or ~azure.mgmt.alertsmanagement.models.AlertsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. Possible values include: 'asc', 'desc' :type sort_order: str :param select: This filter allows to selection of the fields(comma seperated) which would be part of the the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section. :type select: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: An iterator like instance of Alert :rtype: ~azure.mgmt.alertsmanagement.models.AlertPaged[~azure.mgmt.alertsmanagement.models.Alert] :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.get_all.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if target_resource is not None: query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') if target_resource_type is not None: query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') if target_resource_group is not None: query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') if monitor_service is not None: query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') if monitor_condition is not None: query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') if severity is not None: query_parameters['severity'] = self._serialize.query("severity", severity, 'str') if alert_state is not None: query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') if alert_rule is not None: query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') if smart_group_id is not None: query_parameters['smartGroupId'] = self._serialize.query("smart_group_id", smart_group_id, 'str') if include_context is not None: query_parameters['includeContext'] = self._serialize.query("include_context", include_context, 'bool') if include_egress_config is not None: query_parameters['includeEgressConfig'] = self._serialize.query("include_egress_config", include_egress_config, 'bool') if page_count is not None: query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') if select is not None: query_parameters['select'] = self._serialize.query("select", select, 'str') if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if custom_time_range is not None: query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' 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, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.AlertPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.AlertPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
def get_all( self, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, smart_group_id=None, include_context=None, include_egress_config=None, page_count=None, sort_by=None, sort_order=None, select=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): """List all the existing alerts, where the results can be selective by passing multiple filter parameters including time range and sorted on specific fields. . :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param smart_group_id: Filter the alerts list by the Smart Group Id. Default value is none. :type smart_group_id: str :param include_context: Include context which has data contextual to the monitor service. Default value is false' :type include_context: bool :param include_egress_config: Include egress config which would be used for displaying the content in portal. Default value is 'false'. :type include_egress_config: bool :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. :type page_count: int :param sort_by: Sort the query results by input field, Default value is 'lastModifiedDateTime'. Possible values include: 'name', 'severity', 'alertState', 'monitorCondition', 'targetResource', 'targetResourceName', 'targetResourceGroup', 'targetResourceType', 'startDateTime', 'lastModifiedDateTime' :type sort_by: str or ~azure.mgmt.alertsmanagement.models.AlertsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. Possible values include: 'asc', 'desc' :type sort_order: str :param select: This filter allows to selection of the fields(comma seperated) which would be part of the the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section. :type select: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: An iterator like instance of Alert :rtype: ~azure.mgmt.alertsmanagement.models.AlertPaged[~azure.mgmt.alertsmanagement.models.Alert] :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.get_all.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if target_resource is not None: query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') if target_resource_type is not None: query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') if target_resource_group is not None: query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') if monitor_service is not None: query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') if monitor_condition is not None: query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') if severity is not None: query_parameters['severity'] = self._serialize.query("severity", severity, 'str') if alert_state is not None: query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') if alert_rule is not None: query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') if smart_group_id is not None: query_parameters['smartGroupId'] = self._serialize.query("smart_group_id", smart_group_id, 'str') if include_context is not None: query_parameters['includeContext'] = self._serialize.query("include_context", include_context, 'bool') if include_egress_config is not None: query_parameters['includeEgressConfig'] = self._serialize.query("include_egress_config", include_egress_config, 'bool') if page_count is not None: query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') if select is not None: query_parameters['select'] = self._serialize.query("select", select, 'str') if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if custom_time_range is not None: query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' 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, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.AlertPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.AlertPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
[ "List", "all", "the", "existing", "alerts", "where", "the", "results", "can", "be", "selective", "by", "passing", "multiple", "filter", "parameters", "including", "time", "range", "and", "sorted", "on", "specific", "fields", ".", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/alerts_operations.py#L39-L210
[ "def", "get_all", "(", "self", ",", "target_resource", "=", "None", ",", "target_resource_type", "=", "None", ",", "target_resource_group", "=", "None", ",", "monitor_service", "=", "None", ",", "monitor_condition", "=", "None", ",", "severity", "=", "None", ",", "alert_state", "=", "None", ",", "alert_rule", "=", "None", ",", "smart_group_id", "=", "None", ",", "include_context", "=", "None", ",", "include_egress_config", "=", "None", ",", "page_count", "=", "None", ",", "sort_by", "=", "None", ",", "sort_order", "=", "None", ",", "select", "=", "None", ",", "time_range", "=", "None", ",", "custom_time_range", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "def", "internal_paging", "(", "next_link", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "next_link", ":", "# Construct URL", "url", "=", "self", ".", "get_all", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'subscriptionId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.subscription_id\"", ",", "self", ".", "config", ".", "subscription_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "target_resource", "is", "not", "None", ":", "query_parameters", "[", "'targetResource'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource\"", ",", "target_resource", ",", "'str'", ")", "if", "target_resource_type", "is", "not", "None", ":", "query_parameters", "[", "'targetResourceType'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource_type\"", ",", "target_resource_type", ",", "'str'", ")", "if", "target_resource_group", "is", "not", "None", ":", "query_parameters", "[", "'targetResourceGroup'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource_group\"", ",", "target_resource_group", ",", "'str'", ")", "if", "monitor_service", "is", "not", "None", ":", "query_parameters", "[", "'monitorService'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"monitor_service\"", ",", "monitor_service", ",", "'str'", ")", "if", "monitor_condition", "is", "not", "None", ":", "query_parameters", "[", "'monitorCondition'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"monitor_condition\"", ",", "monitor_condition", ",", "'str'", ")", "if", "severity", "is", "not", "None", ":", "query_parameters", "[", "'severity'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"severity\"", ",", "severity", ",", "'str'", ")", "if", "alert_state", "is", "not", "None", ":", "query_parameters", "[", "'alertState'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"alert_state\"", ",", "alert_state", ",", "'str'", ")", "if", "alert_rule", "is", "not", "None", ":", "query_parameters", "[", "'alertRule'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"alert_rule\"", ",", "alert_rule", ",", "'str'", ")", "if", "smart_group_id", "is", "not", "None", ":", "query_parameters", "[", "'smartGroupId'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"smart_group_id\"", ",", "smart_group_id", ",", "'str'", ")", "if", "include_context", "is", "not", "None", ":", "query_parameters", "[", "'includeContext'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"include_context\"", ",", "include_context", ",", "'bool'", ")", "if", "include_egress_config", "is", "not", "None", ":", "query_parameters", "[", "'includeEgressConfig'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"include_egress_config\"", ",", "include_egress_config", ",", "'bool'", ")", "if", "page_count", "is", "not", "None", ":", "query_parameters", "[", "'pageCount'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"page_count\"", ",", "page_count", ",", "'int'", ")", "if", "sort_by", "is", "not", "None", ":", "query_parameters", "[", "'sortBy'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"sort_by\"", ",", "sort_by", ",", "'str'", ")", "if", "sort_order", "is", "not", "None", ":", "query_parameters", "[", "'sortOrder'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"sort_order\"", ",", "sort_order", ",", "'str'", ")", "if", "select", "is", "not", "None", ":", "query_parameters", "[", "'select'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"select\"", ",", "select", ",", "'str'", ")", "if", "time_range", "is", "not", "None", ":", "query_parameters", "[", "'timeRange'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"time_range\"", ",", "time_range", ",", "'str'", ")", "if", "custom_time_range", "is", "not", "None", ":", "query_parameters", "[", "'customTimeRange'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"custom_time_range\"", ",", "custom_time_range", ",", "'str'", ")", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "else", ":", "url", "=", "next_link", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "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", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "return", "response", "# Deserialize response", "deserialized", "=", "models", ".", "AlertPaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ")", "if", "raw", ":", "header_dict", "=", "{", "}", "client_raw_response", "=", "models", ".", "AlertPaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ",", "header_dict", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AlertsOperations.get_summary
Summary of alerts with the count each severity. :param groupby: This parameter allows the result set to be aggregated by input fields. For example, groupby=severity,alertstate. Possible values include: 'severity', 'alertState', 'monitorCondition', 'monitorService', 'signalType', 'alertRule' :type groupby: str or ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupByFields :param include_smart_groups_count: Include count of the SmartGroups as part of the summary. Default value is 'false'. :type include_smart_groups_count: bool :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: AlertsSummary or ClientRawResponse if raw=true :rtype: ~azure.mgmt.alertsmanagement.models.AlertsSummary or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>`
azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/alerts_operations.py
def get_summary( self, groupby, include_smart_groups_count=None, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): """Summary of alerts with the count each severity. :param groupby: This parameter allows the result set to be aggregated by input fields. For example, groupby=severity,alertstate. Possible values include: 'severity', 'alertState', 'monitorCondition', 'monitorService', 'signalType', 'alertRule' :type groupby: str or ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupByFields :param include_smart_groups_count: Include count of the SmartGroups as part of the summary. Default value is 'false'. :type include_smart_groups_count: bool :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: AlertsSummary or ClientRawResponse if raw=true :rtype: ~azure.mgmt.alertsmanagement.models.AlertsSummary or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>` """ # Construct URL url = self.get_summary.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['groupby'] = self._serialize.query("groupby", groupby, 'str') if include_smart_groups_count is not None: query_parameters['includeSmartGroupsCount'] = self._serialize.query("include_smart_groups_count", include_smart_groups_count, 'bool') if target_resource is not None: query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') if target_resource_type is not None: query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') if target_resource_group is not None: query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') if monitor_service is not None: query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') if monitor_condition is not None: query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') if severity is not None: query_parameters['severity'] = self._serialize.query("severity", severity, 'str') if alert_state is not None: query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') if alert_rule is not None: query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if custom_time_range is not None: query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' 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, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('AlertsSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_summary( self, groupby, include_smart_groups_count=None, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): """Summary of alerts with the count each severity. :param groupby: This parameter allows the result set to be aggregated by input fields. For example, groupby=severity,alertstate. Possible values include: 'severity', 'alertState', 'monitorCondition', 'monitorService', 'signalType', 'alertRule' :type groupby: str or ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupByFields :param include_smart_groups_count: Include count of the SmartGroups as part of the summary. Default value is 'false'. :type include_smart_groups_count: bool :param target_resource: Filter by target resource( which is full ARM ID) Default value is select all. :type target_resource: str :param target_resource_type: Filter by target resource type. Default value is select all. :type target_resource_type: str :param target_resource_group: Filter by target resource group name. Default value is select all. :type target_resource_group: str :param monitor_service: Filter by monitor service which is the source of the alert instance. Default value is select all. Possible values include: 'Application Insights', 'ActivityLog Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService :param monitor_condition: Filter by monitor condition which is the state of the monitor(alertRule) at monitor service. Default value is to select all. Possible values include: 'Fired', 'Resolved' :type monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition :param severity: Filter by severity. Defaut value is select all. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity :param alert_state: Filter by state of the alert instance. Default value is to select all. Possible values include: 'New', 'Acknowledged', 'Closed' :type alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState :param alert_rule: Filter by alert rule(monitor) which fired alert instance. Default value is to select all. :type alert_rule: str :param time_range: Filter by time range by below listed values. Default value is 1 day. Possible values include: '1h', '1d', '7d', '30d' :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange :param custom_time_range: Filter by custom time range in the format <start-time>/<end-time> where time is in (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none. :type custom_time_range: 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: AlertsSummary or ClientRawResponse if raw=true :rtype: ~azure.mgmt.alertsmanagement.models.AlertsSummary or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.alertsmanagement.models.ErrorResponseException>` """ # Construct URL url = self.get_summary.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['groupby'] = self._serialize.query("groupby", groupby, 'str') if include_smart_groups_count is not None: query_parameters['includeSmartGroupsCount'] = self._serialize.query("include_smart_groups_count", include_smart_groups_count, 'bool') if target_resource is not None: query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') if target_resource_type is not None: query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') if target_resource_group is not None: query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') if monitor_service is not None: query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') if monitor_condition is not None: query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') if severity is not None: query_parameters['severity'] = self._serialize.query("severity", severity, 'str') if alert_state is not None: query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') if alert_rule is not None: query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if custom_time_range is not None: query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' 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, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('AlertsSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Summary", "of", "alerts", "with", "the", "count", "each", "severity", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/alerts_operations.py#L393-L521
[ "def", "get_summary", "(", "self", ",", "groupby", ",", "include_smart_groups_count", "=", "None", ",", "target_resource", "=", "None", ",", "target_resource_type", "=", "None", ",", "target_resource_group", "=", "None", ",", "monitor_service", "=", "None", ",", "monitor_condition", "=", "None", ",", "severity", "=", "None", ",", "alert_state", "=", "None", ",", "alert_rule", "=", "None", ",", "time_range", "=", "None", ",", "custom_time_range", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "get_summary", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'subscriptionId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.subscription_id\"", ",", "self", ".", "config", ".", "subscription_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'groupby'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"groupby\"", ",", "groupby", ",", "'str'", ")", "if", "include_smart_groups_count", "is", "not", "None", ":", "query_parameters", "[", "'includeSmartGroupsCount'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"include_smart_groups_count\"", ",", "include_smart_groups_count", ",", "'bool'", ")", "if", "target_resource", "is", "not", "None", ":", "query_parameters", "[", "'targetResource'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource\"", ",", "target_resource", ",", "'str'", ")", "if", "target_resource_type", "is", "not", "None", ":", "query_parameters", "[", "'targetResourceType'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource_type\"", ",", "target_resource_type", ",", "'str'", ")", "if", "target_resource_group", "is", "not", "None", ":", "query_parameters", "[", "'targetResourceGroup'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"target_resource_group\"", ",", "target_resource_group", ",", "'str'", ")", "if", "monitor_service", "is", "not", "None", ":", "query_parameters", "[", "'monitorService'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"monitor_service\"", ",", "monitor_service", ",", "'str'", ")", "if", "monitor_condition", "is", "not", "None", ":", "query_parameters", "[", "'monitorCondition'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"monitor_condition\"", ",", "monitor_condition", ",", "'str'", ")", "if", "severity", "is", "not", "None", ":", "query_parameters", "[", "'severity'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"severity\"", ",", "severity", ",", "'str'", ")", "if", "alert_state", "is", "not", "None", ":", "query_parameters", "[", "'alertState'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"alert_state\"", ",", "alert_state", ",", "'str'", ")", "if", "alert_rule", "is", "not", "None", ":", "query_parameters", "[", "'alertRule'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"alert_rule\"", ",", "alert_rule", ",", "'str'", ")", "if", "time_range", "is", "not", "None", ":", "query_parameters", "[", "'timeRange'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"time_range\"", ",", "time_range", ",", "'str'", ")", "if", "custom_time_range", "is", "not", "None", ":", "query_parameters", "[", "'customTimeRange'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"custom_time_range\"", ",", "custom_time_range", ",", "'str'", ")", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "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", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'AlertsSummary'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SnapshotOperations.take
Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> * Free-tier subscription quota: 100 take operations per month. * S0-tier subscription quota: 100 take operations per day. :param type: User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' :type type: str or ~azure.cognitiveservices.vision.face.models.SnapshotObjectType :param object_id: User specified source object id to take snapshot from. :type object_id: str :param apply_scope: User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. :type apply_scope: list[str] :param user_data: User specified data about the snapshot for any purpose. Length should not exceed 16KB. :type user_data: 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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/snapshot_operations.py
def take( self, type, object_id, apply_scope, user_data=None, custom_headers=None, raw=False, **operation_config): """Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> * Free-tier subscription quota: 100 take operations per month. * S0-tier subscription quota: 100 take operations per day. :param type: User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' :type type: str or ~azure.cognitiveservices.vision.face.models.SnapshotObjectType :param object_id: User specified source object id to take snapshot from. :type object_id: str :param apply_scope: User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. :type apply_scope: list[str] :param user_data: User specified data about the snapshot for any purpose. Length should not exceed 16KB. :type user_data: 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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.TakeSnapshotRequest(type=type, object_id=object_id, apply_scope=apply_scope, user_data=user_data) # Construct URL url = self.take.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'TakeSnapshotRequest') # 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 [202]: raise models.APIErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'Operation-Location': 'str', }) return client_raw_response
def take( self, type, object_id, apply_scope, user_data=None, custom_headers=None, raw=False, **operation_config): """Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> * Free-tier subscription quota: 100 take operations per month. * S0-tier subscription quota: 100 take operations per day. :param type: User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' :type type: str or ~azure.cognitiveservices.vision.face.models.SnapshotObjectType :param object_id: User specified source object id to take snapshot from. :type object_id: str :param apply_scope: User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. :type apply_scope: list[str] :param user_data: User specified data about the snapshot for any purpose. Length should not exceed 16KB. :type user_data: 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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.TakeSnapshotRequest(type=type, object_id=object_id, apply_scope=apply_scope, user_data=user_data) # Construct URL url = self.take.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'TakeSnapshotRequest') # 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 [202]: raise models.APIErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'Operation-Location': 'str', }) return client_raw_response
[ "Submit", "an", "operation", "to", "take", "a", "snapshot", "of", "face", "list", "large", "face", "list", "person", "group", "or", "large", "person", "group", "with", "user", "-", "specified", "snapshot", "type", "source", "object", "id", "apply", "scope", "and", "an", "optional", "user", "data", ".", "<br", "/", ">", "The", "snapshot", "interfaces", "are", "for", "users", "to", "backup", "and", "restore", "their", "face", "data", "from", "one", "face", "subscription", "to", "another", "inside", "same", "region", "or", "across", "regions", ".", "The", "workflow", "contains", "two", "phases", "user", "first", "calls", "Snapshot", "-", "Take", "to", "create", "a", "copy", "of", "the", "source", "object", "and", "store", "it", "as", "a", "snapshot", "then", "calls", "Snapshot", "-", "Apply", "to", "paste", "the", "snapshot", "to", "target", "subscription", ".", "The", "snapshots", "are", "stored", "in", "a", "centralized", "location", "(", "per", "Azure", "instance", ")", "so", "that", "they", "can", "be", "applied", "cross", "accounts", "and", "regions", ".", "<br", "/", ">", "Taking", "snapshot", "is", "an", "asynchronous", "operation", ".", "An", "operation", "id", "can", "be", "obtained", "from", "the", "Operation", "-", "Location", "field", "in", "response", "header", "to", "be", "used", "in", "OperationStatus", "-", "Get", "for", "tracking", "the", "progress", "of", "creating", "the", "snapshot", ".", "The", "snapshot", "id", "will", "be", "included", "in", "the", "resourceLocation", "field", "in", "OperationStatus", "-", "Get", "response", "when", "the", "operation", "status", "is", "succeeded", ".", "<br", "/", ">", "Snapshot", "taking", "time", "depends", "on", "the", "number", "of", "person", "and", "face", "entries", "in", "the", "source", "object", ".", "It", "could", "be", "in", "seconds", "or", "up", "to", "several", "hours", "for", "1", "000", "000", "persons", "with", "multiple", "faces", ".", "<br", "/", ">", "Snapshots", "will", "be", "automatically", "expired", "and", "cleaned", "in", "48", "hours", "after", "it", "is", "created", "by", "Snapshot", "-", "Take", ".", "User", "can", "delete", "the", "snapshot", "using", "Snapshot", "-", "Delete", "by", "themselves", "any", "time", "before", "expiration", ".", "<br", "/", ">", "Taking", "snapshot", "for", "a", "certain", "object", "will", "not", "block", "any", "other", "operations", "against", "the", "object", ".", "All", "read", "-", "only", "operations", "(", "Get", "/", "List", "and", "Identify", "/", "FindSimilar", "/", "Verify", ")", "can", "be", "conducted", "as", "usual", ".", "For", "all", "writable", "operations", "including", "Add", "/", "Update", "/", "Delete", "the", "source", "object", "or", "its", "persons", "/", "faces", "and", "Train", "they", "are", "not", "blocked", "but", "not", "recommended", "because", "writable", "updates", "may", "not", "be", "reflected", "on", "the", "snapshot", "during", "its", "taking", ".", "After", "snapshot", "taking", "is", "completed", "all", "readable", "and", "writable", "operations", "can", "work", "as", "normal", ".", "Snapshot", "will", "also", "include", "the", "training", "results", "of", "the", "source", "object", "which", "means", "target", "subscription", "the", "snapshot", "applied", "to", "does", "not", "need", "re", "-", "train", "the", "target", "object", "before", "calling", "Identify", "/", "FindSimilar", ".", "<br", "/", ">", "*", "Free", "-", "tier", "subscription", "quota", ":", "100", "take", "operations", "per", "month", ".", "*", "S0", "-", "tier", "subscription", "quota", ":", "100", "take", "operations", "per", "day", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/snapshot_operations.py#L36-L134
[ "def", "take", "(", "self", ",", "type", ",", "object_id", ",", "apply_scope", ",", "user_data", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "body", "=", "models", ".", "TakeSnapshotRequest", "(", "type", "=", "type", ",", "object_id", "=", "object_id", ",", "apply_scope", "=", "apply_scope", ",", "user_data", "=", "user_data", ")", "# Construct URL", "url", "=", "self", ".", "take", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "body", ",", "'TakeSnapshotRequest'", ")", "# 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", "[", "202", "]", ":", "raise", "models", ".", "APIErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "{", "'Operation-Location'", ":", "'str'", ",", "}", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
SnapshotOperations.apply
Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> * Free-tier subscription quota: 100 apply operations per month. * S0-tier subscription quota: 100 apply operations per day. :param snapshot_id: Id referencing a particular snapshot. :type snapshot_id: str :param object_id: User specified target object id to be created from the snapshot. :type object_id: str :param mode: Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' :type mode: str or ~azure.cognitiveservices.vision.face.models.SnapshotApplyMode :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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/snapshot_operations.py
def apply( self, snapshot_id, object_id, mode="CreateNew", custom_headers=None, raw=False, **operation_config): """Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> * Free-tier subscription quota: 100 apply operations per month. * S0-tier subscription quota: 100 apply operations per day. :param snapshot_id: Id referencing a particular snapshot. :type snapshot_id: str :param object_id: User specified target object id to be created from the snapshot. :type object_id: str :param mode: Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' :type mode: str or ~azure.cognitiveservices.vision.face.models.SnapshotApplyMode :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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.ApplySnapshotRequest(object_id=object_id, mode=mode) # Construct URL url = self.apply.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'snapshotId': self._serialize.url("snapshot_id", snapshot_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 custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'ApplySnapshotRequest') # 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 [202]: raise models.APIErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'Operation-Location': 'str', }) return client_raw_response
def apply( self, snapshot_id, object_id, mode="CreateNew", custom_headers=None, raw=False, **operation_config): """Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> * Free-tier subscription quota: 100 apply operations per month. * S0-tier subscription quota: 100 apply operations per day. :param snapshot_id: Id referencing a particular snapshot. :type snapshot_id: str :param object_id: User specified target object id to be created from the snapshot. :type object_id: str :param mode: Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' :type mode: str or ~azure.cognitiveservices.vision.face.models.SnapshotApplyMode :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:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.ApplySnapshotRequest(object_id=object_id, mode=mode) # Construct URL url = self.apply.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'snapshotId': self._serialize.url("snapshot_id", snapshot_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 custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'ApplySnapshotRequest') # 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 [202]: raise models.APIErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'Operation-Location': 'str', }) return client_raw_response
[ "Submit", "an", "operation", "to", "apply", "a", "snapshot", "to", "current", "subscription", ".", "For", "each", "snapshot", "only", "subscriptions", "included", "in", "the", "applyScope", "of", "Snapshot", "-", "Take", "can", "apply", "it", ".", "<br", "/", ">", "The", "snapshot", "interfaces", "are", "for", "users", "to", "backup", "and", "restore", "their", "face", "data", "from", "one", "face", "subscription", "to", "another", "inside", "same", "region", "or", "across", "regions", ".", "The", "workflow", "contains", "two", "phases", "user", "first", "calls", "Snapshot", "-", "Take", "to", "create", "a", "copy", "of", "the", "source", "object", "and", "store", "it", "as", "a", "snapshot", "then", "calls", "Snapshot", "-", "Apply", "to", "paste", "the", "snapshot", "to", "target", "subscription", ".", "The", "snapshots", "are", "stored", "in", "a", "centralized", "location", "(", "per", "Azure", "instance", ")", "so", "that", "they", "can", "be", "applied", "cross", "accounts", "and", "regions", ".", "<br", "/", ">", "Applying", "snapshot", "is", "an", "asynchronous", "operation", ".", "An", "operation", "id", "can", "be", "obtained", "from", "the", "Operation", "-", "Location", "field", "in", "response", "header", "to", "be", "used", "in", "OperationStatus", "-", "Get", "for", "tracking", "the", "progress", "of", "applying", "the", "snapshot", ".", "The", "target", "object", "id", "will", "be", "included", "in", "the", "resourceLocation", "field", "in", "OperationStatus", "-", "Get", "response", "when", "the", "operation", "status", "is", "succeeded", ".", "<br", "/", ">", "Snapshot", "applying", "time", "depends", "on", "the", "number", "of", "person", "and", "face", "entries", "in", "the", "snapshot", "object", ".", "It", "could", "be", "in", "seconds", "or", "up", "to", "1", "hour", "for", "1", "000", "000", "persons", "with", "multiple", "faces", ".", "<br", "/", ">", "Snapshots", "will", "be", "automatically", "expired", "and", "cleaned", "in", "48", "hours", "after", "it", "is", "created", "by", "Snapshot", "-", "Take", ".", "So", "the", "target", "subscription", "is", "required", "to", "apply", "the", "snapshot", "in", "48", "hours", "since", "its", "creation", ".", "<br", "/", ">", "Applying", "a", "snapshot", "will", "not", "block", "any", "other", "operations", "against", "the", "target", "object", "however", "it", "is", "not", "recommended", "because", "the", "correctness", "cannot", "be", "guaranteed", "during", "snapshot", "applying", ".", "After", "snapshot", "applying", "is", "completed", "all", "operations", "towards", "the", "target", "object", "can", "work", "as", "normal", ".", "Snapshot", "also", "includes", "the", "training", "results", "of", "the", "source", "object", "which", "means", "target", "subscription", "the", "snapshot", "applied", "to", "does", "not", "need", "re", "-", "train", "the", "target", "object", "before", "calling", "Identify", "/", "FindSimilar", ".", "<br", "/", ">", "One", "snapshot", "can", "be", "applied", "multiple", "times", "in", "parallel", "while", "currently", "only", "CreateNew", "apply", "mode", "is", "supported", "which", "means", "the", "apply", "operation", "will", "fail", "if", "target", "subscription", "already", "contains", "an", "object", "of", "same", "type", "and", "using", "the", "same", "objectId", ".", "Users", "can", "specify", "the", "objectId", "in", "request", "body", "to", "avoid", "such", "conflicts", ".", "<br", "/", ">", "*", "Free", "-", "tier", "subscription", "quota", ":", "100", "apply", "operations", "per", "month", ".", "*", "S0", "-", "tier", "subscription", "quota", ":", "100", "apply", "operations", "per", "day", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/snapshot_operations.py#L366-L463
[ "def", "apply", "(", "self", ",", "snapshot_id", ",", "object_id", ",", "mode", "=", "\"CreateNew\"", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "body", "=", "models", ".", "ApplySnapshotRequest", "(", "object_id", "=", "object_id", ",", "mode", "=", "mode", ")", "# Construct URL", "url", "=", "self", ".", "apply", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", ",", "'snapshotId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"snapshot_id\"", ",", "snapshot_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", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "body", ",", "'ApplySnapshotRequest'", ")", "# 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", "[", "202", "]", ":", "raise", "models", ".", "APIErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "{", "'Operation-Location'", ":", "'str'", ",", "}", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
PredictionOperations.resolve
Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters. :param app_id: The LUIS application ID (Guid). :type app_id: str :param query: The utterance to predict. :type query: str :param timezone_offset: The timezone offset for the location of the request. :type timezone_offset: float :param verbose: If true, return all intents instead of just the top scoring intent. :type verbose: bool :param staging: Use the staging endpoint slot. :type staging: bool :param spell_check: Enable spell checking. :type spell_check: bool :param bing_spell_check_subscription_key: The subscription key to use when enabling Bing spell check :type bing_spell_check_subscription_key: str :param log: Log query (default is true) :type log: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: LuisResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.luis.runtime.models.LuisResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.language.luis.runtime.models.APIErrorException>`
azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/prediction_operations.py
def resolve( self, app_id, query, timezone_offset=None, verbose=None, staging=None, spell_check=None, bing_spell_check_subscription_key=None, log=None, custom_headers=None, raw=False, **operation_config): """Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters. :param app_id: The LUIS application ID (Guid). :type app_id: str :param query: The utterance to predict. :type query: str :param timezone_offset: The timezone offset for the location of the request. :type timezone_offset: float :param verbose: If true, return all intents instead of just the top scoring intent. :type verbose: bool :param staging: Use the staging endpoint slot. :type staging: bool :param spell_check: Enable spell checking. :type spell_check: bool :param bing_spell_check_subscription_key: The subscription key to use when enabling Bing spell check :type bing_spell_check_subscription_key: str :param log: Log query (default is true) :type log: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: LuisResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.luis.runtime.models.LuisResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.language.luis.runtime.models.APIErrorException>` """ # Construct URL url = self.resolve.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if timezone_offset is not None: query_parameters['timezoneOffset'] = self._serialize.query("timezone_offset", timezone_offset, 'float') if verbose is not None: query_parameters['verbose'] = self._serialize.query("verbose", verbose, 'bool') if staging is not None: query_parameters['staging'] = self._serialize.query("staging", staging, 'bool') if spell_check is not None: query_parameters['spellCheck'] = self._serialize.query("spell_check", spell_check, 'bool') if bing_spell_check_subscription_key is not None: query_parameters['bing-spell-check-subscription-key'] = self._serialize.query("bing_spell_check_subscription_key", bing_spell_check_subscription_key, 'str') if log is not None: query_parameters['log'] = self._serialize.query("log", log, 'bool') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(query, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('LuisResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def resolve( self, app_id, query, timezone_offset=None, verbose=None, staging=None, spell_check=None, bing_spell_check_subscription_key=None, log=None, custom_headers=None, raw=False, **operation_config): """Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters. :param app_id: The LUIS application ID (Guid). :type app_id: str :param query: The utterance to predict. :type query: str :param timezone_offset: The timezone offset for the location of the request. :type timezone_offset: float :param verbose: If true, return all intents instead of just the top scoring intent. :type verbose: bool :param staging: Use the staging endpoint slot. :type staging: bool :param spell_check: Enable spell checking. :type spell_check: bool :param bing_spell_check_subscription_key: The subscription key to use when enabling Bing spell check :type bing_spell_check_subscription_key: str :param log: Log query (default is true) :type log: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: LuisResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.luis.runtime.models.LuisResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.language.luis.runtime.models.APIErrorException>` """ # Construct URL url = self.resolve.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if timezone_offset is not None: query_parameters['timezoneOffset'] = self._serialize.query("timezone_offset", timezone_offset, 'float') if verbose is not None: query_parameters['verbose'] = self._serialize.query("verbose", verbose, 'bool') if staging is not None: query_parameters['staging'] = self._serialize.query("staging", staging, 'bool') if spell_check is not None: query_parameters['spellCheck'] = self._serialize.query("spell_check", spell_check, 'bool') if bing_spell_check_subscription_key is not None: query_parameters['bing-spell-check-subscription-key'] = self._serialize.query("bing_spell_check_subscription_key", bing_spell_check_subscription_key, 'str') if log is not None: query_parameters['log'] = self._serialize.query("log", log, 'bool') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(query, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('LuisResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Gets", "predictions", "for", "a", "given", "utterance", "in", "the", "form", "of", "intents", "and", "entities", ".", "The", "current", "maximum", "query", "size", "is", "500", "characters", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/prediction_operations.py#L36-L121
[ "def", "resolve", "(", "self", ",", "app_id", ",", "query", ",", "timezone_offset", "=", "None", ",", "verbose", "=", "None", ",", "staging", "=", "None", ",", "spell_check", "=", "None", ",", "bing_spell_check_subscription_key", "=", "None", ",", "log", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "resolve", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", ",", "'appId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"app_id\"", ",", "app_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "timezone_offset", "is", "not", "None", ":", "query_parameters", "[", "'timezoneOffset'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timezone_offset\"", ",", "timezone_offset", ",", "'float'", ")", "if", "verbose", "is", "not", "None", ":", "query_parameters", "[", "'verbose'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"verbose\"", ",", "verbose", ",", "'bool'", ")", "if", "staging", "is", "not", "None", ":", "query_parameters", "[", "'staging'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"staging\"", ",", "staging", ",", "'bool'", ")", "if", "spell_check", "is", "not", "None", ":", "query_parameters", "[", "'spellCheck'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"spell_check\"", ",", "spell_check", ",", "'bool'", ")", "if", "bing_spell_check_subscription_key", "is", "not", "None", ":", "query_parameters", "[", "'bing-spell-check-subscription-key'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"bing_spell_check_subscription_key\"", ",", "bing_spell_check_subscription_key", ",", "'str'", ")", "if", "log", "is", "not", "None", ":", "query_parameters", "[", "'log'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"log\"", ",", "log", ",", "'bool'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "query", ",", "'str'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "APIErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'LuisResult'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
MixedRealityClient.check_name_availability_local
Check Name Availability for global uniqueness. :param location: The location in which uniqueness will be verified. :type location: str :param name: Resource Name To Verify :type name: str :param type: Fully qualified resource type which includes provider namespace :type type: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.mixedreality.models.CheckNameAvailabilityResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.mixedreality.models.ErrorResponseException>`
azure-mgmt-mixedreality/azure/mgmt/mixedreality/mixed_reality_client.py
def check_name_availability_local( self, location, name, type, custom_headers=None, raw=False, **operation_config): """Check Name Availability for global uniqueness. :param location: The location in which uniqueness will be verified. :type location: str :param name: Resource Name To Verify :type name: str :param type: Fully qualified resource type which includes provider namespace :type type: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.mixedreality.models.CheckNameAvailabilityResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.mixedreality.models.ErrorResponseException>` """ check_name_availability = models.CheckNameAvailabilityRequest(name=name, type=type) # Construct URL url = self.check_name_availability_local.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'location': self._serialize.url("location", location, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(check_name_availability, 'CheckNameAvailabilityRequest') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def check_name_availability_local( self, location, name, type, custom_headers=None, raw=False, **operation_config): """Check Name Availability for global uniqueness. :param location: The location in which uniqueness will be verified. :type location: str :param name: Resource Name To Verify :type name: str :param type: Fully qualified resource type which includes provider namespace :type type: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: CheckNameAvailabilityResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.mixedreality.models.CheckNameAvailabilityResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.mixedreality.models.ErrorResponseException>` """ check_name_availability = models.CheckNameAvailabilityRequest(name=name, type=type) # Construct URL url = self.check_name_availability_local.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'location': self._serialize.url("location", location, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(check_name_availability, 'CheckNameAvailabilityRequest') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Check", "Name", "Availability", "for", "global", "uniqueness", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-mixedreality/azure/mgmt/mixedreality/mixed_reality_client.py#L90-L157
[ "def", "check_name_availability_local", "(", "self", ",", "location", ",", "name", ",", "type", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "check_name_availability", "=", "models", ".", "CheckNameAvailabilityRequest", "(", "name", "=", "name", ",", "type", "=", "type", ")", "# Construct URL", "url", "=", "self", ".", "check_name_availability_local", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'subscriptionId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.subscription_id\"", ",", "self", ".", "config", ".", "subscription_id", ",", "'str'", ")", ",", "'location'", ":", "self", ".", "_serialize", ".", "url", "(", "\"location\"", ",", "location", ",", "'str'", ",", "max_length", "=", "90", ",", "min_length", "=", "1", ",", "pattern", "=", "r'^[-\\w\\._\\(\\)]+$'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'x-ms-client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "check_name_availability", ",", "'CheckNameAvailabilityRequest'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'CheckNameAvailabilityResponse'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ImagesOperations.details
The Image Detail Search API lets you search on Bing and get back insights about an image, such as webpages that include the image. This section provides technical details about the query parameters and headers that you use to request insights of images and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the Web for Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web). :param query: The user's search query term. The term cannot be empty. The term may contain [Bing Advanced Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance of an insights query (see [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), you should always include the user's query term. Use this parameter only with the Image Search API.Do not specify this parameter when calling the Trending Images API. :type query: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param content_type: Optional request header. If you set the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter to RecognizedEntities, you may specify the binary of an image in the body of a POST request. If you specify the image in the body of a POST request, you must specify this header and set its value to multipart/form-data. The maximum image size is 1 MB. :type content_type: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param crop_bottom: The bottom coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_bottom: float :param crop_left: The left coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_left: float :param crop_right: The right coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_right: float :param crop_top: The top coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_top: float :param crop_type: The crop type to use when cropping the image based on the coordinates specified in the cal, cat, car, and cab parameters. The following are the possible values. 0: Rectangular (default). Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. Possible values include: 'Rectangular' :type crop_type: str or ~azure.cognitiveservices.search.imagesearch.models.ImageCropType :param country_code: A 2-character country code of the country where the results come from. For a list of possible values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). If you set this parameter, you must also specify the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) query parameter are mutually exclusive—do not specify both. :type country_code: str :param id: An ID that uniquely identifies an image. Use this parameter to ensure that the specified image is the first image in the list of images that Bing returns. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's imageId field contains the ID that you set this parameter to. :type id: str :param image_url: The URL of an image that you want to get insights of. Use this parameter as an alternative to using the insightsToken parameter to specify the image. You may also specify the image by placing the binary of the image in the body of a POST request. If you use the binary option, see the [Content-Type](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#contenttype) header. The maximum supported image size is 1 MB. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type image_url: str :param insights_token: An image token. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's [imageInsightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image-imageinsightstoken) contains the token. Specify this parameter to get additional information about an image, such as a caption or shopping source. For a list of the additional information about an image that you can get, see the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type insights_token: str :param modules: A comma-delimited list of insights to request. The following are the possible case-insensitive values. All: Return all insights, if available, except RecognizedEntities. BRQ: Best representative query. The query term that best describes the image. Caption: A caption that provides information about the image. If the caption contains entities, the response may include links to images of those entities. Collections: A list of related images. Recipes: A list of recipes for cooking the food shown in the images. PagesIncluding: A list of webpages that include the image. RecognizedEntities: A list of entities (people) that were recognized in the image. NOTE: You may not specify this module with any other module. If you specify it with other modules, the response doesn't include recognized entities. RelatedSearches: A list of related searches made by others. ShoppingSources: A list of merchants where you can buy related offerings. SimilarImages: A list of images that are visually similar to the original image. SimilarProducts: A list of images that contain a product that is similar to a product found in the original image. Tags: Provides characteristics of the type of content found in the image. For example, if the image is of a person, the tags might indicate the person's gender and type of clothes they're wearing. If you specify a module and there is no data for the module, the response object doesn't include the related field. For example, if you specify Caption and it does not exist, the response doesn't include the imageCaption field. To include related searches, the request must include the original query string. Although the original query string is not required for similar images or products, you should always include it because it can help improve relevance and the results. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type modules: list[str or ~azure.cognitiveservices.search.imagesearch.models.ImageInsightModule] :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: ImageInsights or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.ImageInsights or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>`
azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py
def details( self, query, accept_language=None, content_type=None, user_agent=None, client_id=None, client_ip=None, location=None, crop_bottom=None, crop_left=None, crop_right=None, crop_top=None, crop_type=None, country_code=None, id=None, image_url=None, insights_token=None, modules=None, market=None, safe_search=None, set_lang=None, custom_headers=None, raw=False, **operation_config): """The Image Detail Search API lets you search on Bing and get back insights about an image, such as webpages that include the image. This section provides technical details about the query parameters and headers that you use to request insights of images and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the Web for Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web). :param query: The user's search query term. The term cannot be empty. The term may contain [Bing Advanced Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance of an insights query (see [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), you should always include the user's query term. Use this parameter only with the Image Search API.Do not specify this parameter when calling the Trending Images API. :type query: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param content_type: Optional request header. If you set the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter to RecognizedEntities, you may specify the binary of an image in the body of a POST request. If you specify the image in the body of a POST request, you must specify this header and set its value to multipart/form-data. The maximum image size is 1 MB. :type content_type: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param crop_bottom: The bottom coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_bottom: float :param crop_left: The left coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_left: float :param crop_right: The right coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_right: float :param crop_top: The top coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_top: float :param crop_type: The crop type to use when cropping the image based on the coordinates specified in the cal, cat, car, and cab parameters. The following are the possible values. 0: Rectangular (default). Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. Possible values include: 'Rectangular' :type crop_type: str or ~azure.cognitiveservices.search.imagesearch.models.ImageCropType :param country_code: A 2-character country code of the country where the results come from. For a list of possible values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). If you set this parameter, you must also specify the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) query parameter are mutually exclusive—do not specify both. :type country_code: str :param id: An ID that uniquely identifies an image. Use this parameter to ensure that the specified image is the first image in the list of images that Bing returns. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's imageId field contains the ID that you set this parameter to. :type id: str :param image_url: The URL of an image that you want to get insights of. Use this parameter as an alternative to using the insightsToken parameter to specify the image. You may also specify the image by placing the binary of the image in the body of a POST request. If you use the binary option, see the [Content-Type](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#contenttype) header. The maximum supported image size is 1 MB. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type image_url: str :param insights_token: An image token. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's [imageInsightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image-imageinsightstoken) contains the token. Specify this parameter to get additional information about an image, such as a caption or shopping source. For a list of the additional information about an image that you can get, see the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type insights_token: str :param modules: A comma-delimited list of insights to request. The following are the possible case-insensitive values. All: Return all insights, if available, except RecognizedEntities. BRQ: Best representative query. The query term that best describes the image. Caption: A caption that provides information about the image. If the caption contains entities, the response may include links to images of those entities. Collections: A list of related images. Recipes: A list of recipes for cooking the food shown in the images. PagesIncluding: A list of webpages that include the image. RecognizedEntities: A list of entities (people) that were recognized in the image. NOTE: You may not specify this module with any other module. If you specify it with other modules, the response doesn't include recognized entities. RelatedSearches: A list of related searches made by others. ShoppingSources: A list of merchants where you can buy related offerings. SimilarImages: A list of images that are visually similar to the original image. SimilarProducts: A list of images that contain a product that is similar to a product found in the original image. Tags: Provides characteristics of the type of content found in the image. For example, if the image is of a person, the tags might indicate the person's gender and type of clothes they're wearing. If you specify a module and there is no data for the module, the response object doesn't include the related field. For example, if you specify Caption and it does not exist, the response doesn't include the imageCaption field. To include related searches, the request must include the original query string. Although the original query string is not required for similar images or products, you should always include it because it can help improve relevance and the results. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type modules: list[str or ~azure.cognitiveservices.search.imagesearch.models.ImageInsightModule] :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: ImageInsights or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.ImageInsights or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>` """ # Construct URL url = self.details.metadata['url'] # Construct parameters query_parameters = {} if crop_bottom is not None: query_parameters['cab'] = self._serialize.query("crop_bottom", crop_bottom, 'float') if crop_left is not None: query_parameters['cal'] = self._serialize.query("crop_left", crop_left, 'float') if crop_right is not None: query_parameters['car'] = self._serialize.query("crop_right", crop_right, 'float') if crop_top is not None: query_parameters['cat'] = self._serialize.query("crop_top", crop_top, 'float') if crop_type is not None: query_parameters['ct'] = self._serialize.query("crop_type", crop_type, 'str') if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if id is not None: query_parameters['id'] = self._serialize.query("id", id, 'str') if image_url is not None: query_parameters['imgUrl'] = self._serialize.query("image_url", image_url, 'str') if insights_token is not None: query_parameters['insightsToken'] = self._serialize.query("insights_token", insights_token, 'str') if modules is not None: query_parameters['modules'] = self._serialize.query("modules", modules, '[str]', div=',') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') query_parameters['q'] = self._serialize.query("query", query, 'str') if safe_search is not None: query_parameters['safeSearch'] = self._serialize.query("safe_search", safe_search, 'str') if set_lang is not None: query_parameters['setLang'] = self._serialize.query("set_lang", set_lang, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("self.x_bing_apis_sdk", self.x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if content_type is not None: header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, '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.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageInsights', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def details( self, query, accept_language=None, content_type=None, user_agent=None, client_id=None, client_ip=None, location=None, crop_bottom=None, crop_left=None, crop_right=None, crop_top=None, crop_type=None, country_code=None, id=None, image_url=None, insights_token=None, modules=None, market=None, safe_search=None, set_lang=None, custom_headers=None, raw=False, **operation_config): """The Image Detail Search API lets you search on Bing and get back insights about an image, such as webpages that include the image. This section provides technical details about the query parameters and headers that you use to request insights of images and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the Web for Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web). :param query: The user's search query term. The term cannot be empty. The term may contain [Bing Advanced Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance of an insights query (see [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), you should always include the user's query term. Use this parameter only with the Image Search API.Do not specify this parameter when calling the Trending Images API. :type query: str :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param content_type: Optional request header. If you set the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter to RecognizedEntities, you may specify the binary of an image in the body of a POST request. If you specify the image in the body of a POST request, you must specify this header and set its value to multipart/form-data. The maximum image size is 1 MB. :type content_type: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param crop_bottom: The bottom coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_bottom: float :param crop_left: The left coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_left: float :param crop_right: The right coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_right: float :param crop_top: The top coordinate of the region to crop. The coordinate is a fractional value of the original image's height and is measured from the top, left corner of the image. Specify the coordinate as a value from 0.0 through 1.0. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type crop_top: float :param crop_type: The crop type to use when cropping the image based on the coordinates specified in the cal, cat, car, and cab parameters. The following are the possible values. 0: Rectangular (default). Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. Possible values include: 'Rectangular' :type crop_type: str or ~azure.cognitiveservices.search.imagesearch.models.ImageCropType :param country_code: A 2-character country code of the country where the results come from. For a list of possible values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). If you set this parameter, you must also specify the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) query parameter are mutually exclusive—do not specify both. :type country_code: str :param id: An ID that uniquely identifies an image. Use this parameter to ensure that the specified image is the first image in the list of images that Bing returns. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's imageId field contains the ID that you set this parameter to. :type id: str :param image_url: The URL of an image that you want to get insights of. Use this parameter as an alternative to using the insightsToken parameter to specify the image. You may also specify the image by placing the binary of the image in the body of a POST request. If you use the binary option, see the [Content-Type](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#contenttype) header. The maximum supported image size is 1 MB. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type image_url: str :param insights_token: An image token. The [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) object's [imageInsightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image-imageinsightstoken) contains the token. Specify this parameter to get additional information about an image, such as a caption or shopping source. For a list of the additional information about an image that you can get, see the [modules](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#modulesrequested) query parameter. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type insights_token: str :param modules: A comma-delimited list of insights to request. The following are the possible case-insensitive values. All: Return all insights, if available, except RecognizedEntities. BRQ: Best representative query. The query term that best describes the image. Caption: A caption that provides information about the image. If the caption contains entities, the response may include links to images of those entities. Collections: A list of related images. Recipes: A list of recipes for cooking the food shown in the images. PagesIncluding: A list of webpages that include the image. RecognizedEntities: A list of entities (people) that were recognized in the image. NOTE: You may not specify this module with any other module. If you specify it with other modules, the response doesn't include recognized entities. RelatedSearches: A list of related searches made by others. ShoppingSources: A list of merchants where you can buy related offerings. SimilarImages: A list of images that are visually similar to the original image. SimilarProducts: A list of images that contain a product that is similar to a product found in the original image. Tags: Provides characteristics of the type of content found in the image. For example, if the image is of a person, the tags might indicate the person's gender and type of clothes they're wearing. If you specify a module and there is no data for the module, the response object doesn't include the related field. For example, if you specify Caption and it does not exist, the response doesn't include the imageCaption field. To include related searches, the request must include the original query string. Although the original query string is not required for similar images or products, you should always include it because it can help improve relevance and the results. Use this parameter only with the Insights API. Do not specify this parameter when calling the Images, Trending Images, or Web Search APIs. :type modules: list[str or ~azure.cognitiveservices.search.imagesearch.models.ImageInsightModule] :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: ImageInsights or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.ImageInsights or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>` """ # Construct URL url = self.details.metadata['url'] # Construct parameters query_parameters = {} if crop_bottom is not None: query_parameters['cab'] = self._serialize.query("crop_bottom", crop_bottom, 'float') if crop_left is not None: query_parameters['cal'] = self._serialize.query("crop_left", crop_left, 'float') if crop_right is not None: query_parameters['car'] = self._serialize.query("crop_right", crop_right, 'float') if crop_top is not None: query_parameters['cat'] = self._serialize.query("crop_top", crop_top, 'float') if crop_type is not None: query_parameters['ct'] = self._serialize.query("crop_type", crop_type, 'str') if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if id is not None: query_parameters['id'] = self._serialize.query("id", id, 'str') if image_url is not None: query_parameters['imgUrl'] = self._serialize.query("image_url", image_url, 'str') if insights_token is not None: query_parameters['insightsToken'] = self._serialize.query("insights_token", insights_token, 'str') if modules is not None: query_parameters['modules'] = self._serialize.query("modules", modules, '[str]', div=',') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') query_parameters['q'] = self._serialize.query("query", query, 'str') if safe_search is not None: query_parameters['safeSearch'] = self._serialize.query("safe_search", safe_search, 'str') if set_lang is not None: query_parameters['setLang'] = self._serialize.query("set_lang", set_lang, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("self.x_bing_apis_sdk", self.x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if content_type is not None: header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, '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.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageInsights', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "The", "Image", "Detail", "Search", "API", "lets", "you", "search", "on", "Bing", "and", "get", "back", "insights", "about", "an", "image", "such", "as", "webpages", "that", "include", "the", "image", ".", "This", "section", "provides", "technical", "details", "about", "the", "query", "parameters", "and", "headers", "that", "you", "use", "to", "request", "insights", "of", "images", "and", "the", "JSON", "response", "objects", "that", "contain", "them", ".", "For", "examples", "that", "show", "how", "to", "make", "requests", "see", "[", "Searching", "the", "Web", "for", "Images", "]", "(", "https", ":", "//", "docs", ".", "microsoft", ".", "com", "/", "azure", "/", "cognitive", "-", "services", "/", "bing", "-", "image", "-", "search", "/", "search", "-", "the", "-", "web", ")", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py#L499-L897
[ "def", "details", "(", "self", ",", "query", ",", "accept_language", "=", "None", ",", "content_type", "=", "None", ",", "user_agent", "=", "None", ",", "client_id", "=", "None", ",", "client_ip", "=", "None", ",", "location", "=", "None", ",", "crop_bottom", "=", "None", ",", "crop_left", "=", "None", ",", "crop_right", "=", "None", ",", "crop_top", "=", "None", ",", "crop_type", "=", "None", ",", "country_code", "=", "None", ",", "id", "=", "None", ",", "image_url", "=", "None", ",", "insights_token", "=", "None", ",", "modules", "=", "None", ",", "market", "=", "None", ",", "safe_search", "=", "None", ",", "set_lang", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "details", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "crop_bottom", "is", "not", "None", ":", "query_parameters", "[", "'cab'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"crop_bottom\"", ",", "crop_bottom", ",", "'float'", ")", "if", "crop_left", "is", "not", "None", ":", "query_parameters", "[", "'cal'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"crop_left\"", ",", "crop_left", ",", "'float'", ")", "if", "crop_right", "is", "not", "None", ":", "query_parameters", "[", "'car'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"crop_right\"", ",", "crop_right", ",", "'float'", ")", "if", "crop_top", "is", "not", "None", ":", "query_parameters", "[", "'cat'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"crop_top\"", ",", "crop_top", ",", "'float'", ")", "if", "crop_type", "is", "not", "None", ":", "query_parameters", "[", "'ct'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"crop_type\"", ",", "crop_type", ",", "'str'", ")", "if", "country_code", "is", "not", "None", ":", "query_parameters", "[", "'cc'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"country_code\"", ",", "country_code", ",", "'str'", ")", "if", "id", "is", "not", "None", ":", "query_parameters", "[", "'id'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"id\"", ",", "id", ",", "'str'", ")", "if", "image_url", "is", "not", "None", ":", "query_parameters", "[", "'imgUrl'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"image_url\"", ",", "image_url", ",", "'str'", ")", "if", "insights_token", "is", "not", "None", ":", "query_parameters", "[", "'insightsToken'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"insights_token\"", ",", "insights_token", ",", "'str'", ")", "if", "modules", "is", "not", "None", ":", "query_parameters", "[", "'modules'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"modules\"", ",", "modules", ",", "'[str]'", ",", "div", "=", "','", ")", "if", "market", "is", "not", "None", ":", "query_parameters", "[", "'mkt'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"market\"", ",", "market", ",", "'str'", ")", "query_parameters", "[", "'q'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"query\"", ",", "query", ",", "'str'", ")", "if", "safe_search", "is", "not", "None", ":", "query_parameters", "[", "'safeSearch'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"safe_search\"", ",", "safe_search", ",", "'str'", ")", "if", "set_lang", "is", "not", "None", ":", "query_parameters", "[", "'setLang'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"set_lang\"", ",", "set_lang", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "header_parameters", "[", "'X-BingApis-SDK'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.x_bing_apis_sdk\"", ",", "self", ".", "x_bing_apis_sdk", ",", "'str'", ")", "if", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'Accept-Language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"accept_language\"", ",", "accept_language", ",", "'str'", ")", "if", "content_type", "is", "not", "None", ":", "header_parameters", "[", "'Content-Type'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"content_type\"", ",", "content_type", ",", "'str'", ")", "if", "user_agent", "is", "not", "None", ":", "header_parameters", "[", "'User-Agent'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"user_agent\"", ",", "user_agent", ",", "'str'", ")", "if", "client_id", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientID'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_id\"", ",", "client_id", ",", "'str'", ")", "if", "client_ip", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientIP'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_ip\"", ",", "client_ip", ",", "'str'", ")", "if", "location", "is", "not", "None", ":", "header_parameters", "[", "'X-Search-Location'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"location\"", ",", "location", ",", "'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", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'ImageInsights'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
ImagesOperations.trending
The Image Trending Search API lets you search on Bing and get back a list of images that are trending based on search requests made by others. The images are broken out into different categories. For example, Popular People Searches. For a list of markets that support trending images, see [Trending Images](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/trending-images). :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States, Canada, Australia, and China markets. If you specify this query parameter, it must be set to us, ca, au, or cn. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: TrendingImages or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.TrendingImages or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>`
azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py
def trending( self, accept_language=None, user_agent=None, client_id=None, client_ip=None, location=None, country_code=None, market=None, safe_search=None, set_lang=None, custom_headers=None, raw=False, **operation_config): """The Image Trending Search API lets you search on Bing and get back a list of images that are trending based on search requests made by others. The images are broken out into different categories. For example, Popular People Searches. For a list of markets that support trending images, see [Trending Images](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/trending-images). :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States, Canada, Australia, and China markets. If you specify this query parameter, it must be set to us, ca, au, or cn. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: TrendingImages or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.TrendingImages or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>` """ # Construct URL url = self.trending.metadata['url'] # Construct parameters query_parameters = {} if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') if safe_search is not None: query_parameters['safeSearch'] = self._serialize.query("safe_search", safe_search, 'str') if set_lang is not None: query_parameters['setLang'] = self._serialize.query("set_lang", set_lang, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("self.x_bing_apis_sdk", self.x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, '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.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('TrendingImages', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def trending( self, accept_language=None, user_agent=None, client_id=None, client_ip=None, location=None, country_code=None, market=None, safe_search=None, set_lang=None, custom_headers=None, raw=False, **operation_config): """The Image Trending Search API lets you search on Bing and get back a list of images that are trending based on search requests made by others. The images are broken out into different categories. For example, Popular People Searches. For a list of markets that support trending images, see [Trending Images](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/trending-images). :param accept_language: A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter. To determine the market to return results for, Bing uses the first supported language it finds from the list and combines it with the cc parameter value. If the list does not include a supported language, Bing finds the closest language and market that supports the request or it uses an aggregated or default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use this header and the cc query parameter only if you specify multiple languages. Otherwise, use the [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) query parameters. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Any links to Bing.com properties in the response objects apply the specified language. :type accept_language: str :param user_agent: The user agent originating the request. Bing uses the user agent to provide mobile users with an optimized experience. Although optional, you are encouraged to always specify this header. The user-agent should be the same string that any commonly used browser sends. For information about user agents, see [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 :type user_agent: str :param client_id: Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. :type client_id: str :param client_ip: The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. :type client_ip: str :param location: A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States, Canada, Australia, and China markets. If you specify this query parameter, it must be set to us, ca, au, or cn. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. :type country_code: str :param market: The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. For a list of possible market values, see [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in [Market Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query parameter are mutually exclusive—do not specify both. :type market: str :param safe_search: Filter images for adult content. The following are the possible filter values. Off: May return images with adult content. If the request is through the Image Search API, the response includes thumbnail images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search API, the response doesn't include images with adult content. If the request is through the Web Search API, the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do not return images with adult content. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' :type safe_search: str or ~azure.cognitiveservices.search.imagesearch.models.SafeSearch :param set_lang: The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) header are mutually exclusive; do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. :type set_lang: 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: TrendingImages or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.search.imagesearch.models.TrendingImages or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.search.imagesearch.models.ErrorResponseException>` """ # Construct URL url = self.trending.metadata['url'] # Construct parameters query_parameters = {} if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if market is not None: query_parameters['mkt'] = self._serialize.query("market", market, 'str') if safe_search is not None: query_parameters['safeSearch'] = self._serialize.query("safe_search", safe_search, 'str') if set_lang is not None: query_parameters['setLang'] = self._serialize.query("set_lang", set_lang, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['X-BingApis-SDK'] = self._serialize.header("self.x_bing_apis_sdk", self.x_bing_apis_sdk, 'str') if accept_language is not None: header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str') if user_agent is not None: header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str') if client_id is not None: header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str') if client_ip is not None: header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str') if location is not None: header_parameters['X-Search-Location'] = self._serialize.header("location", location, '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.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('TrendingImages', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "The", "Image", "Trending", "Search", "API", "lets", "you", "search", "on", "Bing", "and", "get", "back", "a", "list", "of", "images", "that", "are", "trending", "based", "on", "search", "requests", "made", "by", "others", ".", "The", "images", "are", "broken", "out", "into", "different", "categories", ".", "For", "example", "Popular", "People", "Searches", ".", "For", "a", "list", "of", "markets", "that", "support", "trending", "images", "see", "[", "Trending", "Images", "]", "(", "https", ":", "//", "docs", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "azure", "/", "cognitive", "-", "services", "/", "bing", "-", "image", "-", "search", "/", "trending", "-", "images", ")", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py#L900-L1159
[ "def", "trending", "(", "self", ",", "accept_language", "=", "None", ",", "user_agent", "=", "None", ",", "client_id", "=", "None", ",", "client_ip", "=", "None", ",", "location", "=", "None", ",", "country_code", "=", "None", ",", "market", "=", "None", ",", "safe_search", "=", "None", ",", "set_lang", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "# Construct URL", "url", "=", "self", ".", "trending", ".", "metadata", "[", "'url'", "]", "# Construct parameters", "query_parameters", "=", "{", "}", "if", "country_code", "is", "not", "None", ":", "query_parameters", "[", "'cc'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"country_code\"", ",", "country_code", ",", "'str'", ")", "if", "market", "is", "not", "None", ":", "query_parameters", "[", "'mkt'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"market\"", ",", "market", ",", "'str'", ")", "if", "safe_search", "is", "not", "None", ":", "query_parameters", "[", "'safeSearch'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"safe_search\"", ",", "safe_search", ",", "'str'", ")", "if", "set_lang", "is", "not", "None", ":", "query_parameters", "[", "'setLang'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"set_lang\"", ",", "set_lang", ",", "'str'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "header_parameters", "[", "'X-BingApis-SDK'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.x_bing_apis_sdk\"", ",", "self", ".", "x_bing_apis_sdk", ",", "'str'", ")", "if", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'Accept-Language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"accept_language\"", ",", "accept_language", ",", "'str'", ")", "if", "user_agent", "is", "not", "None", ":", "header_parameters", "[", "'User-Agent'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"user_agent\"", ",", "user_agent", ",", "'str'", ")", "if", "client_id", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientID'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_id\"", ",", "client_id", ",", "'str'", ")", "if", "client_ip", "is", "not", "None", ":", "header_parameters", "[", "'X-MSEdge-ClientIP'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_ip\"", ",", "client_ip", ",", "'str'", ")", "if", "location", "is", "not", "None", ":", "header_parameters", "[", "'X-Search-Location'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"location\"", ",", "location", ",", "'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", ".", "ErrorResponseException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'TrendingImages'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.open
Opens the request. method: the request VERB 'GET', 'POST', etc. url: the url to connect
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def open(self, method, url): ''' Opens the request. method: the request VERB 'GET', 'POST', etc. url: the url to connect ''' flag = VARIANT.create_bool_false() _method = BSTR(method) _url = BSTR(url) _WinHttpRequest._Open(self, _method, _url, flag)
def open(self, method, url): ''' Opens the request. method: the request VERB 'GET', 'POST', etc. url: the url to connect ''' flag = VARIANT.create_bool_false() _method = BSTR(method) _url = BSTR(url) _WinHttpRequest._Open(self, _method, _url, flag)
[ "Opens", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L265-L277
[ "def", "open", "(", "self", ",", "method", ",", "url", ")", ":", "flag", "=", "VARIANT", ".", "create_bool_false", "(", ")", "_method", "=", "BSTR", "(", "method", ")", "_url", "=", "BSTR", "(", "url", ")", "_WinHttpRequest", ".", "_Open", "(", "self", ",", "_method", ",", "_url", ",", "flag", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.set_timeout
Sets up the timeout for the request.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def set_timeout(self, timeout_in_seconds): ''' Sets up the timeout for the request. ''' timeout_in_ms = int(timeout_in_seconds * 1000) _WinHttpRequest._SetTimeouts( self, 0, timeout_in_ms, timeout_in_ms, timeout_in_ms)
def set_timeout(self, timeout_in_seconds): ''' Sets up the timeout for the request. ''' timeout_in_ms = int(timeout_in_seconds * 1000) _WinHttpRequest._SetTimeouts( self, 0, timeout_in_ms, timeout_in_ms, timeout_in_ms)
[ "Sets", "up", "the", "timeout", "for", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L279-L283
[ "def", "set_timeout", "(", "self", ",", "timeout_in_seconds", ")", ":", "timeout_in_ms", "=", "int", "(", "timeout_in_seconds", "*", "1000", ")", "_WinHttpRequest", ".", "_SetTimeouts", "(", "self", ",", "0", ",", "timeout_in_ms", ",", "timeout_in_ms", ",", "timeout_in_ms", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.set_request_header
Sets the request header.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def set_request_header(self, name, value): ''' Sets the request header. ''' _name = BSTR(name) _value = BSTR(value) _WinHttpRequest._SetRequestHeader(self, _name, _value)
def set_request_header(self, name, value): ''' Sets the request header. ''' _name = BSTR(name) _value = BSTR(value) _WinHttpRequest._SetRequestHeader(self, _name, _value)
[ "Sets", "the", "request", "header", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L285-L290
[ "def", "set_request_header", "(", "self", ",", "name", ",", "value", ")", ":", "_name", "=", "BSTR", "(", "name", ")", "_value", "=", "BSTR", "(", "value", ")", "_WinHttpRequest", ".", "_SetRequestHeader", "(", "self", ",", "_name", ",", "_value", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.get_all_response_headers
Gets back all response headers.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def get_all_response_headers(self): ''' Gets back all response headers. ''' bstr_headers = c_void_p() _WinHttpRequest._GetAllResponseHeaders(self, byref(bstr_headers)) bstr_headers = ctypes.cast(bstr_headers, c_wchar_p) headers = bstr_headers.value _SysFreeString(bstr_headers) return headers
def get_all_response_headers(self): ''' Gets back all response headers. ''' bstr_headers = c_void_p() _WinHttpRequest._GetAllResponseHeaders(self, byref(bstr_headers)) bstr_headers = ctypes.cast(bstr_headers, c_wchar_p) headers = bstr_headers.value _SysFreeString(bstr_headers) return headers
[ "Gets", "back", "all", "response", "headers", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L292-L300
[ "def", "get_all_response_headers", "(", "self", ")", ":", "bstr_headers", "=", "c_void_p", "(", ")", "_WinHttpRequest", ".", "_GetAllResponseHeaders", "(", "self", ",", "byref", "(", "bstr_headers", ")", ")", "bstr_headers", "=", "ctypes", ".", "cast", "(", "bstr_headers", ",", "c_wchar_p", ")", "headers", "=", "bstr_headers", ".", "value", "_SysFreeString", "(", "bstr_headers", ")", "return", "headers" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.send
Sends the request body.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def send(self, request=None): ''' Sends the request body. ''' # Sends VT_EMPTY if it is GET, HEAD request. if request is None: var_empty = VARIANT.create_empty() _WinHttpRequest._Send(self, var_empty) else: # Sends request body as SAFEArray. _request = VARIANT.create_safearray_from_str(request) _WinHttpRequest._Send(self, _request)
def send(self, request=None): ''' Sends the request body. ''' # Sends VT_EMPTY if it is GET, HEAD request. if request is None: var_empty = VARIANT.create_empty() _WinHttpRequest._Send(self, var_empty) else: # Sends request body as SAFEArray. _request = VARIANT.create_safearray_from_str(request) _WinHttpRequest._Send(self, _request)
[ "Sends", "the", "request", "body", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L302-L311
[ "def", "send", "(", "self", ",", "request", "=", "None", ")", ":", "# Sends VT_EMPTY if it is GET, HEAD request.", "if", "request", "is", "None", ":", "var_empty", "=", "VARIANT", ".", "create_empty", "(", ")", "_WinHttpRequest", ".", "_Send", "(", "self", ",", "var_empty", ")", "else", ":", "# Sends request body as SAFEArray.", "_request", "=", "VARIANT", ".", "create_safearray_from_str", "(", "request", ")", "_WinHttpRequest", ".", "_Send", "(", "self", ",", "_request", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.status
Gets status of response.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def status(self): ''' Gets status of response. ''' status = c_long() _WinHttpRequest._Status(self, byref(status)) return int(status.value)
def status(self): ''' Gets status of response. ''' status = c_long() _WinHttpRequest._Status(self, byref(status)) return int(status.value)
[ "Gets", "status", "of", "response", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L313-L318
[ "def", "status", "(", "self", ")", ":", "status", "=", "c_long", "(", ")", "_WinHttpRequest", ".", "_Status", "(", "self", ",", "byref", "(", "status", ")", ")", "return", "int", "(", "status", ".", "value", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.status_text
Gets status text of response.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def status_text(self): ''' Gets status text of response. ''' bstr_status_text = c_void_p() _WinHttpRequest._StatusText(self, byref(bstr_status_text)) bstr_status_text = ctypes.cast(bstr_status_text, c_wchar_p) status_text = bstr_status_text.value _SysFreeString(bstr_status_text) return status_text
def status_text(self): ''' Gets status text of response. ''' bstr_status_text = c_void_p() _WinHttpRequest._StatusText(self, byref(bstr_status_text)) bstr_status_text = ctypes.cast(bstr_status_text, c_wchar_p) status_text = bstr_status_text.value _SysFreeString(bstr_status_text) return status_text
[ "Gets", "status", "text", "of", "response", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L320-L328
[ "def", "status_text", "(", "self", ")", ":", "bstr_status_text", "=", "c_void_p", "(", ")", "_WinHttpRequest", ".", "_StatusText", "(", "self", ",", "byref", "(", "bstr_status_text", ")", ")", "bstr_status_text", "=", "ctypes", ".", "cast", "(", "bstr_status_text", ",", "c_wchar_p", ")", "status_text", "=", "bstr_status_text", ".", "value", "_SysFreeString", "(", "bstr_status_text", ")", "return", "status_text" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.response_body
Gets response body as a SAFEARRAY and converts the SAFEARRAY to str.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def response_body(self): ''' Gets response body as a SAFEARRAY and converts the SAFEARRAY to str. ''' var_respbody = VARIANT() _WinHttpRequest._ResponseBody(self, byref(var_respbody)) if var_respbody.is_safearray_of_bytes(): respbody = var_respbody.str_from_safearray() return respbody else: return ''
def response_body(self): ''' Gets response body as a SAFEARRAY and converts the SAFEARRAY to str. ''' var_respbody = VARIANT() _WinHttpRequest._ResponseBody(self, byref(var_respbody)) if var_respbody.is_safearray_of_bytes(): respbody = var_respbody.str_from_safearray() return respbody else: return ''
[ "Gets", "response", "body", "as", "a", "SAFEARRAY", "and", "converts", "the", "SAFEARRAY", "to", "str", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L330-L340
[ "def", "response_body", "(", "self", ")", ":", "var_respbody", "=", "VARIANT", "(", ")", "_WinHttpRequest", ".", "_ResponseBody", "(", "self", ",", "byref", "(", "var_respbody", ")", ")", "if", "var_respbody", ".", "is_safearray_of_bytes", "(", ")", ":", "respbody", "=", "var_respbody", ".", "str_from_safearray", "(", ")", "return", "respbody", "else", ":", "return", "''" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.set_client_certificate
Sets client certificate for the request.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def set_client_certificate(self, certificate): '''Sets client certificate for the request. ''' _certificate = BSTR(certificate) _WinHttpRequest._SetClientCertificate(self, _certificate)
def set_client_certificate(self, certificate): '''Sets client certificate for the request. ''' _certificate = BSTR(certificate) _WinHttpRequest._SetClientCertificate(self, _certificate)
[ "Sets", "client", "certificate", "for", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L342-L345
[ "def", "set_client_certificate", "(", "self", ",", "certificate", ")", ":", "_certificate", "=", "BSTR", "(", "certificate", ")", "_WinHttpRequest", ".", "_SetClientCertificate", "(", "self", ",", "_certificate", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_WinHttpRequest.set_tunnel
Sets up the host and the port for the HTTP CONNECT Tunnelling.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def set_tunnel(self, host, port): ''' Sets up the host and the port for the HTTP CONNECT Tunnelling.''' url = host if port: url = url + u':' + port var_host = VARIANT.create_bstr_from_str(url) var_empty = VARIANT.create_empty() _WinHttpRequest._SetProxy( self, HTTPREQUEST_PROXYSETTING_PROXY, var_host, var_empty)
def set_tunnel(self, host, port): ''' Sets up the host and the port for the HTTP CONNECT Tunnelling.''' url = host if port: url = url + u':' + port var_host = VARIANT.create_bstr_from_str(url) var_empty = VARIANT.create_empty() _WinHttpRequest._SetProxy( self, HTTPREQUEST_PROXYSETTING_PROXY, var_host, var_empty)
[ "Sets", "up", "the", "host", "and", "the", "port", "for", "the", "HTTP", "CONNECT", "Tunnelling", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L347-L357
[ "def", "set_tunnel", "(", "self", ",", "host", ",", "port", ")", ":", "url", "=", "host", "if", "port", ":", "url", "=", "url", "+", "u':'", "+", "port", "var_host", "=", "VARIANT", ".", "create_bstr_from_str", "(", "url", ")", "var_empty", "=", "VARIANT", ".", "create_empty", "(", ")", "_WinHttpRequest", ".", "_SetProxy", "(", "self", ",", "HTTPREQUEST_PROXYSETTING_PROXY", ",", "var_host", ",", "var_empty", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPConnection.set_tunnel
Sets up the host and the port for the HTTP CONNECT Tunnelling.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def set_tunnel(self, host, port=None, headers=None): ''' Sets up the host and the port for the HTTP CONNECT Tunnelling. ''' self._httprequest.set_tunnel(unicode(host), unicode(str(port)))
def set_tunnel(self, host, port=None, headers=None): ''' Sets up the host and the port for the HTTP CONNECT Tunnelling. ''' self._httprequest.set_tunnel(unicode(host), unicode(str(port)))
[ "Sets", "up", "the", "host", "and", "the", "port", "for", "the", "HTTP", "CONNECT", "Tunnelling", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L410-L412
[ "def", "set_tunnel", "(", "self", ",", "host", ",", "port", "=", "None", ",", "headers", "=", "None", ")", ":", "self", ".", "_httprequest", ".", "set_tunnel", "(", "unicode", "(", "host", ")", ",", "unicode", "(", "str", "(", "port", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPConnection.putrequest
Connects to host and sends the request.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def putrequest(self, method, uri): ''' Connects to host and sends the request. ''' protocol = unicode(self.protocol + '://') url = protocol + self.host + unicode(uri) self._httprequest.set_timeout(self.timeout) self._httprequest.open(unicode(method), url) # sets certificate for the connection if cert_file is set. if self.cert_file is not None: self._httprequest.set_client_certificate(unicode(self.cert_file))
def putrequest(self, method, uri): ''' Connects to host and sends the request. ''' protocol = unicode(self.protocol + '://') url = protocol + self.host + unicode(uri) self._httprequest.set_timeout(self.timeout) self._httprequest.open(unicode(method), url) # sets certificate for the connection if cert_file is set. if self.cert_file is not None: self._httprequest.set_client_certificate(unicode(self.cert_file))
[ "Connects", "to", "host", "and", "sends", "the", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L418-L428
[ "def", "putrequest", "(", "self", ",", "method", ",", "uri", ")", ":", "protocol", "=", "unicode", "(", "self", ".", "protocol", "+", "'://'", ")", "url", "=", "protocol", "+", "self", ".", "host", "+", "unicode", "(", "uri", ")", "self", ".", "_httprequest", ".", "set_timeout", "(", "self", ".", "timeout", ")", "self", ".", "_httprequest", ".", "open", "(", "unicode", "(", "method", ")", ",", "url", ")", "# sets certificate for the connection if cert_file is set.", "if", "self", ".", "cert_file", "is", "not", "None", ":", "self", ".", "_httprequest", ".", "set_client_certificate", "(", "unicode", "(", "self", ".", "cert_file", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPConnection.putheader
Sends the headers of request.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def putheader(self, name, value): ''' Sends the headers of request. ''' if sys.version_info < (3,): name = str(name).decode('utf-8') value = str(value).decode('utf-8') self._httprequest.set_request_header(name, value)
def putheader(self, name, value): ''' Sends the headers of request. ''' if sys.version_info < (3,): name = str(name).decode('utf-8') value = str(value).decode('utf-8') self._httprequest.set_request_header(name, value)
[ "Sends", "the", "headers", "of", "request", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L430-L435
[ "def", "putheader", "(", "self", ",", "name", ",", "value", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", ")", ":", "name", "=", "str", "(", "name", ")", ".", "decode", "(", "'utf-8'", ")", "value", "=", "str", "(", "value", ")", ".", "decode", "(", "'utf-8'", ")", "self", ".", "_httprequest", ".", "set_request_header", "(", "name", ",", "value", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPConnection.send
Sends request body.
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def send(self, request_body): ''' Sends request body. ''' if not request_body: self._httprequest.send() else: self._httprequest.send(request_body)
def send(self, request_body): ''' Sends request body. ''' if not request_body: self._httprequest.send() else: self._httprequest.send(request_body)
[ "Sends", "request", "body", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L442-L447
[ "def", "send", "(", "self", ",", "request_body", ")", ":", "if", "not", "request_body", ":", "self", ".", "_httprequest", ".", "send", "(", ")", "else", ":", "self", ".", "_httprequest", ".", "send", "(", "request_body", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_HTTPConnection.getresponse
Gets the response and generates the _Response object
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
def getresponse(self): ''' Gets the response and generates the _Response object''' status = self._httprequest.status() status_text = self._httprequest.status_text() resp_headers = self._httprequest.get_all_response_headers() fixed_headers = [] for resp_header in resp_headers.split('\n'): if (resp_header.startswith('\t') or\ resp_header.startswith(' ')) and fixed_headers: # append to previous header fixed_headers[-1] += resp_header else: fixed_headers.append(resp_header) headers = [] for resp_header in fixed_headers: if ':' in resp_header: pos = resp_header.find(':') headers.append( (resp_header[:pos].lower(), resp_header[pos + 1:].strip())) body = self._httprequest.response_body() length = len(body) return _Response(status, status_text, length, headers, body)
def getresponse(self): ''' Gets the response and generates the _Response object''' status = self._httprequest.status() status_text = self._httprequest.status_text() resp_headers = self._httprequest.get_all_response_headers() fixed_headers = [] for resp_header in resp_headers.split('\n'): if (resp_header.startswith('\t') or\ resp_header.startswith(' ')) and fixed_headers: # append to previous header fixed_headers[-1] += resp_header else: fixed_headers.append(resp_header) headers = [] for resp_header in fixed_headers: if ':' in resp_header: pos = resp_header.find(':') headers.append( (resp_header[:pos].lower(), resp_header[pos + 1:].strip())) body = self._httprequest.response_body() length = len(body) return _Response(status, status_text, length, headers, body)
[ "Gets", "the", "response", "and", "generates", "the", "_Response", "object" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L449-L474
[ "def", "getresponse", "(", "self", ")", ":", "status", "=", "self", ".", "_httprequest", ".", "status", "(", ")", "status_text", "=", "self", ".", "_httprequest", ".", "status_text", "(", ")", "resp_headers", "=", "self", ".", "_httprequest", ".", "get_all_response_headers", "(", ")", "fixed_headers", "=", "[", "]", "for", "resp_header", "in", "resp_headers", ".", "split", "(", "'\\n'", ")", ":", "if", "(", "resp_header", ".", "startswith", "(", "'\\t'", ")", "or", "resp_header", ".", "startswith", "(", "' '", ")", ")", "and", "fixed_headers", ":", "# append to previous header", "fixed_headers", "[", "-", "1", "]", "+=", "resp_header", "else", ":", "fixed_headers", ".", "append", "(", "resp_header", ")", "headers", "=", "[", "]", "for", "resp_header", "in", "fixed_headers", ":", "if", "':'", "in", "resp_header", ":", "pos", "=", "resp_header", ".", "find", "(", "':'", ")", "headers", ".", "append", "(", "(", "resp_header", "[", ":", "pos", "]", ".", "lower", "(", ")", ",", "resp_header", "[", "pos", "+", "1", ":", "]", ".", "strip", "(", ")", ")", ")", "body", "=", "self", ".", "_httprequest", ".", "response_body", "(", ")", "length", "=", "len", "(", "body", ")", "return", "_Response", "(", "status", ",", "status_text", ",", "length", ",", "headers", ",", "body", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_get_readable_id
simplified an id to be more friendly for us people
azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py
def _get_readable_id(id_name, id_prefix_to_skip): """simplified an id to be more friendly for us people""" # id_name is in the form 'https://namespace.host.suffix/name' # where name may contain a forward slash! pos = id_name.find('//') if pos != -1: pos += 2 if id_prefix_to_skip: pos = id_name.find(id_prefix_to_skip, pos) if pos != -1: pos += len(id_prefix_to_skip) pos = id_name.find('/', pos) if pos != -1: return id_name[pos + 1:] return id_name
def _get_readable_id(id_name, id_prefix_to_skip): """simplified an id to be more friendly for us people""" # id_name is in the form 'https://namespace.host.suffix/name' # where name may contain a forward slash! pos = id_name.find('//') if pos != -1: pos += 2 if id_prefix_to_skip: pos = id_name.find(id_prefix_to_skip, pos) if pos != -1: pos += len(id_prefix_to_skip) pos = id_name.find('/', pos) if pos != -1: return id_name[pos + 1:] return id_name
[ "simplified", "an", "id", "to", "be", "more", "friendly", "for", "us", "people" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py#L29-L43
[ "def", "_get_readable_id", "(", "id_name", ",", "id_prefix_to_skip", ")", ":", "# id_name is in the form 'https://namespace.host.suffix/name'", "# where name may contain a forward slash!", "pos", "=", "id_name", ".", "find", "(", "'//'", ")", "if", "pos", "!=", "-", "1", ":", "pos", "+=", "2", "if", "id_prefix_to_skip", ":", "pos", "=", "id_name", ".", "find", "(", "id_prefix_to_skip", ",", "pos", ")", "if", "pos", "!=", "-", "1", ":", "pos", "+=", "len", "(", "id_prefix_to_skip", ")", "pos", "=", "id_name", ".", "find", "(", "'/'", ",", "pos", ")", "if", "pos", "!=", "-", "1", ":", "return", "id_name", "[", "pos", "+", "1", ":", "]", "return", "id_name" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_create_entry
Adds common part of entry to a given entry body and return the whole xml.
azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py
def _create_entry(entry_body): ''' Adds common part of entry to a given entry body and return the whole xml. ''' updated_str = datetime.utcnow().isoformat() if datetime.utcnow().utcoffset() is None: updated_str += '+00:00' entry_start = '''<?xml version="1.0" encoding="utf-8" standalone="yes"?> <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom" > <title /><updated>{updated}</updated><author><name /></author><id /> <content type="application/xml"> {body}</content></entry>''' return entry_start.format(updated=updated_str, body=entry_body)
def _create_entry(entry_body): ''' Adds common part of entry to a given entry body and return the whole xml. ''' updated_str = datetime.utcnow().isoformat() if datetime.utcnow().utcoffset() is None: updated_str += '+00:00' entry_start = '''<?xml version="1.0" encoding="utf-8" standalone="yes"?> <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom" > <title /><updated>{updated}</updated><author><name /></author><id /> <content type="application/xml"> {body}</content></entry>''' return entry_start.format(updated=updated_str, body=entry_body)
[ "Adds", "common", "part", "of", "entry", "to", "a", "given", "entry", "body", "and", "return", "the", "whole", "xml", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py#L46-L58
[ "def", "_create_entry", "(", "entry_body", ")", ":", "updated_str", "=", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", "(", ")", "if", "datetime", ".", "utcnow", "(", ")", ".", "utcoffset", "(", ")", "is", "None", ":", "updated_str", "+=", "'+00:00'", "entry_start", "=", "'''<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<entry xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" xmlns=\"http://www.w3.org/2005/Atom\" >\n<title /><updated>{updated}</updated><author><name /></author><id />\n<content type=\"application/xml\">\n {body}</content></entry>'''", "return", "entry_start", ".", "format", "(", "updated", "=", "updated_str", ",", "body", "=", "entry_body", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_get_serialization_name
converts a Python name into a serializable name
azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py
def _get_serialization_name(element_name): """converts a Python name into a serializable name""" known = _KNOWN_SERIALIZATION_XFORMS.get(element_name) if known is not None: return known if element_name.startswith('x_ms_'): return element_name.replace('_', '-') if element_name.endswith('_id'): element_name = element_name.replace('_id', 'ID') for name in ['content_', 'last_modified', 'if_', 'cache_control']: if element_name.startswith(name): element_name = element_name.replace('_', '-_') return ''.join(name.capitalize() for name in element_name.split('_'))
def _get_serialization_name(element_name): """converts a Python name into a serializable name""" known = _KNOWN_SERIALIZATION_XFORMS.get(element_name) if known is not None: return known if element_name.startswith('x_ms_'): return element_name.replace('_', '-') if element_name.endswith('_id'): element_name = element_name.replace('_id', 'ID') for name in ['content_', 'last_modified', 'if_', 'cache_control']: if element_name.startswith(name): element_name = element_name.replace('_', '-_') return ''.join(name.capitalize() for name in element_name.split('_'))
[ "converts", "a", "Python", "name", "into", "a", "serializable", "name" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_common_serialization.py#L100-L114
[ "def", "_get_serialization_name", "(", "element_name", ")", ":", "known", "=", "_KNOWN_SERIALIZATION_XFORMS", ".", "get", "(", "element_name", ")", "if", "known", "is", "not", "None", ":", "return", "known", "if", "element_name", ".", "startswith", "(", "'x_ms_'", ")", ":", "return", "element_name", ".", "replace", "(", "'_'", ",", "'-'", ")", "if", "element_name", ".", "endswith", "(", "'_id'", ")", ":", "element_name", "=", "element_name", ".", "replace", "(", "'_id'", ",", "'ID'", ")", "for", "name", "in", "[", "'content_'", ",", "'last_modified'", ",", "'if_'", ",", "'cache_control'", "]", ":", "if", "element_name", ".", "startswith", "(", "name", ")", ":", "element_name", "=", "element_name", ".", "replace", "(", "'_'", ",", "'-_'", ")", "return", "''", ".", "join", "(", "name", ".", "capitalize", "(", ")", "for", "name", "in", "element_name", ".", "split", "(", "'_'", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_bstr_to_b64url
Serialize bytes into base-64 string. :param str: Object to be serialized. :rtype: str
azure-keyvault/azure/keyvault/_internal.py
def _bstr_to_b64url(bstr, **kwargs): """Serialize bytes into base-64 string. :param str: Object to be serialized. :rtype: str """ encoded = b64encode(bstr).decode() return encoded.strip('=').replace('+', '-').replace('/', '_')
def _bstr_to_b64url(bstr, **kwargs): """Serialize bytes into base-64 string. :param str: Object to be serialized. :rtype: str """ encoded = b64encode(bstr).decode() return encoded.strip('=').replace('+', '-').replace('/', '_')
[ "Serialize", "bytes", "into", "base", "-", "64", "string", ".", ":", "param", "str", ":", "Object", "to", "be", "serialized", ".", ":", "rtype", ":", "str" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/_internal.py#L114-L120
[ "def", "_bstr_to_b64url", "(", "bstr", ",", "*", "*", "kwargs", ")", ":", "encoded", "=", "b64encode", "(", "bstr", ")", ".", "decode", "(", ")", "return", "encoded", ".", "strip", "(", "'='", ")", ".", "replace", "(", "'+'", ",", "'-'", ")", ".", "replace", "(", "'/'", ",", "'_'", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_b64_to_bstr
Deserialize base64 encoded string into string. :param str b64str: response string to be deserialized. :rtype: bytearray :raises: TypeError if string format invalid.
azure-keyvault/azure/keyvault/_internal.py
def _b64_to_bstr(b64str): """Deserialize base64 encoded string into string. :param str b64str: response string to be deserialized. :rtype: bytearray :raises: TypeError if string format invalid. """ padding = '=' * (3 - (len(b64str) + 3) % 4) b64str = b64str + padding encoded = b64str.replace('-', '+').replace('_', '/') return b64decode(encoded)
def _b64_to_bstr(b64str): """Deserialize base64 encoded string into string. :param str b64str: response string to be deserialized. :rtype: bytearray :raises: TypeError if string format invalid. """ padding = '=' * (3 - (len(b64str) + 3) % 4) b64str = b64str + padding encoded = b64str.replace('-', '+').replace('_', '/') return b64decode(encoded)
[ "Deserialize", "base64", "encoded", "string", "into", "string", ".", ":", "param", "str", "b64str", ":", "response", "string", "to", "be", "deserialized", ".", ":", "rtype", ":", "bytearray", ":", "raises", ":", "TypeError", "if", "string", "format", "invalid", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/_internal.py#L131-L140
[ "def", "_b64_to_bstr", "(", "b64str", ")", ":", "padding", "=", "'='", "*", "(", "3", "-", "(", "len", "(", "b64str", ")", "+", "3", ")", "%", "4", ")", "b64str", "=", "b64str", "+", "padding", "encoded", "=", "b64str", ".", "replace", "(", "'-'", ",", "'+'", ")", ".", "replace", "(", "'_'", ",", "'/'", ")", "return", "b64decode", "(", "encoded", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FaceOperations.find_similar
Given query face's faceId, to search the similar-looking faces from a faceId array, a face list or a large face list. faceId array contains the faces created by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), which will expire 24 hours after creation. A "faceListId" is created by [FaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b) containing persistedFaceIds that will not expire. And a "largeFaceListId" is created by [LargeFaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) containing persistedFaceIds that will also not expire. Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity. <br/>Find similar has two working modes, "matchPerson" and "matchFace". "matchPerson" is the default mode that it tries to find faces of the same person as possible by using internal same-person thresholds. It is useful to find a known person's other photos. Note that an empty list will be returned if no faces pass the internal thresholds. "matchFace" mode ignores same-person thresholds and returns ranked similar faces anyway, even the similarity is low. It can be used in the cases like searching celebrity-looking faces. <br/>The 'recognitionModel' associated with the query face's faceId should be the same as the 'recognitionModel' used by the target faceId array, face list or large face list. . :param face_id: FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call :type face_id: str :param face_list_id: An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_list_id: str :param large_face_list_id: An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type large_face_list_id: str :param face_ids: An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_ids: list[str] :param max_num_of_candidates_returned: The number of top similar faces returned. The valid range is [1, 1000]. :type max_num_of_candidates_returned: int :param mode: Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' :type mode: str or ~azure.cognitiveservices.vision.face.models.FindSimilarMatchMode :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.SimilarFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py
def find_similar( self, face_id, face_list_id=None, large_face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode="matchPerson", custom_headers=None, raw=False, **operation_config): """Given query face's faceId, to search the similar-looking faces from a faceId array, a face list or a large face list. faceId array contains the faces created by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), which will expire 24 hours after creation. A "faceListId" is created by [FaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b) containing persistedFaceIds that will not expire. And a "largeFaceListId" is created by [LargeFaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) containing persistedFaceIds that will also not expire. Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity. <br/>Find similar has two working modes, "matchPerson" and "matchFace". "matchPerson" is the default mode that it tries to find faces of the same person as possible by using internal same-person thresholds. It is useful to find a known person's other photos. Note that an empty list will be returned if no faces pass the internal thresholds. "matchFace" mode ignores same-person thresholds and returns ranked similar faces anyway, even the similarity is low. It can be used in the cases like searching celebrity-looking faces. <br/>The 'recognitionModel' associated with the query face's faceId should be the same as the 'recognitionModel' used by the target faceId array, face list or large face list. . :param face_id: FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call :type face_id: str :param face_list_id: An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_list_id: str :param large_face_list_id: An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type large_face_list_id: str :param face_ids: An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_ids: list[str] :param max_num_of_candidates_returned: The number of top similar faces returned. The valid range is [1, 1000]. :type max_num_of_candidates_returned: int :param mode: Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' :type mode: str or ~azure.cognitiveservices.vision.face.models.FindSimilarMatchMode :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.SimilarFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.FindSimilarRequest(face_id=face_id, face_list_id=face_list_id, large_face_list_id=large_face_list_id, face_ids=face_ids, max_num_of_candidates_returned=max_num_of_candidates_returned, mode=mode) # Construct URL url = self.find_similar.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'FindSimilarRequest') # 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('[SimilarFace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def find_similar( self, face_id, face_list_id=None, large_face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode="matchPerson", custom_headers=None, raw=False, **operation_config): """Given query face's faceId, to search the similar-looking faces from a faceId array, a face list or a large face list. faceId array contains the faces created by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), which will expire 24 hours after creation. A "faceListId" is created by [FaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b) containing persistedFaceIds that will not expire. And a "largeFaceListId" is created by [LargeFaceList - Create](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) containing persistedFaceIds that will also not expire. Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity. <br/>Find similar has two working modes, "matchPerson" and "matchFace". "matchPerson" is the default mode that it tries to find faces of the same person as possible by using internal same-person thresholds. It is useful to find a known person's other photos. Note that an empty list will be returned if no faces pass the internal thresholds. "matchFace" mode ignores same-person thresholds and returns ranked similar faces anyway, even the similarity is low. It can be used in the cases like searching celebrity-looking faces. <br/>The 'recognitionModel' associated with the query face's faceId should be the same as the 'recognitionModel' used by the target faceId array, face list or large face list. . :param face_id: FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call :type face_id: str :param face_list_id: An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_list_id: str :param large_face_list_id: An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type large_face_list_id: str :param face_ids: An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. :type face_ids: list[str] :param max_num_of_candidates_returned: The number of top similar faces returned. The valid range is [1, 1000]. :type max_num_of_candidates_returned: int :param mode: Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' :type mode: str or ~azure.cognitiveservices.vision.face.models.FindSimilarMatchMode :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.SimilarFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.FindSimilarRequest(face_id=face_id, face_list_id=face_list_id, large_face_list_id=large_face_list_id, face_ids=face_ids, max_num_of_candidates_returned=max_num_of_candidates_returned, mode=mode) # Construct URL url = self.find_similar.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'FindSimilarRequest') # 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('[SimilarFace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Given", "query", "face", "s", "faceId", "to", "search", "the", "similar", "-", "looking", "faces", "from", "a", "faceId", "array", "a", "face", "list", "or", "a", "large", "face", "list", ".", "faceId", "array", "contains", "the", "faces", "created", "by", "[", "Face", "-", "Detect", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "563879b61984550f30395236", ")", "which", "will", "expire", "24", "hours", "after", "creation", ".", "A", "faceListId", "is", "created", "by", "[", "FaceList", "-", "Create", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "563879b61984550f3039524b", ")", "containing", "persistedFaceIds", "that", "will", "not", "expire", ".", "And", "a", "largeFaceListId", "is", "created", "by", "[", "LargeFaceList", "-", "Create", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "5a157b68d2de3616c086f2cc", ")", "containing", "persistedFaceIds", "that", "will", "also", "not", "expire", ".", "Depending", "on", "the", "input", "the", "returned", "similar", "faces", "list", "contains", "faceIds", "or", "persistedFaceIds", "ranked", "by", "similarity", ".", "<br", "/", ">", "Find", "similar", "has", "two", "working", "modes", "matchPerson", "and", "matchFace", ".", "matchPerson", "is", "the", "default", "mode", "that", "it", "tries", "to", "find", "faces", "of", "the", "same", "person", "as", "possible", "by", "using", "internal", "same", "-", "person", "thresholds", ".", "It", "is", "useful", "to", "find", "a", "known", "person", "s", "other", "photos", ".", "Note", "that", "an", "empty", "list", "will", "be", "returned", "if", "no", "faces", "pass", "the", "internal", "thresholds", ".", "matchFace", "mode", "ignores", "same", "-", "person", "thresholds", "and", "returns", "ranked", "similar", "faces", "anyway", "even", "the", "similarity", "is", "low", ".", "It", "can", "be", "used", "in", "the", "cases", "like", "searching", "celebrity", "-", "looking", "faces", ".", "<br", "/", ">", "The", "recognitionModel", "associated", "with", "the", "query", "face", "s", "faceId", "should", "be", "the", "same", "as", "the", "recognitionModel", "used", "by", "the", "target", "faceId", "array", "face", "list", "or", "large", "face", "list", ".", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py#L36-L142
[ "def", "find_similar", "(", "self", ",", "face_id", ",", "face_list_id", "=", "None", ",", "large_face_list_id", "=", "None", ",", "face_ids", "=", "None", ",", "max_num_of_candidates_returned", "=", "20", ",", "mode", "=", "\"matchPerson\"", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "body", "=", "models", ".", "FindSimilarRequest", "(", "face_id", "=", "face_id", ",", "face_list_id", "=", "face_list_id", ",", "large_face_list_id", "=", "large_face_list_id", ",", "face_ids", "=", "face_ids", ",", "max_num_of_candidates_returned", "=", "max_num_of_candidates_returned", ",", "mode", "=", "mode", ")", "# Construct URL", "url", "=", "self", ".", "find_similar", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "body", ",", "'FindSimilarRequest'", ")", "# 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", "(", "'[SimilarFace]'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FaceOperations.detect_with_url
Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.<br /> * Optional parameters including faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise. * The extracted face feature, instead of the actual image, will be stored on server. The faceId is an identifier of the face feature and will be used in [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239), [Face - Verify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a), and [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). It will expire 24 hours after the detection call. * Higher face image quality means better detection and recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * Faces are detectable when its size is 36x36 to 4096x4096 pixels. If need to detect very small but clear faces, please try to enlarge the input image. * Up to 64 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * Face detector prefer frontal and near-frontal faces. There are cases that faces may not be detected, e.g. exceptionally large face angles (head-pose) or being occluded, or wrong image orientation. * Attributes (age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise) may not be perfectly accurate. HeadPose's pitch value is a reserved field and will always return 0. * Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to [How to specify a recognition model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model) . :param url: Publicly reachable URL of an image :type url: str :param return_face_id: A value indicating whether the operation should return faceIds of detected faces. :type return_face_id: bool :param return_face_landmarks: A value indicating whether the operation should return landmarks of the detected faces. :type return_face_landmarks: bool :param return_face_attributes: Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. :type return_face_attributes: list[str or ~azure.cognitiveservices.vision.face.models.FaceAttributeType] :param recognition_model: Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds, (Large)FaceList or (Large)PersonGroup. A recognition model name can be provided when performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup - Create. The default value is 'recognition_01', if latest model needed, please explicitly specify the model you need. Possible values include: 'recognition_01', 'recognition_02' :type recognition_model: str or ~azure.cognitiveservices.vision.face.models.RecognitionModel :param return_recognition_model: A value indicating whether the operation should return 'recognitionModel' in response. :type return_recognition_model: 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: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.DetectedFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py
def detect_with_url( self, url, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, recognition_model="recognition_01", return_recognition_model=False, custom_headers=None, raw=False, **operation_config): """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.<br /> * Optional parameters including faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise. * The extracted face feature, instead of the actual image, will be stored on server. The faceId is an identifier of the face feature and will be used in [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239), [Face - Verify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a), and [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). It will expire 24 hours after the detection call. * Higher face image quality means better detection and recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * Faces are detectable when its size is 36x36 to 4096x4096 pixels. If need to detect very small but clear faces, please try to enlarge the input image. * Up to 64 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * Face detector prefer frontal and near-frontal faces. There are cases that faces may not be detected, e.g. exceptionally large face angles (head-pose) or being occluded, or wrong image orientation. * Attributes (age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise) may not be perfectly accurate. HeadPose's pitch value is a reserved field and will always return 0. * Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to [How to specify a recognition model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model) . :param url: Publicly reachable URL of an image :type url: str :param return_face_id: A value indicating whether the operation should return faceIds of detected faces. :type return_face_id: bool :param return_face_landmarks: A value indicating whether the operation should return landmarks of the detected faces. :type return_face_landmarks: bool :param return_face_attributes: Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. :type return_face_attributes: list[str or ~azure.cognitiveservices.vision.face.models.FaceAttributeType] :param recognition_model: Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds, (Large)FaceList or (Large)PersonGroup. A recognition model name can be provided when performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup - Create. The default value is 'recognition_01', if latest model needed, please explicitly specify the model you need. Possible values include: 'recognition_01', 'recognition_02' :type recognition_model: str or ~azure.cognitiveservices.vision.face.models.RecognitionModel :param return_recognition_model: A value indicating whether the operation should return 'recognitionModel' in response. :type return_recognition_model: 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: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.DetectedFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ image_url = models.ImageUrl(url=url) # Construct URL url = self.detect_with_url.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 return_face_id is not None: query_parameters['returnFaceId'] = self._serialize.query("return_face_id", return_face_id, 'bool') if return_face_landmarks is not None: query_parameters['returnFaceLandmarks'] = self._serialize.query("return_face_landmarks", return_face_landmarks, 'bool') if return_face_attributes is not None: query_parameters['returnFaceAttributes'] = self._serialize.query("return_face_attributes", return_face_attributes, '[FaceAttributeType]', div=',') if recognition_model is not None: query_parameters['recognitionModel'] = self._serialize.query("recognition_model", recognition_model, 'str') if return_recognition_model is not None: query_parameters['returnRecognitionModel'] = self._serialize.query("return_recognition_model", return_recognition_model, 'bool') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') # 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('[DetectedFace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def detect_with_url( self, url, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, recognition_model="recognition_01", return_recognition_model=False, custom_headers=None, raw=False, **operation_config): """Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.<br /> * Optional parameters including faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise. * The extracted face feature, instead of the actual image, will be stored on server. The faceId is an identifier of the face feature and will be used in [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239), [Face - Verify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a), and [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). It will expire 24 hours after the detection call. * Higher face image quality means better detection and recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * Faces are detectable when its size is 36x36 to 4096x4096 pixels. If need to detect very small but clear faces, please try to enlarge the input image. * Up to 64 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * Face detector prefer frontal and near-frontal faces. There are cases that faces may not be detected, e.g. exceptionally large face angles (head-pose) or being occluded, or wrong image orientation. * Attributes (age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure and noise) may not be perfectly accurate. HeadPose's pitch value is a reserved field and will always return 0. * Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to [How to specify a recognition model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model) . :param url: Publicly reachable URL of an image :type url: str :param return_face_id: A value indicating whether the operation should return faceIds of detected faces. :type return_face_id: bool :param return_face_landmarks: A value indicating whether the operation should return landmarks of the detected faces. :type return_face_landmarks: bool :param return_face_attributes: Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. :type return_face_attributes: list[str or ~azure.cognitiveservices.vision.face.models.FaceAttributeType] :param recognition_model: Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds, (Large)FaceList or (Large)PersonGroup. A recognition model name can be provided when performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup - Create. The default value is 'recognition_01', if latest model needed, please explicitly specify the model you need. Possible values include: 'recognition_01', 'recognition_02' :type recognition_model: str or ~azure.cognitiveservices.vision.face.models.RecognitionModel :param return_recognition_model: A value indicating whether the operation should return 'recognitionModel' in response. :type return_recognition_model: 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: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.vision.face.models.DetectedFace] or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ image_url = models.ImageUrl(url=url) # Construct URL url = self.detect_with_url.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 return_face_id is not None: query_parameters['returnFaceId'] = self._serialize.query("return_face_id", return_face_id, 'bool') if return_face_landmarks is not None: query_parameters['returnFaceLandmarks'] = self._serialize.query("return_face_landmarks", return_face_landmarks, 'bool') if return_face_attributes is not None: query_parameters['returnFaceAttributes'] = self._serialize.query("return_face_attributes", return_face_attributes, '[FaceAttributeType]', div=',') if recognition_model is not None: query_parameters['recognitionModel'] = self._serialize.query("recognition_model", recognition_model, 'str') if return_recognition_model is not None: query_parameters['returnRecognitionModel'] = self._serialize.query("return_recognition_model", return_recognition_model, 'bool') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') # 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('[DetectedFace]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Detect", "human", "faces", "in", "an", "image", "return", "face", "rectangles", "and", "optionally", "with", "faceIds", "landmarks", "and", "attributes", ".", "<br", "/", ">", "*", "Optional", "parameters", "including", "faceId", "landmarks", "and", "attributes", ".", "Attributes", "include", "age", "gender", "headPose", "smile", "facialHair", "glasses", "emotion", "hair", "makeup", "occlusion", "accessories", "blur", "exposure", "and", "noise", ".", "*", "The", "extracted", "face", "feature", "instead", "of", "the", "actual", "image", "will", "be", "stored", "on", "server", ".", "The", "faceId", "is", "an", "identifier", "of", "the", "face", "feature", "and", "will", "be", "used", "in", "[", "Face", "-", "Identify", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "563879b61984550f30395239", ")", "[", "Face", "-", "Verify", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "563879b61984550f3039523a", ")", "and", "[", "Face", "-", "Find", "Similar", "]", "(", "/", "docs", "/", "services", "/", "563879b61984550e40cbbe8d", "/", "operations", "/", "563879b61984550f30395237", ")", ".", "It", "will", "expire", "24", "hours", "after", "the", "detection", "call", ".", "*", "Higher", "face", "image", "quality", "means", "better", "detection", "and", "recognition", "precision", ".", "Please", "consider", "high", "-", "quality", "faces", ":", "frontal", "clear", "and", "face", "size", "is", "200x200", "pixels", "(", "100", "pixels", "between", "eyes", ")", "or", "bigger", ".", "*", "JPEG", "PNG", "GIF", "(", "the", "first", "frame", ")", "and", "BMP", "format", "are", "supported", ".", "The", "allowed", "image", "file", "size", "is", "from", "1KB", "to", "6MB", ".", "*", "Faces", "are", "detectable", "when", "its", "size", "is", "36x36", "to", "4096x4096", "pixels", ".", "If", "need", "to", "detect", "very", "small", "but", "clear", "faces", "please", "try", "to", "enlarge", "the", "input", "image", ".", "*", "Up", "to", "64", "faces", "can", "be", "returned", "for", "an", "image", ".", "Faces", "are", "ranked", "by", "face", "rectangle", "size", "from", "large", "to", "small", ".", "*", "Face", "detector", "prefer", "frontal", "and", "near", "-", "frontal", "faces", ".", "There", "are", "cases", "that", "faces", "may", "not", "be", "detected", "e", ".", "g", ".", "exceptionally", "large", "face", "angles", "(", "head", "-", "pose", ")", "or", "being", "occluded", "or", "wrong", "image", "orientation", ".", "*", "Attributes", "(", "age", "gender", "headPose", "smile", "facialHair", "glasses", "emotion", "hair", "makeup", "occlusion", "accessories", "blur", "exposure", "and", "noise", ")", "may", "not", "be", "perfectly", "accurate", ".", "HeadPose", "s", "pitch", "value", "is", "a", "reserved", "field", "and", "will", "always", "return", "0", ".", "*", "Different", "recognitionModel", "values", "are", "provided", ".", "If", "follow", "-", "up", "operations", "like", "Verify", "Identify", "Find", "Similar", "are", "needed", "please", "specify", "the", "recognition", "model", "with", "recognitionModel", "parameter", ".", "The", "default", "value", "for", "recognitionModel", "is", "recognition_01", "if", "latest", "model", "needed", "please", "explicitly", "specify", "the", "model", "you", "need", "in", "this", "parameter", ".", "Once", "specified", "the", "detected", "faceIds", "will", "be", "associated", "with", "the", "specified", "recognition", "model", ".", "More", "details", "please", "refer", "to", "[", "How", "to", "specify", "a", "recognition", "model", "]", "(", "https", ":", "//", "docs", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "azure", "/", "cognitive", "-", "services", "/", "face", "/", "face", "-", "api", "-", "how", "-", "to", "-", "topics", "/", "specify", "-", "recognition", "-", "model", ")", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py#L399-L532
[ "def", "detect_with_url", "(", "self", ",", "url", ",", "return_face_id", "=", "True", ",", "return_face_landmarks", "=", "False", ",", "return_face_attributes", "=", "None", ",", "recognition_model", "=", "\"recognition_01\"", ",", "return_recognition_model", "=", "False", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "image_url", "=", "models", ".", "ImageUrl", "(", "url", "=", "url", ")", "# Construct URL", "url", "=", "self", ".", "detect_with_url", ".", "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", "return_face_id", "is", "not", "None", ":", "query_parameters", "[", "'returnFaceId'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"return_face_id\"", ",", "return_face_id", ",", "'bool'", ")", "if", "return_face_landmarks", "is", "not", "None", ":", "query_parameters", "[", "'returnFaceLandmarks'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"return_face_landmarks\"", ",", "return_face_landmarks", ",", "'bool'", ")", "if", "return_face_attributes", "is", "not", "None", ":", "query_parameters", "[", "'returnFaceAttributes'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"return_face_attributes\"", ",", "return_face_attributes", ",", "'[FaceAttributeType]'", ",", "div", "=", "','", ")", "if", "recognition_model", "is", "not", "None", ":", "query_parameters", "[", "'recognitionModel'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"recognition_model\"", ",", "recognition_model", ",", "'str'", ")", "if", "return_recognition_model", "is", "not", "None", ":", "query_parameters", "[", "'returnRecognitionModel'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"return_recognition_model\"", ",", "return_recognition_model", ",", "'bool'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "image_url", ",", "'ImageUrl'", ")", "# 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", "(", "'[DetectedFace]'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
FaceOperations.verify_face_to_person
Verify whether two faces belong to a same person. Compares a face Id with a Person Id. :param face_id: FaceId of the face, comes from Face - Detect :type face_id: str :param person_id: Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. :type person_id: str :param person_group_id: Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type person_group_id: str :param large_person_group_id: Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type large_person_group_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: VerifyResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.VerifyResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>`
azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py
def verify_face_to_person( self, face_id, person_id, person_group_id=None, large_person_group_id=None, custom_headers=None, raw=False, **operation_config): """Verify whether two faces belong to a same person. Compares a face Id with a Person Id. :param face_id: FaceId of the face, comes from Face - Detect :type face_id: str :param person_id: Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. :type person_id: str :param person_group_id: Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type person_group_id: str :param large_person_group_id: Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type large_person_group_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: VerifyResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.VerifyResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.VerifyFaceToPersonRequest(face_id=face_id, person_group_id=person_group_id, large_person_group_id=large_person_group_id, person_id=person_id) # Construct URL url = self.verify_face_to_person.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'VerifyFaceToPersonRequest') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('VerifyResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def verify_face_to_person( self, face_id, person_id, person_group_id=None, large_person_group_id=None, custom_headers=None, raw=False, **operation_config): """Verify whether two faces belong to a same person. Compares a face Id with a Person Id. :param face_id: FaceId of the face, comes from Face - Detect :type face_id: str :param person_id: Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. :type person_id: str :param person_group_id: Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type person_group_id: str :param large_person_group_id: Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. :type large_person_group_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: VerifyResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.face.models.VerifyResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`APIErrorException<azure.cognitiveservices.vision.face.models.APIErrorException>` """ body = models.VerifyFaceToPersonRequest(face_id=face_id, person_group_id=person_group_id, large_person_group_id=large_person_group_id, person_id=person_id) # Construct URL url = self.verify_face_to_person.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'VerifyFaceToPersonRequest') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.APIErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('VerifyResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "Verify", "whether", "two", "faces", "belong", "to", "a", "same", "person", ".", "Compares", "a", "face", "Id", "with", "a", "Person", "Id", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/face_operations.py#L535-L605
[ "def", "verify_face_to_person", "(", "self", ",", "face_id", ",", "person_id", ",", "person_group_id", "=", "None", ",", "large_person_group_id", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "body", "=", "models", ".", "VerifyFaceToPersonRequest", "(", "face_id", "=", "face_id", ",", "person_group_id", "=", "person_group_id", ",", "large_person_group_id", "=", "large_person_group_id", ",", "person_id", "=", "person_id", ")", "# Construct URL", "url", "=", "self", ".", "verify_face_to_person", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'Endpoint'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.endpoint\"", ",", "self", ".", "config", ".", "endpoint", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; charset=utf-8'", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "body", ",", "'VerifyFaceToPersonRequest'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "APIErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'VerifyResult'", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
get_challenge_for_url
Gets the challenge for the cached URL. :param url: the URL the challenge is cached for. :rtype: HttpBearerChallenge
azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py
def get_challenge_for_url(url): """ Gets the challenge for the cached URL. :param url: the URL the challenge is cached for. :rtype: HttpBearerChallenge """ if not url: raise ValueError('URL cannot be None') url = parse.urlparse(url) _lock.acquire() val = _cache.get(url.netloc) _lock.release() return val
def get_challenge_for_url(url): """ Gets the challenge for the cached URL. :param url: the URL the challenge is cached for. :rtype: HttpBearerChallenge """ if not url: raise ValueError('URL cannot be None') url = parse.urlparse(url) _lock.acquire() val = _cache.get(url.netloc) _lock.release() return val
[ "Gets", "the", "challenge", "for", "the", "cached", "URL", ".", ":", "param", "url", ":", "the", "URL", "the", "challenge", "is", "cached", "for", ".", ":", "rtype", ":", "HttpBearerChallenge" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py#L16-L31
[ "def", "get_challenge_for_url", "(", "url", ")", ":", "if", "not", "url", ":", "raise", "ValueError", "(", "'URL cannot be None'", ")", "url", "=", "parse", ".", "urlparse", "(", "url", ")", "_lock", ".", "acquire", "(", ")", "val", "=", "_cache", ".", "get", "(", "url", ".", "netloc", ")", "_lock", ".", "release", "(", ")", "return", "val" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
remove_challenge_for_url
Removes the cached challenge for the specified URL. :param url: the URL for which to remove the cached challenge
azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py
def remove_challenge_for_url(url): """ Removes the cached challenge for the specified URL. :param url: the URL for which to remove the cached challenge """ if not url: raise ValueError('URL cannot be empty') url = parse.urlparse(url) _lock.acquire() del _cache[url.netloc] _lock.release()
def remove_challenge_for_url(url): """ Removes the cached challenge for the specified URL. :param url: the URL for which to remove the cached challenge """ if not url: raise ValueError('URL cannot be empty') url = parse.urlparse(url) _lock.acquire() del _cache[url.netloc] _lock.release()
[ "Removes", "the", "cached", "challenge", "for", "the", "specified", "URL", ".", ":", "param", "url", ":", "the", "URL", "for", "which", "to", "remove", "the", "cached", "challenge" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py#L34-L46
[ "def", "remove_challenge_for_url", "(", "url", ")", ":", "if", "not", "url", ":", "raise", "ValueError", "(", "'URL cannot be empty'", ")", "url", "=", "parse", ".", "urlparse", "(", "url", ")", "_lock", ".", "acquire", "(", ")", "del", "_cache", "[", "url", ".", "netloc", "]", "_lock", ".", "release", "(", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
set_challenge_for_url
Caches the challenge for the specified URL. :param url: the URL for which to cache the challenge :param challenge: the challenge to cache
azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py
def set_challenge_for_url(url, challenge): """ Caches the challenge for the specified URL. :param url: the URL for which to cache the challenge :param challenge: the challenge to cache """ if not url: raise ValueError('URL cannot be empty') if not challenge: raise ValueError('Challenge cannot be empty') src_url = parse.urlparse(url) if src_url.netloc != challenge.source_authority: raise ValueError('Source URL and Challenge URL do not match') _lock.acquire() _cache[src_url.netloc] = challenge _lock.release()
def set_challenge_for_url(url, challenge): """ Caches the challenge for the specified URL. :param url: the URL for which to cache the challenge :param challenge: the challenge to cache """ if not url: raise ValueError('URL cannot be empty') if not challenge: raise ValueError('Challenge cannot be empty') src_url = parse.urlparse(url) if src_url.netloc != challenge.source_authority: raise ValueError('Source URL and Challenge URL do not match') _lock.acquire() _cache[src_url.netloc] = challenge _lock.release()
[ "Caches", "the", "challenge", "for", "the", "specified", "URL", ".", ":", "param", "url", ":", "the", "URL", "for", "which", "to", "cache", "the", "challenge", ":", "param", "challenge", ":", "the", "challenge", "to", "cache" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/http_bearer_challenge_cache/__init__.py#L49-L67
[ "def", "set_challenge_for_url", "(", "url", ",", "challenge", ")", ":", "if", "not", "url", ":", "raise", "ValueError", "(", "'URL cannot be empty'", ")", "if", "not", "challenge", ":", "raise", "ValueError", "(", "'Challenge cannot be empty'", ")", "src_url", "=", "parse", ".", "urlparse", "(", "url", ")", "if", "src_url", ".", "netloc", "!=", "challenge", ".", "source_authority", ":", "raise", "ValueError", "(", "'Source URL and Challenge URL do not match'", ")", "_lock", ".", "acquire", "(", ")", "_cache", "[", "src_url", ".", "netloc", "]", "=", "challenge", "_lock", ".", "release", "(", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
JobOperations.get
Gets information about the specified job. :param job_id: The ID of the job. :type job_id: str :param job_get_options: Additional parameters for the operation :type job_get_options: ~azure.batch.models.JobGetOptions :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: CloudJob or ClientRawResponse if raw=true :rtype: ~azure.batch.models.CloudJob or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>`
azure-batch/azure/batch/operations/job_operations.py
def get( self, job_id, job_get_options=None, custom_headers=None, raw=False, **operation_config): """Gets information about the specified job. :param job_id: The ID of the job. :type job_id: str :param job_get_options: Additional parameters for the operation :type job_get_options: ~azure.batch.models.JobGetOptions :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: CloudJob or ClientRawResponse if raw=true :rtype: ~azure.batch.models.CloudJob or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ select = None if job_get_options is not None: select = job_get_options.select expand = None if job_get_options is not None: expand = job_get_options.expand timeout = None if job_get_options is not None: timeout = job_get_options.timeout client_request_id = None if job_get_options is not None: client_request_id = job_get_options.client_request_id return_client_request_id = None if job_get_options is not None: return_client_request_id = job_get_options.return_client_request_id ocp_date = None if job_get_options is not None: ocp_date = job_get_options.ocp_date if_match = None if job_get_options is not None: if_match = job_get_options.if_match if_none_match = None if job_get_options is not None: if_none_match = job_get_options.if_none_match if_modified_since = None if job_get_options is not None: if_modified_since = job_get_options.if_modified_since if_unmodified_since = None if job_get_options is not None: if_unmodified_since = job_get_options.if_unmodified_since # Construct URL url = self.get.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 'jobId': self._serialize.url("job_id", job_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if expand is not None: query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') if if_modified_since is not None: header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') if if_unmodified_since is not None: header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) deserialized = None header_dict = {} if response.status_code == 200: deserialized = self._deserialize('CloudJob', response) header_dict = { 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', } if raw: client_raw_response = ClientRawResponse(deserialized, response) client_raw_response.add_headers(header_dict) return client_raw_response return deserialized
def get( self, job_id, job_get_options=None, custom_headers=None, raw=False, **operation_config): """Gets information about the specified job. :param job_id: The ID of the job. :type job_id: str :param job_get_options: Additional parameters for the operation :type job_get_options: ~azure.batch.models.JobGetOptions :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: CloudJob or ClientRawResponse if raw=true :rtype: ~azure.batch.models.CloudJob or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ select = None if job_get_options is not None: select = job_get_options.select expand = None if job_get_options is not None: expand = job_get_options.expand timeout = None if job_get_options is not None: timeout = job_get_options.timeout client_request_id = None if job_get_options is not None: client_request_id = job_get_options.client_request_id return_client_request_id = None if job_get_options is not None: return_client_request_id = job_get_options.return_client_request_id ocp_date = None if job_get_options is not None: ocp_date = job_get_options.ocp_date if_match = None if job_get_options is not None: if_match = job_get_options.if_match if_none_match = None if job_get_options is not None: if_none_match = job_get_options.if_none_match if_modified_since = None if job_get_options is not None: if_modified_since = job_get_options.if_modified_since if_unmodified_since = None if job_get_options is not None: if_unmodified_since = job_get_options.if_unmodified_since # Construct URL url = self.get.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 'jobId': self._serialize.url("job_id", job_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if expand is not None: query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') if if_modified_since is not None: header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') if if_unmodified_since is not None: header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) deserialized = None header_dict = {} if response.status_code == 200: deserialized = self._deserialize('CloudJob', response) header_dict = { 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', } if raw: client_raw_response = ClientRawResponse(deserialized, response) client_raw_response.add_headers(header_dict) return client_raw_response return deserialized
[ "Gets", "information", "about", "the", "specified", "job", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/operations/job_operations.py#L240-L356
[ "def", "get", "(", "self", ",", "job_id", ",", "job_get_options", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "select", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "select", "=", "job_get_options", ".", "select", "expand", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "expand", "=", "job_get_options", ".", "expand", "timeout", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "timeout", "=", "job_get_options", ".", "timeout", "client_request_id", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "client_request_id", "=", "job_get_options", ".", "client_request_id", "return_client_request_id", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "return_client_request_id", "=", "job_get_options", ".", "return_client_request_id", "ocp_date", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "ocp_date", "=", "job_get_options", ".", "ocp_date", "if_match", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "if_match", "=", "job_get_options", ".", "if_match", "if_none_match", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "if_none_match", "=", "job_get_options", ".", "if_none_match", "if_modified_since", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "if_modified_since", "=", "job_get_options", ".", "if_modified_since", "if_unmodified_since", "=", "None", "if", "job_get_options", "is", "not", "None", ":", "if_unmodified_since", "=", "job_get_options", ".", "if_unmodified_since", "# Construct URL", "url", "=", "self", ".", "get", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'batchUrl'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.batch_url\"", ",", "self", ".", "config", ".", "batch_url", ",", "'str'", ",", "skip_quote", "=", "True", ")", ",", "'jobId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"job_id\"", ",", "job_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "if", "select", "is", "not", "None", ":", "query_parameters", "[", "'$select'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"select\"", ",", "select", ",", "'str'", ")", "if", "expand", "is", "not", "None", ":", "query_parameters", "[", "'$expand'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"expand\"", ",", "expand", ",", "'str'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'int'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "if", "client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_request_id\"", ",", "client_request_id", ",", "'str'", ")", "if", "return_client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'return-client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"return_client_request_id\"", ",", "return_client_request_id", ",", "'bool'", ")", "if", "ocp_date", "is", "not", "None", ":", "header_parameters", "[", "'ocp-date'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"ocp_date\"", ",", "ocp_date", ",", "'rfc-1123'", ")", "if", "if_match", "is", "not", "None", ":", "header_parameters", "[", "'If-Match'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_match\"", ",", "if_match", ",", "'str'", ")", "if", "if_none_match", "is", "not", "None", ":", "header_parameters", "[", "'If-None-Match'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_none_match\"", ",", "if_none_match", ",", "'str'", ")", "if", "if_modified_since", "is", "not", "None", ":", "header_parameters", "[", "'If-Modified-Since'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_modified_since\"", ",", "if_modified_since", ",", "'rfc-1123'", ")", "if", "if_unmodified_since", "is", "not", "None", ":", "header_parameters", "[", "'If-Unmodified-Since'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_unmodified_since\"", ",", "if_unmodified_since", ",", "'rfc-1123'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "get", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "BatchErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "deserialized", "=", "None", "header_dict", "=", "{", "}", "if", "response", ".", "status_code", "==", "200", ":", "deserialized", "=", "self", ".", "_deserialize", "(", "'CloudJob'", ",", "response", ")", "header_dict", "=", "{", "'client-request-id'", ":", "'str'", ",", "'request-id'", ":", "'str'", ",", "'ETag'", ":", "'str'", ",", "'Last-Modified'", ":", "'rfc-1123'", ",", "}", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "deserialized", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "header_dict", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
JobOperations.patch
Updates the properties of the specified job. This replaces only the job properties specified in the request. For example, if the job has constraints, and a request does not specify the constraints element, then the job keeps the existing constraints. :param job_id: The ID of the job whose properties you want to update. :type job_id: str :param job_patch_parameter: The parameters for the request. :type job_patch_parameter: ~azure.batch.models.JobPatchParameter :param job_patch_options: Additional parameters for the operation :type job_patch_options: ~azure.batch.models.JobPatchOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>`
azure-batch/azure/batch/operations/job_operations.py
def patch( self, job_id, job_patch_parameter, job_patch_options=None, custom_headers=None, raw=False, **operation_config): """Updates the properties of the specified job. This replaces only the job properties specified in the request. For example, if the job has constraints, and a request does not specify the constraints element, then the job keeps the existing constraints. :param job_id: The ID of the job whose properties you want to update. :type job_id: str :param job_patch_parameter: The parameters for the request. :type job_patch_parameter: ~azure.batch.models.JobPatchParameter :param job_patch_options: Additional parameters for the operation :type job_patch_options: ~azure.batch.models.JobPatchOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ timeout = None if job_patch_options is not None: timeout = job_patch_options.timeout client_request_id = None if job_patch_options is not None: client_request_id = job_patch_options.client_request_id return_client_request_id = None if job_patch_options is not None: return_client_request_id = job_patch_options.return_client_request_id ocp_date = None if job_patch_options is not None: ocp_date = job_patch_options.ocp_date if_match = None if job_patch_options is not None: if_match = job_patch_options.if_match if_none_match = None if job_patch_options is not None: if_none_match = job_patch_options.if_none_match if_modified_since = None if job_patch_options is not None: if_modified_since = job_patch_options.if_modified_since if_unmodified_since = None if job_patch_options is not None: if_unmodified_since = job_patch_options.if_unmodified_since # Construct URL url = self.patch.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 'jobId': self._serialize.url("job_id", job_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') if if_modified_since is not None: header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') if if_unmodified_since is not None: header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') # Construct body body_content = self._serialize.body(job_patch_parameter, 'JobPatchParameter') # Construct and send request request = self._client.patch(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', 'DataServiceId': 'str', }) return client_raw_response
def patch( self, job_id, job_patch_parameter, job_patch_options=None, custom_headers=None, raw=False, **operation_config): """Updates the properties of the specified job. This replaces only the job properties specified in the request. For example, if the job has constraints, and a request does not specify the constraints element, then the job keeps the existing constraints. :param job_id: The ID of the job whose properties you want to update. :type job_id: str :param job_patch_parameter: The parameters for the request. :type job_patch_parameter: ~azure.batch.models.JobPatchParameter :param job_patch_options: Additional parameters for the operation :type job_patch_options: ~azure.batch.models.JobPatchOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ timeout = None if job_patch_options is not None: timeout = job_patch_options.timeout client_request_id = None if job_patch_options is not None: client_request_id = job_patch_options.client_request_id return_client_request_id = None if job_patch_options is not None: return_client_request_id = job_patch_options.return_client_request_id ocp_date = None if job_patch_options is not None: ocp_date = job_patch_options.ocp_date if_match = None if job_patch_options is not None: if_match = job_patch_options.if_match if_none_match = None if job_patch_options is not None: if_none_match = job_patch_options.if_none_match if_modified_since = None if job_patch_options is not None: if_modified_since = job_patch_options.if_modified_since if_unmodified_since = None if job_patch_options is not None: if_unmodified_since = job_patch_options.if_unmodified_since # Construct URL url = self.patch.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True), 'jobId': self._serialize.url("job_id", job_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') if if_none_match is not None: header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') if if_modified_since is not None: header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') if if_unmodified_since is not None: header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') # Construct body body_content = self._serialize.body(job_patch_parameter, 'JobPatchParameter') # Construct and send request request = self._client.patch(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', 'DataServiceId': 'str', }) return client_raw_response
[ "Updates", "the", "properties", "of", "the", "specified", "job", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/operations/job_operations.py#L359-L465
[ "def", "patch", "(", "self", ",", "job_id", ",", "job_patch_parameter", ",", "job_patch_options", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "timeout", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "timeout", "=", "job_patch_options", ".", "timeout", "client_request_id", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "client_request_id", "=", "job_patch_options", ".", "client_request_id", "return_client_request_id", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "return_client_request_id", "=", "job_patch_options", ".", "return_client_request_id", "ocp_date", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "ocp_date", "=", "job_patch_options", ".", "ocp_date", "if_match", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "if_match", "=", "job_patch_options", ".", "if_match", "if_none_match", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "if_none_match", "=", "job_patch_options", ".", "if_none_match", "if_modified_since", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "if_modified_since", "=", "job_patch_options", ".", "if_modified_since", "if_unmodified_since", "=", "None", "if", "job_patch_options", "is", "not", "None", ":", "if_unmodified_since", "=", "job_patch_options", ".", "if_unmodified_since", "# Construct URL", "url", "=", "self", ".", "patch", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'batchUrl'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.batch_url\"", ",", "self", ".", "config", ".", "batch_url", ",", "'str'", ",", "skip_quote", "=", "True", ")", ",", "'jobId'", ":", "self", ".", "_serialize", ".", "url", "(", "\"job_id\"", ",", "job_id", ",", "'str'", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'int'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; odata=minimalmetadata; charset=utf-8'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "if", "client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_request_id\"", ",", "client_request_id", ",", "'str'", ")", "if", "return_client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'return-client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"return_client_request_id\"", ",", "return_client_request_id", ",", "'bool'", ")", "if", "ocp_date", "is", "not", "None", ":", "header_parameters", "[", "'ocp-date'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"ocp_date\"", ",", "ocp_date", ",", "'rfc-1123'", ")", "if", "if_match", "is", "not", "None", ":", "header_parameters", "[", "'If-Match'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_match\"", ",", "if_match", ",", "'str'", ")", "if", "if_none_match", "is", "not", "None", ":", "header_parameters", "[", "'If-None-Match'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_none_match\"", ",", "if_none_match", ",", "'str'", ")", "if", "if_modified_since", "is", "not", "None", ":", "header_parameters", "[", "'If-Modified-Since'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_modified_since\"", ",", "if_modified_since", ",", "'rfc-1123'", ")", "if", "if_unmodified_since", "is", "not", "None", ":", "header_parameters", "[", "'If-Unmodified-Since'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"if_unmodified_since\"", ",", "if_unmodified_since", ",", "'rfc-1123'", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "job_patch_parameter", ",", "'JobPatchParameter'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "patch", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "BatchErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "{", "'client-request-id'", ":", "'str'", ",", "'request-id'", ":", "'str'", ",", "'ETag'", ":", "'str'", ",", "'Last-Modified'", ":", "'rfc-1123'", ",", "'DataServiceId'", ":", "'str'", ",", "}", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
JobOperations.add
Adds a job to the specified account. The Batch service supports two ways to control the work done as part of a job. In the first approach, the user specifies a Job Manager task. The Batch service launches this task when it is ready to start the job. The Job Manager task controls all other tasks that run under this job, by using the Task APIs. In the second approach, the user directly controls the execution of tasks under an active job, by using the Task APIs. Also note: when naming jobs, avoid including sensitive information such as user names or secret project names. This information may appear in telemetry logs accessible to Microsoft Support engineers. :param job: The job to be added. :type job: ~azure.batch.models.JobAddParameter :param job_add_options: Additional parameters for the operation :type job_add_options: ~azure.batch.models.JobAddOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>`
azure-batch/azure/batch/operations/job_operations.py
def add( self, job, job_add_options=None, custom_headers=None, raw=False, **operation_config): """Adds a job to the specified account. The Batch service supports two ways to control the work done as part of a job. In the first approach, the user specifies a Job Manager task. The Batch service launches this task when it is ready to start the job. The Job Manager task controls all other tasks that run under this job, by using the Task APIs. In the second approach, the user directly controls the execution of tasks under an active job, by using the Task APIs. Also note: when naming jobs, avoid including sensitive information such as user names or secret project names. This information may appear in telemetry logs accessible to Microsoft Support engineers. :param job: The job to be added. :type job: ~azure.batch.models.JobAddParameter :param job_add_options: Additional parameters for the operation :type job_add_options: ~azure.batch.models.JobAddOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ timeout = None if job_add_options is not None: timeout = job_add_options.timeout client_request_id = None if job_add_options is not None: client_request_id = job_add_options.client_request_id return_client_request_id = None if job_add_options is not None: return_client_request_id = job_add_options.return_client_request_id ocp_date = None if job_add_options is not None: ocp_date = job_add_options.ocp_date # Construct URL url = self.add.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') # Construct body body_content = self._serialize.body(job, 'JobAddParameter') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [201]: raise models.BatchErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', 'DataServiceId': 'str', }) return client_raw_response
def add( self, job, job_add_options=None, custom_headers=None, raw=False, **operation_config): """Adds a job to the specified account. The Batch service supports two ways to control the work done as part of a job. In the first approach, the user specifies a Job Manager task. The Batch service launches this task when it is ready to start the job. The Job Manager task controls all other tasks that run under this job, by using the Task APIs. In the second approach, the user directly controls the execution of tasks under an active job, by using the Task APIs. Also note: when naming jobs, avoid including sensitive information such as user names or secret project names. This information may appear in telemetry logs accessible to Microsoft Support engineers. :param job: The job to be added. :type job: ~azure.batch.models.JobAddParameter :param job_add_options: Additional parameters for the operation :type job_add_options: ~azure.batch.models.JobAddOptions :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ timeout = None if job_add_options is not None: timeout = job_add_options.timeout client_request_id = None if job_add_options is not None: client_request_id = job_add_options.client_request_id return_client_request_id = None if job_add_options is not None: return_client_request_id = job_add_options.return_client_request_id ocp_date = None if job_add_options is not None: ocp_date = job_add_options.ocp_date # Construct URL url = self.add.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; odata=minimalmetadata; charset=utf-8' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') # Construct body body_content = self._serialize.body(job, 'JobAddParameter') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [201]: raise models.BatchErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'client-request-id': 'str', 'request-id': 'str', 'ETag': 'str', 'Last-Modified': 'rfc-1123', 'DataServiceId': 'str', }) return client_raw_response
[ "Adds", "a", "job", "to", "the", "specified", "account", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/operations/job_operations.py#L922-L1012
[ "def", "add", "(", "self", ",", "job", ",", "job_add_options", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "timeout", "=", "None", "if", "job_add_options", "is", "not", "None", ":", "timeout", "=", "job_add_options", ".", "timeout", "client_request_id", "=", "None", "if", "job_add_options", "is", "not", "None", ":", "client_request_id", "=", "job_add_options", ".", "client_request_id", "return_client_request_id", "=", "None", "if", "job_add_options", "is", "not", "None", ":", "return_client_request_id", "=", "job_add_options", ".", "return_client_request_id", "ocp_date", "=", "None", "if", "job_add_options", "is", "not", "None", ":", "ocp_date", "=", "job_add_options", ".", "ocp_date", "# Construct URL", "url", "=", "self", ".", "add", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'batchUrl'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.batch_url\"", ",", "self", ".", "config", ".", "batch_url", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'int'", ")", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Content-Type'", "]", "=", "'application/json; odata=minimalmetadata; charset=utf-8'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "if", "client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_request_id\"", ",", "client_request_id", ",", "'str'", ")", "if", "return_client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'return-client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"return_client_request_id\"", ",", "return_client_request_id", ",", "'bool'", ")", "if", "ocp_date", "is", "not", "None", ":", "header_parameters", "[", "'ocp-date'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"ocp_date\"", ",", "ocp_date", ",", "'rfc-1123'", ")", "# Construct body", "body_content", "=", "self", ".", "_serialize", ".", "body", "(", "job", ",", "'JobAddParameter'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "post", "(", "url", ",", "query_parameters", ",", "header_parameters", ",", "body_content", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "201", "]", ":", "raise", "models", ".", "BatchErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "if", "raw", ":", "client_raw_response", "=", "ClientRawResponse", "(", "None", ",", "response", ")", "client_raw_response", ".", "add_headers", "(", "{", "'client-request-id'", ":", "'str'", ",", "'request-id'", ":", "'str'", ",", "'ETag'", ":", "'str'", ",", "'Last-Modified'", ":", "'rfc-1123'", ",", "'DataServiceId'", ":", "'str'", ",", "}", ")", "return", "client_raw_response" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
JobOperations.list
Lists all of the jobs in the specified account. :param job_list_options: Additional parameters for the operation :type job_list_options: ~azure.batch.models.JobListOptions :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 CloudJob :rtype: ~azure.batch.models.CloudJobPaged[~azure.batch.models.CloudJob] :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>`
azure-batch/azure/batch/operations/job_operations.py
def list( self, job_list_options=None, custom_headers=None, raw=False, **operation_config): """Lists all of the jobs in the specified account. :param job_list_options: Additional parameters for the operation :type job_list_options: ~azure.batch.models.JobListOptions :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 CloudJob :rtype: ~azure.batch.models.CloudJobPaged[~azure.batch.models.CloudJob] :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ filter = None if job_list_options is not None: filter = job_list_options.filter select = None if job_list_options is not None: select = job_list_options.select expand = None if job_list_options is not None: expand = job_list_options.expand max_results = None if job_list_options is not None: max_results = job_list_options.max_results timeout = None if job_list_options is not None: timeout = job_list_options.timeout client_request_id = None if job_list_options is not None: client_request_id = job_list_options.client_request_id return_client_request_id = None if job_list_options is not None: return_client_request_id = job_list_options.return_client_request_id ocp_date = None if job_list_options is not None: ocp_date = job_list_options.ocp_date def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if expand is not None: query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') if max_results is not None: query_parameters['maxresults'] = self._serialize.query("max_results", max_results, 'int', maximum=1000, minimum=1) if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.CloudJobPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.CloudJobPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
def list( self, job_list_options=None, custom_headers=None, raw=False, **operation_config): """Lists all of the jobs in the specified account. :param job_list_options: Additional parameters for the operation :type job_list_options: ~azure.batch.models.JobListOptions :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 CloudJob :rtype: ~azure.batch.models.CloudJobPaged[~azure.batch.models.CloudJob] :raises: :class:`BatchErrorException<azure.batch.models.BatchErrorException>` """ filter = None if job_list_options is not None: filter = job_list_options.filter select = None if job_list_options is not None: select = job_list_options.select expand = None if job_list_options is not None: expand = job_list_options.expand max_results = None if job_list_options is not None: max_results = job_list_options.max_results timeout = None if job_list_options is not None: timeout = job_list_options.timeout client_request_id = None if job_list_options is not None: client_request_id = job_list_options.client_request_id return_client_request_id = None if job_list_options is not None: return_client_request_id = job_list_options.return_client_request_id ocp_date = None if job_list_options is not None: ocp_date = job_list_options.ocp_date def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = self.list.metadata['url'] path_format_arguments = { 'batchUrl': self._serialize.url("self.config.batch_url", self.config.batch_url, 'str', skip_quote=True) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') if expand is not None: query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') if max_results is not None: query_parameters['maxresults'] = self._serialize.query("max_results", max_results, 'int', maximum=1000, minimum=1) if timeout is not None: query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if self.config.generate_client_request_id: header_parameters['client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') if client_request_id is not None: header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') if return_client_request_id is not None: header_parameters['return-client-request-id'] = self._serialize.header("return_client_request_id", return_client_request_id, 'bool') if ocp_date is not None: header_parameters['ocp-date'] = self._serialize.header("ocp_date", ocp_date, 'rfc-1123') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.BatchErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.CloudJobPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.CloudJobPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
[ "Lists", "all", "of", "the", "jobs", "in", "the", "specified", "account", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-batch/azure/batch/operations/job_operations.py#L1015-L1118
[ "def", "list", "(", "self", ",", "job_list_options", "=", "None", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operation_config", ")", ":", "filter", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "filter", "=", "job_list_options", ".", "filter", "select", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "select", "=", "job_list_options", ".", "select", "expand", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "expand", "=", "job_list_options", ".", "expand", "max_results", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "max_results", "=", "job_list_options", ".", "max_results", "timeout", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "timeout", "=", "job_list_options", ".", "timeout", "client_request_id", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "client_request_id", "=", "job_list_options", ".", "client_request_id", "return_client_request_id", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "return_client_request_id", "=", "job_list_options", ".", "return_client_request_id", "ocp_date", "=", "None", "if", "job_list_options", "is", "not", "None", ":", "ocp_date", "=", "job_list_options", ".", "ocp_date", "def", "internal_paging", "(", "next_link", "=", "None", ",", "raw", "=", "False", ")", ":", "if", "not", "next_link", ":", "# Construct URL", "url", "=", "self", ".", "list", ".", "metadata", "[", "'url'", "]", "path_format_arguments", "=", "{", "'batchUrl'", ":", "self", ".", "_serialize", ".", "url", "(", "\"self.config.batch_url\"", ",", "self", ".", "config", ".", "batch_url", ",", "'str'", ",", "skip_quote", "=", "True", ")", "}", "url", "=", "self", ".", "_client", ".", "format_url", "(", "url", ",", "*", "*", "path_format_arguments", ")", "# Construct parameters", "query_parameters", "=", "{", "}", "query_parameters", "[", "'api-version'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"self.api_version\"", ",", "self", ".", "api_version", ",", "'str'", ")", "if", "filter", "is", "not", "None", ":", "query_parameters", "[", "'$filter'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"filter\"", ",", "filter", ",", "'str'", ")", "if", "select", "is", "not", "None", ":", "query_parameters", "[", "'$select'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"select\"", ",", "select", ",", "'str'", ")", "if", "expand", "is", "not", "None", ":", "query_parameters", "[", "'$expand'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"expand\"", ",", "expand", ",", "'str'", ")", "if", "max_results", "is", "not", "None", ":", "query_parameters", "[", "'maxresults'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"max_results\"", ",", "max_results", ",", "'int'", ",", "maximum", "=", "1000", ",", "minimum", "=", "1", ")", "if", "timeout", "is", "not", "None", ":", "query_parameters", "[", "'timeout'", "]", "=", "self", ".", "_serialize", ".", "query", "(", "\"timeout\"", ",", "timeout", ",", "'int'", ")", "else", ":", "url", "=", "next_link", "query_parameters", "=", "{", "}", "# Construct headers", "header_parameters", "=", "{", "}", "header_parameters", "[", "'Accept'", "]", "=", "'application/json'", "if", "self", ".", "config", ".", "generate_client_request_id", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "custom_headers", ":", "header_parameters", ".", "update", "(", "custom_headers", ")", "if", "self", ".", "config", ".", "accept_language", "is", "not", "None", ":", "header_parameters", "[", "'accept-language'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"self.config.accept_language\"", ",", "self", ".", "config", ".", "accept_language", ",", "'str'", ")", "if", "client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"client_request_id\"", ",", "client_request_id", ",", "'str'", ")", "if", "return_client_request_id", "is", "not", "None", ":", "header_parameters", "[", "'return-client-request-id'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"return_client_request_id\"", ",", "return_client_request_id", ",", "'bool'", ")", "if", "ocp_date", "is", "not", "None", ":", "header_parameters", "[", "'ocp-date'", "]", "=", "self", ".", "_serialize", ".", "header", "(", "\"ocp_date\"", ",", "ocp_date", ",", "'rfc-1123'", ")", "# Construct and send request", "request", "=", "self", ".", "_client", ".", "get", "(", "url", ",", "query_parameters", ",", "header_parameters", ")", "response", "=", "self", ".", "_client", ".", "send", "(", "request", ",", "stream", "=", "False", ",", "*", "*", "operation_config", ")", "if", "response", ".", "status_code", "not", "in", "[", "200", "]", ":", "raise", "models", ".", "BatchErrorException", "(", "self", ".", "_deserialize", ",", "response", ")", "return", "response", "# Deserialize response", "deserialized", "=", "models", ".", "CloudJobPaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ")", "if", "raw", ":", "header_dict", "=", "{", "}", "client_raw_response", "=", "models", ".", "CloudJobPaged", "(", "internal_paging", ",", "self", ".", "_deserialize", ".", "dependencies", ",", "header_dict", ")", "return", "client_raw_response", "return", "deserialized" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.models
Module depends on the API version: * 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>` * 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>` * 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>` * 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>` * 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>` * 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>` * 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>` """ if api_version == '2015-06-01': from .v2015_06_01 import models return models elif api_version == '2015-07-01': from .v2015_07_01 import models return models elif api_version == '2018-01-01-preview': from .v2018_01_01_preview import models return models elif api_version == '2018-07-01-preview': from .v2018_07_01_preview import models return models elif api_version == '2018-09-01-preview': from .v2018_09_01_preview import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>` * 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>` * 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>` * 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>` """ if api_version == '2015-06-01': from .v2015_06_01 import models return models elif api_version == '2015-07-01': from .v2015_07_01 import models return models elif api_version == '2018-01-01-preview': from .v2018_01_01_preview import models return models elif api_version == '2018-07-01-preview': from .v2018_07_01_preview import models return models elif api_version == '2018-09-01-preview': from .v2018_09_01_preview import models return models raise NotImplementedError("APIVersion {} is not available".format(api_version))
[ "Module", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L109-L133
[ "def", "models", "(", "cls", ",", "api_version", "=", "DEFAULT_API_VERSION", ")", ":", "if", "api_version", "==", "'2015-06-01'", ":", "from", ".", "v2015_06_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2015-07-01'", ":", "from", ".", "v2015_07_01", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-07-01-preview'", ":", "from", ".", "v2018_07_01_preview", "import", "models", "return", "models", "elif", "api_version", "==", "'2018-09-01-preview'", ":", "from", ".", "v2018_09_01_preview", "import", "models", "return", "models", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.classic_administrators
Instance depends on the API version: * 2015-06-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def classic_administrators(self): """Instance depends on the API version: * 2015-06-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations>` """ api_version = self._get_api_version('classic_administrators') if api_version == '2015-06-01': from .v2015_06_01.operations import ClassicAdministratorsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def classic_administrators(self): """Instance depends on the API version: * 2015-06-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations>` """ api_version = self._get_api_version('classic_administrators') if api_version == '2015-06-01': from .v2015_06_01.operations import ClassicAdministratorsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L136-L146
[ "def", "classic_administrators", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'classic_administrators'", ")", "if", "api_version", "==", "'2015-06-01'", ":", "from", ".", "v2015_06_01", ".", "operations", "import", "ClassicAdministratorsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.deny_assignments
Instance depends on the API version: * 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def deny_assignments(self): """Instance depends on the API version: * 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations>` """ api_version = self._get_api_version('deny_assignments') if api_version == '2018-07-01-preview': from .v2018_07_01_preview.operations import DenyAssignmentsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def deny_assignments(self): """Instance depends on the API version: * 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations>` """ api_version = self._get_api_version('deny_assignments') if api_version == '2018-07-01-preview': from .v2018_07_01_preview.operations import DenyAssignmentsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L149-L159
[ "def", "deny_assignments", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'deny_assignments'", ")", "if", "api_version", "==", "'2018-07-01-preview'", ":", "from", ".", "v2018_07_01_preview", ".", "operations", "import", "DenyAssignmentsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.permissions
Instance depends on the API version: * 2015-07-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2015_07_01.operations.PermissionsOperations>` * 2018-01-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def permissions(self): """Instance depends on the API version: * 2015-07-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2015_07_01.operations.PermissionsOperations>` * 2018-01-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations>` """ api_version = self._get_api_version('permissions') if api_version == '2015-07-01': from .v2015_07_01.operations import PermissionsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import PermissionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def permissions(self): """Instance depends on the API version: * 2015-07-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2015_07_01.operations.PermissionsOperations>` * 2018-01-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations>` """ api_version = self._get_api_version('permissions') if api_version == '2015-07-01': from .v2015_07_01.operations import PermissionsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import PermissionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L162-L175
[ "def", "permissions", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'permissions'", ")", "if", "api_version", "==", "'2015-07-01'", ":", "from", ".", "v2015_07_01", ".", "operations", "import", "PermissionsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "PermissionsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.provider_operations_metadata
Instance depends on the API version: * 2015-07-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations>` * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def provider_operations_metadata(self): """Instance depends on the API version: * 2015-07-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations>` * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations>` """ api_version = self._get_api_version('provider_operations_metadata') if api_version == '2015-07-01': from .v2015_07_01.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ProviderOperationsMetadataOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def provider_operations_metadata(self): """Instance depends on the API version: * 2015-07-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations>` * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations>` """ api_version = self._get_api_version('provider_operations_metadata') if api_version == '2015-07-01': from .v2015_07_01.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import ProviderOperationsMetadataOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L178-L191
[ "def", "provider_operations_metadata", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'provider_operations_metadata'", ")", "if", "api_version", "==", "'2015-07-01'", ":", "from", ".", "v2015_07_01", ".", "operations", "import", "ProviderOperationsMetadataOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "ProviderOperationsMetadataOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.role_assignments
Instance depends on the API version: * 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations>` * 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations>` * 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def role_assignments(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations>` * 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations>` * 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations>` """ api_version = self._get_api_version('role_assignments') if api_version == '2015-07-01': from .v2015_07_01.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-09-01-preview': from .v2018_09_01_preview.operations import RoleAssignmentsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def role_assignments(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations>` * 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations>` * 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations>` """ api_version = self._get_api_version('role_assignments') if api_version == '2015-07-01': from .v2015_07_01.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-09-01-preview': from .v2018_09_01_preview.operations import RoleAssignmentsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L194-L210
[ "def", "role_assignments", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'role_assignments'", ")", "if", "api_version", "==", "'2015-07-01'", ":", "from", ".", "v2015_07_01", ".", "operations", "import", "RoleAssignmentsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "RoleAssignmentsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-09-01-preview'", ":", "from", ".", "v2018_09_01_preview", ".", "operations", "import", "RoleAssignmentsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
AuthorizationManagementClient.role_definitions
Instance depends on the API version: * 2015-07-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations>` * 2018-01-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations>`
azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py
def role_definitions(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations>` * 2018-01-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations>` """ api_version = self._get_api_version('role_definitions') if api_version == '2015-07-01': from .v2015_07_01.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import RoleDefinitionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
def role_definitions(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations>` * 2018-01-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations>` """ api_version = self._get_api_version('role_definitions') if api_version == '2015-07-01': from .v2015_07_01.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2018-01-01-preview': from .v2018_01_01_preview.operations import RoleDefinitionsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-authorization/azure/mgmt/authorization/authorization_management_client.py#L213-L226
[ "def", "role_definitions", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'role_definitions'", ")", "if", "api_version", "==", "'2015-07-01'", ":", "from", ".", "v2015_07_01", ".", "operations", "import", "RoleDefinitionsOperations", "as", "OperationClass", "elif", "api_version", "==", "'2018-01-01-preview'", ":", "from", ".", "v2018_01_01_preview", ".", "operations", "import", "RoleDefinitionsOperations", "as", "OperationClass", "else", ":", "raise", "NotImplementedError", "(", "\"APIVersion {} is not available\"", ".", "format", "(", "api_version", ")", ")", "return", "OperationClass", "(", "self", ".", "_client", ",", "self", ".", "config", ",", "Serializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ",", "Deserializer", "(", "self", ".", "_models_dict", "(", "api_version", ")", ")", ")" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_data_to_xml
Creates an xml fragment from the specified data. data: Array of tuples, where first: xml element name second: xml element text third: conversion function
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _data_to_xml(data): '''Creates an xml fragment from the specified data. data: Array of tuples, where first: xml element name second: xml element text third: conversion function ''' xml = '' for element in data: name = element[0] val = element[1] if len(element) > 2: converter = element[2] else: converter = None if val is not None: if converter is not None: text = _str(converter(_str(val))) else: text = _str(val) xml += ''.join(['<', name, '>', text, '</', name, '>']) return xml
def _data_to_xml(data): '''Creates an xml fragment from the specified data. data: Array of tuples, where first: xml element name second: xml element text third: conversion function ''' xml = '' for element in data: name = element[0] val = element[1] if len(element) > 2: converter = element[2] else: converter = None if val is not None: if converter is not None: text = _str(converter(_str(val))) else: text = _str(val) xml += ''.join(['<', name, '>', text, '</', name, '>']) return xml
[ "Creates", "an", "xml", "fragment", "from", "the", "specified", "data", ".", "data", ":", "Array", "of", "tuples", "where", "first", ":", "xml", "element", "name", "second", ":", "xml", "element", "text", "third", ":", "conversion", "function" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L455-L480
[ "def", "_data_to_xml", "(", "data", ")", ":", "xml", "=", "''", "for", "element", "in", "data", ":", "name", "=", "element", "[", "0", "]", "val", "=", "element", "[", "1", "]", "if", "len", "(", "element", ")", ">", "2", ":", "converter", "=", "element", "[", "2", "]", "else", ":", "converter", "=", "None", "if", "val", "is", "not", "None", ":", "if", "converter", "is", "not", "None", ":", "text", "=", "_str", "(", "converter", "(", "_str", "(", "val", ")", ")", ")", "else", ":", "text", "=", "_str", "(", "val", ")", "xml", "+=", "''", ".", "join", "(", "[", "'<'", ",", "name", ",", "'>'", ",", "text", ",", "'</'", ",", "name", ",", "'>'", "]", ")", "return", "xml" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject.parse_response
Parse the HTTPResponse's body and fill all the data into a class of return_type.
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def parse_response(response, return_type): ''' Parse the HTTPResponse's body and fill all the data into a class of return_type. ''' doc = minidom.parseString(response.body) return_obj = return_type() xml_name = return_type._xml_name if hasattr(return_type, '_xml_name') else return_type.__name__ for node in _MinidomXmlToObject.get_child_nodes(doc, xml_name): _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
def parse_response(response, return_type): ''' Parse the HTTPResponse's body and fill all the data into a class of return_type. ''' doc = minidom.parseString(response.body) return_obj = return_type() xml_name = return_type._xml_name if hasattr(return_type, '_xml_name') else return_type.__name__ for node in _MinidomXmlToObject.get_child_nodes(doc, xml_name): _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
[ "Parse", "the", "HTTPResponse", "s", "body", "and", "fill", "all", "the", "data", "into", "a", "class", "of", "return_type", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L69-L80
[ "def", "parse_response", "(", "response", ",", "return_type", ")", ":", "doc", "=", "minidom", ".", "parseString", "(", "response", ".", "body", ")", "return_obj", "=", "return_type", "(", ")", "xml_name", "=", "return_type", ".", "_xml_name", "if", "hasattr", "(", "return_type", ",", "'_xml_name'", ")", "else", "return_type", ".", "__name__", "for", "node", "in", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "doc", ",", "xml_name", ")", ":", "_MinidomXmlToObject", ".", "_fill_data_to_return_object", "(", "node", ",", "return_obj", ")", "return", "return_obj" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject.parse_service_resources_response
Parse the HTTPResponse's body and fill all the data into a class of return_type.
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def parse_service_resources_response(response, return_type): ''' Parse the HTTPResponse's body and fill all the data into a class of return_type. ''' doc = minidom.parseString(response.body) return_obj = _list_of(return_type) for node in _MinidomXmlToObject.get_children_from_path(doc, "ServiceResources", "ServiceResource"): local_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, local_obj) return_obj.append(local_obj) return return_obj
def parse_service_resources_response(response, return_type): ''' Parse the HTTPResponse's body and fill all the data into a class of return_type. ''' doc = minidom.parseString(response.body) return_obj = _list_of(return_type) for node in _MinidomXmlToObject.get_children_from_path(doc, "ServiceResources", "ServiceResource"): local_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, local_obj) return_obj.append(local_obj) return return_obj
[ "Parse", "the", "HTTPResponse", "s", "body", "and", "fill", "all", "the", "data", "into", "a", "class", "of", "return_type", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L84-L96
[ "def", "parse_service_resources_response", "(", "response", ",", "return_type", ")", ":", "doc", "=", "minidom", ".", "parseString", "(", "response", ".", "body", ")", "return_obj", "=", "_list_of", "(", "return_type", ")", "for", "node", "in", "_MinidomXmlToObject", ".", "get_children_from_path", "(", "doc", ",", "\"ServiceResources\"", ",", "\"ServiceResource\"", ")", ":", "local_obj", "=", "return_type", "(", ")", "_MinidomXmlToObject", ".", "_fill_data_to_return_object", "(", "node", ",", "local_obj", ")", "return_obj", ".", "append", "(", "local_obj", ")", "return", "return_obj" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject.get_entry_properties_from_node
get properties from entry xml
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def get_entry_properties_from_node(entry, include_id, id_prefix_to_skip=None, use_title_as_id=False): ''' get properties from entry xml ''' properties = {} etag = entry.getAttributeNS(METADATA_NS, 'etag') if etag: properties['etag'] = etag for updated in _MinidomXmlToObject.get_child_nodes(entry, 'updated'): properties['updated'] = updated.firstChild.nodeValue for name in _MinidomXmlToObject.get_children_from_path(entry, 'author', 'name'): if name.firstChild is not None: properties['author'] = name.firstChild.nodeValue if include_id: if use_title_as_id: for title in _MinidomXmlToObject.get_child_nodes(entry, 'title'): properties['name'] = title.firstChild.nodeValue else: # TODO: check if this is used for id in _MinidomXmlToObject.get_child_nodes(entry, 'id'): properties['name'] = _get_readable_id( id.firstChild.nodeValue, id_prefix_to_skip) return properties
def get_entry_properties_from_node(entry, include_id, id_prefix_to_skip=None, use_title_as_id=False): ''' get properties from entry xml ''' properties = {} etag = entry.getAttributeNS(METADATA_NS, 'etag') if etag: properties['etag'] = etag for updated in _MinidomXmlToObject.get_child_nodes(entry, 'updated'): properties['updated'] = updated.firstChild.nodeValue for name in _MinidomXmlToObject.get_children_from_path(entry, 'author', 'name'): if name.firstChild is not None: properties['author'] = name.firstChild.nodeValue if include_id: if use_title_as_id: for title in _MinidomXmlToObject.get_child_nodes(entry, 'title'): properties['name'] = title.firstChild.nodeValue else: # TODO: check if this is used for id in _MinidomXmlToObject.get_child_nodes(entry, 'id'): properties['name'] = _get_readable_id( id.firstChild.nodeValue, id_prefix_to_skip) return properties
[ "get", "properties", "from", "entry", "xml" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L141-L164
[ "def", "get_entry_properties_from_node", "(", "entry", ",", "include_id", ",", "id_prefix_to_skip", "=", "None", ",", "use_title_as_id", "=", "False", ")", ":", "properties", "=", "{", "}", "etag", "=", "entry", ".", "getAttributeNS", "(", "METADATA_NS", ",", "'etag'", ")", "if", "etag", ":", "properties", "[", "'etag'", "]", "=", "etag", "for", "updated", "in", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "entry", ",", "'updated'", ")", ":", "properties", "[", "'updated'", "]", "=", "updated", ".", "firstChild", ".", "nodeValue", "for", "name", "in", "_MinidomXmlToObject", ".", "get_children_from_path", "(", "entry", ",", "'author'", ",", "'name'", ")", ":", "if", "name", ".", "firstChild", "is", "not", "None", ":", "properties", "[", "'author'", "]", "=", "name", ".", "firstChild", ".", "nodeValue", "if", "include_id", ":", "if", "use_title_as_id", ":", "for", "title", "in", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "entry", ",", "'title'", ")", ":", "properties", "[", "'name'", "]", "=", "title", ".", "firstChild", ".", "nodeValue", "else", ":", "# TODO: check if this is used", "for", "id", "in", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "entry", ",", "'id'", ")", ":", "properties", "[", "'name'", "]", "=", "_get_readable_id", "(", "id", ".", "firstChild", ".", "nodeValue", ",", "id_prefix_to_skip", ")", "return", "properties" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject.get_children_from_path
descends through a hierarchy of nodes returning the list of children at the inner most level. Only returns children who share a common parent, not cousins.
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def get_children_from_path(node, *path): '''descends through a hierarchy of nodes returning the list of children at the inner most level. Only returns children who share a common parent, not cousins.''' cur = node for index, child in enumerate(path): if isinstance(child, _strtype): next = _MinidomXmlToObject.get_child_nodes(cur, child) else: next = _MinidomXmlToObject._get_child_nodesNS(cur, *child) if index == len(path) - 1: return next elif not next: break cur = next[0] return []
def get_children_from_path(node, *path): '''descends through a hierarchy of nodes returning the list of children at the inner most level. Only returns children who share a common parent, not cousins.''' cur = node for index, child in enumerate(path): if isinstance(child, _strtype): next = _MinidomXmlToObject.get_child_nodes(cur, child) else: next = _MinidomXmlToObject._get_child_nodesNS(cur, *child) if index == len(path) - 1: return next elif not next: break cur = next[0] return []
[ "descends", "through", "a", "hierarchy", "of", "nodes", "returning", "the", "list", "of", "children", "at", "the", "inner", "most", "level", ".", "Only", "returns", "children", "who", "share", "a", "common", "parent", "not", "cousins", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L199-L215
[ "def", "get_children_from_path", "(", "node", ",", "*", "path", ")", ":", "cur", "=", "node", "for", "index", ",", "child", "in", "enumerate", "(", "path", ")", ":", "if", "isinstance", "(", "child", ",", "_strtype", ")", ":", "next", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "cur", ",", "child", ")", "else", ":", "next", "=", "_MinidomXmlToObject", ".", "_get_child_nodesNS", "(", "cur", ",", "*", "child", ")", "if", "index", "==", "len", "(", "path", ")", "-", "1", ":", "return", "next", "elif", "not", "next", ":", "break", "cur", "=", "next", "[", "0", "]", "return", "[", "]" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject._parse_response_body_from_xml_node
parse the xml and fill all the data into a class of return_type
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _parse_response_body_from_xml_node(node, return_type): ''' parse the xml and fill all the data into a class of return_type ''' return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
def _parse_response_body_from_xml_node(node, return_type): ''' parse the xml and fill all the data into a class of return_type ''' return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
[ "parse", "the", "xml", "and", "fill", "all", "the", "data", "into", "a", "class", "of", "return_type" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L233-L240
[ "def", "_parse_response_body_from_xml_node", "(", "node", ",", "return_type", ")", ":", "return_obj", "=", "return_type", "(", ")", "_MinidomXmlToObject", ".", "_fill_data_to_return_object", "(", "node", ",", "return_obj", ")", "return", "return_obj" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject._fill_scalar_list_of
Converts an xml fragment into a list of scalar types. The parent xml element contains a flat list of xml elements which are converted into the specified scalar type and added to the list. Example: xmldoc= <Endpoints> <Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.queue.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.table.core.windows.net/</Endpoint> </Endpoints> element_type=str parent_xml_element_name='Endpoints' xml_element_name='Endpoint'
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _fill_scalar_list_of(xmldoc, element_type, parent_xml_element_name, xml_element_name): '''Converts an xml fragment into a list of scalar types. The parent xml element contains a flat list of xml elements which are converted into the specified scalar type and added to the list. Example: xmldoc= <Endpoints> <Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.queue.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.table.core.windows.net/</Endpoint> </Endpoints> element_type=str parent_xml_element_name='Endpoints' xml_element_name='Endpoint' ''' xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], xml_element_name) return [_MinidomXmlToObject._get_node_value(xmlelement, element_type) \ for xmlelement in xmlelements]
def _fill_scalar_list_of(xmldoc, element_type, parent_xml_element_name, xml_element_name): '''Converts an xml fragment into a list of scalar types. The parent xml element contains a flat list of xml elements which are converted into the specified scalar type and added to the list. Example: xmldoc= <Endpoints> <Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.queue.core.windows.net/</Endpoint> <Endpoint>http://{storage-service-name}.table.core.windows.net/</Endpoint> </Endpoints> element_type=str parent_xml_element_name='Endpoints' xml_element_name='Endpoint' ''' xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], xml_element_name) return [_MinidomXmlToObject._get_node_value(xmlelement, element_type) \ for xmlelement in xmlelements]
[ "Converts", "an", "xml", "fragment", "into", "a", "list", "of", "scalar", "types", ".", "The", "parent", "xml", "element", "contains", "a", "flat", "list", "of", "xml", "elements", "which", "are", "converted", "into", "the", "specified", "scalar", "type", "and", "added", "to", "the", "list", ".", "Example", ":", "xmldoc", "=", "<Endpoints", ">", "<Endpoint", ">", "http", ":", "//", "{", "storage", "-", "service", "-", "name", "}", ".", "blob", ".", "core", ".", "windows", ".", "net", "/", "<", "/", "Endpoint", ">", "<Endpoint", ">", "http", ":", "//", "{", "storage", "-", "service", "-", "name", "}", ".", "queue", ".", "core", ".", "windows", ".", "net", "/", "<", "/", "Endpoint", ">", "<Endpoint", ">", "http", ":", "//", "{", "storage", "-", "service", "-", "name", "}", ".", "table", ".", "core", ".", "windows", ".", "net", "/", "<", "/", "Endpoint", ">", "<", "/", "Endpoints", ">", "element_type", "=", "str", "parent_xml_element_name", "=", "Endpoints", "xml_element_name", "=", "Endpoint" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L251-L271
[ "def", "_fill_scalar_list_of", "(", "xmldoc", ",", "element_type", ",", "parent_xml_element_name", ",", "xml_element_name", ")", ":", "xmlelements", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "xmldoc", ",", "parent_xml_element_name", ")", "if", "xmlelements", ":", "xmlelements", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "xmlelements", "[", "0", "]", ",", "xml_element_name", ")", "return", "[", "_MinidomXmlToObject", ".", "_get_node_value", "(", "xmlelement", ",", "element_type", ")", "for", "xmlelement", "in", "xmlelements", "]" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject._fill_dict_of
Converts an xml fragment into a dictionary. The parent xml element contains a list of xml elements where each element has a child element for the key, and another for the value. Example: xmldoc= <ExtendedProperties> <ExtendedProperty> <Name>Ext1</Name> <Value>Val1</Value> </ExtendedProperty> <ExtendedProperty> <Name>Ext2</Name> <Value>Val2</Value> </ExtendedProperty> </ExtendedProperties> element_type=str parent_xml_element_name='ExtendedProperties' pair_xml_element_name='ExtendedProperty' key_xml_element_name='Name' value_xml_element_name='Value'
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _fill_dict_of(xmldoc, parent_xml_element_name, pair_xml_element_name, key_xml_element_name, value_xml_element_name): '''Converts an xml fragment into a dictionary. The parent xml element contains a list of xml elements where each element has a child element for the key, and another for the value. Example: xmldoc= <ExtendedProperties> <ExtendedProperty> <Name>Ext1</Name> <Value>Val1</Value> </ExtendedProperty> <ExtendedProperty> <Name>Ext2</Name> <Value>Val2</Value> </ExtendedProperty> </ExtendedProperties> element_type=str parent_xml_element_name='ExtendedProperties' pair_xml_element_name='ExtendedProperty' key_xml_element_name='Name' value_xml_element_name='Value' ''' return_obj = {} xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], pair_xml_element_name) for pair in xmlelements: keys = _MinidomXmlToObject.get_child_nodes(pair, key_xml_element_name) values = _MinidomXmlToObject.get_child_nodes(pair, value_xml_element_name) if keys and values: key = keys[0].firstChild.nodeValue valueContentNode = values[0].firstChild value = valueContentNode.nodeValue if valueContentNode else None return_obj[key] = value return return_obj
def _fill_dict_of(xmldoc, parent_xml_element_name, pair_xml_element_name, key_xml_element_name, value_xml_element_name): '''Converts an xml fragment into a dictionary. The parent xml element contains a list of xml elements where each element has a child element for the key, and another for the value. Example: xmldoc= <ExtendedProperties> <ExtendedProperty> <Name>Ext1</Name> <Value>Val1</Value> </ExtendedProperty> <ExtendedProperty> <Name>Ext2</Name> <Value>Val2</Value> </ExtendedProperty> </ExtendedProperties> element_type=str parent_xml_element_name='ExtendedProperties' pair_xml_element_name='ExtendedProperty' key_xml_element_name='Name' value_xml_element_name='Value' ''' return_obj = {} xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], pair_xml_element_name) for pair in xmlelements: keys = _MinidomXmlToObject.get_child_nodes(pair, key_xml_element_name) values = _MinidomXmlToObject.get_child_nodes(pair, value_xml_element_name) if keys and values: key = keys[0].firstChild.nodeValue valueContentNode = values[0].firstChild value = valueContentNode.nodeValue if valueContentNode else None return_obj[key] = value return return_obj
[ "Converts", "an", "xml", "fragment", "into", "a", "dictionary", ".", "The", "parent", "xml", "element", "contains", "a", "list", "of", "xml", "elements", "where", "each", "element", "has", "a", "child", "element", "for", "the", "key", "and", "another", "for", "the", "value", ".", "Example", ":", "xmldoc", "=", "<ExtendedProperties", ">", "<ExtendedProperty", ">", "<Name", ">", "Ext1<", "/", "Name", ">", "<Value", ">", "Val1<", "/", "Value", ">", "<", "/", "ExtendedProperty", ">", "<ExtendedProperty", ">", "<Name", ">", "Ext2<", "/", "Name", ">", "<Value", ">", "Val2<", "/", "Value", ">", "<", "/", "ExtendedProperty", ">", "<", "/", "ExtendedProperties", ">", "element_type", "=", "str", "parent_xml_element_name", "=", "ExtendedProperties", "pair_xml_element_name", "=", "ExtendedProperty", "key_xml_element_name", "=", "Name", "value_xml_element_name", "=", "Value" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L286-L323
[ "def", "_fill_dict_of", "(", "xmldoc", ",", "parent_xml_element_name", ",", "pair_xml_element_name", ",", "key_xml_element_name", ",", "value_xml_element_name", ")", ":", "return_obj", "=", "{", "}", "xmlelements", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "xmldoc", ",", "parent_xml_element_name", ")", "if", "xmlelements", ":", "xmlelements", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "xmlelements", "[", "0", "]", ",", "pair_xml_element_name", ")", "for", "pair", "in", "xmlelements", ":", "keys", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "pair", ",", "key_xml_element_name", ")", "values", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "pair", ",", "value_xml_element_name", ")", "if", "keys", "and", "values", ":", "key", "=", "keys", "[", "0", "]", ".", "firstChild", ".", "nodeValue", "valueContentNode", "=", "values", "[", "0", "]", ".", "firstChild", "value", "=", "valueContentNode", ".", "nodeValue", "if", "valueContentNode", "else", "None", "return_obj", "[", "key", "]", "=", "value", "return", "return_obj" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject._fill_instance_child
Converts a child of the current dom element to the specified type.
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _fill_instance_child(xmldoc, element_name, return_type): '''Converts a child of the current dom element to the specified type. ''' xmlelements = _MinidomXmlToObject.get_child_nodes( xmldoc, _get_serialization_name(element_name)) if not xmlelements: return None return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(xmlelements[0], return_obj) return return_obj
def _fill_instance_child(xmldoc, element_name, return_type): '''Converts a child of the current dom element to the specified type. ''' xmlelements = _MinidomXmlToObject.get_child_nodes( xmldoc, _get_serialization_name(element_name)) if not xmlelements: return None return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(xmlelements[0], return_obj) return return_obj
[ "Converts", "a", "child", "of", "the", "current", "dom", "element", "to", "the", "specified", "type", "." ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L327-L339
[ "def", "_fill_instance_child", "(", "xmldoc", ",", "element_name", ",", "return_type", ")", ":", "xmlelements", "=", "_MinidomXmlToObject", ".", "get_child_nodes", "(", "xmldoc", ",", "_get_serialization_name", "(", "element_name", ")", ")", "if", "not", "xmlelements", ":", "return", "None", "return_obj", "=", "return_type", "(", ")", "_MinidomXmlToObject", ".", "_fill_data_to_return_object", "(", "xmlelements", "[", "0", "]", ",", "return_obj", ")", "return", "return_obj" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_MinidomXmlToObject._find_namespaces_from_child
Recursively searches from the parent to the child, gathering all the applicable namespaces along the way
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def _find_namespaces_from_child(parent, child, namespaces): """Recursively searches from the parent to the child, gathering all the applicable namespaces along the way""" for cur_child in parent.childNodes: if cur_child is child: return True if _MinidomXmlToObject._find_namespaces_from_child(cur_child, child, namespaces): # we are the parent node for key in cur_child.attributes.keys(): if key.startswith('xmlns:') or key == 'xmlns': namespaces[key] = cur_child.attributes[key] break return False
def _find_namespaces_from_child(parent, child, namespaces): """Recursively searches from the parent to the child, gathering all the applicable namespaces along the way""" for cur_child in parent.childNodes: if cur_child is child: return True if _MinidomXmlToObject._find_namespaces_from_child(cur_child, child, namespaces): # we are the parent node for key in cur_child.attributes.keys(): if key.startswith('xmlns:') or key == 'xmlns': namespaces[key] = cur_child.attributes[key] break return False
[ "Recursively", "searches", "from", "the", "parent", "to", "the", "child", "gathering", "all", "the", "applicable", "namespaces", "along", "the", "way" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L420-L432
[ "def", "_find_namespaces_from_child", "(", "parent", ",", "child", ",", "namespaces", ")", ":", "for", "cur_child", "in", "parent", ".", "childNodes", ":", "if", "cur_child", "is", "child", ":", "return", "True", "if", "_MinidomXmlToObject", ".", "_find_namespaces_from_child", "(", "cur_child", ",", "child", ",", "namespaces", ")", ":", "# we are the parent node", "for", "key", "in", "cur_child", ".", "attributes", ".", "keys", "(", ")", ":", "if", "key", ".", "startswith", "(", "'xmlns:'", ")", "or", "key", "==", "'xmlns'", ":", "namespaces", "[", "key", "]", "=", "cur_child", ".", "attributes", "[", "key", "]", "break", "return", "False" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_XmlSerializer.doc_from_xml
Wraps the specified xml in an xml root element with default azure namespaces
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def doc_from_xml(document_element_name, inner_xml): '''Wraps the specified xml in an xml root element with default azure namespaces''' xml = ''.join(['<', document_element_name, ' xmlns:i="http://www.w3.org/2001/XMLSchema-instance"', ' xmlns="http://schemas.microsoft.com/windowsazure">']) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
def doc_from_xml(document_element_name, inner_xml): '''Wraps the specified xml in an xml root element with default azure namespaces''' xml = ''.join(['<', document_element_name, ' xmlns:i="http://www.w3.org/2001/XMLSchema-instance"', ' xmlns="http://schemas.microsoft.com/windowsazure">']) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
[ "Wraps", "the", "specified", "xml", "in", "an", "xml", "root", "element", "with", "default", "azure", "namespaces" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L1285-L1293
[ "def", "doc_from_xml", "(", "document_element_name", ",", "inner_xml", ")", ":", "xml", "=", "''", ".", "join", "(", "[", "'<'", ",", "document_element_name", ",", "' xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"'", ",", "' xmlns=\"http://schemas.microsoft.com/windowsazure\">'", "]", ")", "xml", "+=", "inner_xml", "xml", "+=", "''", ".", "join", "(", "[", "'</'", ",", "document_element_name", ",", "'>'", "]", ")", "return", "xml" ]
d7306fde32f60a293a7567678692bdad31e4b667
test
_SqlManagementXmlSerializer.doc_from_xml
Wraps the specified xml in an xml root element with default azure namespaces
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
def doc_from_xml(document_element_name, inner_xml, xmlns='http://schemas.microsoft.com/windowsazure'): '''Wraps the specified xml in an xml root element with default azure namespaces''' xml = ''.join(['<', document_element_name, ' xmlns="{0}">'.format(xmlns)]) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
def doc_from_xml(document_element_name, inner_xml, xmlns='http://schemas.microsoft.com/windowsazure'): '''Wraps the specified xml in an xml root element with default azure namespaces''' xml = ''.join(['<', document_element_name, ' xmlns="{0}">'.format(xmlns)]) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
[ "Wraps", "the", "specified", "xml", "in", "an", "xml", "root", "element", "with", "default", "azure", "namespaces" ]
Azure/azure-sdk-for-python
python
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py#L1391-L1399
[ "def", "doc_from_xml", "(", "document_element_name", ",", "inner_xml", ",", "xmlns", "=", "'http://schemas.microsoft.com/windowsazure'", ")", ":", "xml", "=", "''", ".", "join", "(", "[", "'<'", ",", "document_element_name", ",", "' xmlns=\"{0}\">'", ".", "format", "(", "xmlns", ")", "]", ")", "xml", "+=", "inner_xml", "xml", "+=", "''", ".", "join", "(", "[", "'</'", ",", "document_element_name", ",", "'>'", "]", ")", "return", "xml" ]
d7306fde32f60a293a7567678692bdad31e4b667