diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/cognitive_services_management_client.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/cognitive_services_management_client.py old mode 100755 new mode 100644 index 613e5c6b6213..4c267aa4fc00 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/cognitive_services_management_client.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/cognitive_services_management_client.py @@ -13,7 +13,6 @@ from msrest import Serializer, Deserializer from msrestazure import AzureConfiguration from .version import VERSION -from .operations.cognitive_services_accounts_operations import CognitiveServicesAccountsOperations from .operations.accounts_operations import AccountsOperations from .operations.operations import Operations from .operations.check_sku_availability_operations import CheckSkuAvailabilityOperations @@ -30,13 +29,11 @@ class CognitiveServicesManagementClientConfiguration(AzureConfiguration): object` :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param location: Resource location. - :type location: str :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, location, base_url=None): + self, credentials, subscription_id, base_url=None): if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") @@ -44,10 +41,6 @@ def __init__( raise ValueError("Parameter 'subscription_id' must not be None.") if not isinstance(subscription_id, str): raise TypeError("Parameter 'subscription_id' must be str.") - if location is None: - raise ValueError("Parameter 'location' must not be None.") - if not isinstance(location, str): - raise TypeError("Parameter 'location' must be str.") if not base_url: base_url = 'https://management.azure.com' @@ -58,7 +51,6 @@ def __init__( self.credentials = credentials self.subscription_id = subscription_id - self.location = location class CognitiveServicesManagementClient(object): @@ -67,29 +59,25 @@ class CognitiveServicesManagementClient(object): :ivar config: Configuration for client. :vartype config: CognitiveServicesManagementClientConfiguration - :ivar cognitive_services_accounts: CognitiveServicesAccounts operations - :vartype cognitive_services_accounts: .operations.CognitiveServicesAccountsOperations :ivar accounts: Accounts operations - :vartype accounts: .operations.AccountsOperations + :vartype accounts: azure.mgmt.cognitiveservices.operations.AccountsOperations :ivar operations: Operations operations - :vartype operations: .operations.Operations + :vartype operations: azure.mgmt.cognitiveservices.operations.Operations :ivar check_sku_availability: CheckSkuAvailability operations - :vartype check_sku_availability: .operations.CheckSkuAvailabilityOperations + :vartype check_sku_availability: azure.mgmt.cognitiveservices.operations.CheckSkuAvailabilityOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object` :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param location: Resource location. - :type location: str :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, location, base_url=None): + self, credentials, subscription_id, base_url=None): - self.config = CognitiveServicesManagementClientConfiguration(credentials, subscription_id, location, base_url) + self.config = CognitiveServicesManagementClientConfiguration(credentials, subscription_id, base_url) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -97,8 +85,6 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.cognitive_services_accounts = CognitiveServicesAccountsOperations( - self._client, self.config, self._serialize, self._deserialize) self.accounts = AccountsOperations( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_parameter.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_parameter.py old mode 100755 new mode 100644 index d52834852bf6..a52600f5f33b --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_parameter.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_parameter.py @@ -16,7 +16,8 @@ class CheckSkuAvailabilityParameter(Model): """Check SKU availability parameter. :param skus: The SKU of the resource. - :type skus: list of :class:`Sku ` + :type skus: list of str or :class:`SkuName + ` :param kind: The Kind of the resource. Possible values include: 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', @@ -28,13 +29,19 @@ class CheckSkuAvailabilityParameter(Model): :type type: str """ + _validation = { + 'skus': {'required': True}, + 'kind': {'required': True}, + 'type': {'required': True}, + } + _attribute_map = { - 'skus': {'key': 'skus', 'type': '[Sku]'}, + 'skus': {'key': 'skus', 'type': '[str]'}, 'kind': {'key': 'kind', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, skus=None, kind=None, type=None): + def __init__(self, skus, kind, type): self.skus = skus self.kind = kind self.type = type diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result.py old mode 100755 new mode 100644 index 38cdfb67bd15..3647f26599a7 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result.py @@ -24,8 +24,10 @@ class CheckSkuAvailabilityResult(Model): ` :param type: The Type of the resource. :type type: str - :param sku_name: The SKU of Cognitive Services account. - :type sku_name: :class:`Sku ` + :param sku_name: The SKU of Cognitive Services account. Possible values + include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + :type sku_name: str or :class:`SkuName + ` :param sku_available: Indicates the given SKU is available or not. :type sku_available: bool :param reason: Reason why the SKU is not available. @@ -37,7 +39,7 @@ class CheckSkuAvailabilityResult(Model): _attribute_map = { 'kind': {'key': 'kind', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'sku_name': {'key': 'skuName', 'type': 'Sku'}, + 'sku_name': {'key': 'skuName', 'type': 'str'}, 'sku_available': {'key': 'skuAvailable', 'type': 'bool'}, 'reason': {'key': 'reason', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result_list.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/check_sku_availability_result_list.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account.py old mode 100755 new mode 100644 index 3f0d8660f86a..5754278c8a0d --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account.py @@ -21,14 +21,14 @@ class CognitiveServicesAccount(Model): :param etag: Entity Tag :type etag: str - :param id: The id of the created account - :type id: str + :ivar id: The id of the created account + :vartype id: str :param kind: Type of cognitive service account. :type kind: str :param location: The location of the resource :type location: str - :param name: The name of the created account - :type name: str + :ivar name: The name of the created account + :vartype name: str :ivar provisioning_state: Gets the status of the cognitive services account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded', 'Failed' @@ -46,12 +46,15 @@ class CognitiveServicesAccount(Model): resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. :type tags: dict - :param type: Resource type - :type type: str + :ivar type: Resource type + :vartype type: str """ _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, 'provisioning_state': {'readonly': True}, + 'type': {'readonly': True}, } _attribute_map = { @@ -68,15 +71,15 @@ class CognitiveServicesAccount(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, etag=None, id=None, kind=None, location=None, name=None, endpoint=None, internal_id=None, sku=None, tags=None, type=None): + def __init__(self, etag=None, kind=None, location=None, endpoint=None, internal_id=None, sku=None, tags=None): self.etag = etag - self.id = id + self.id = None self.kind = kind self.location = location - self.name = name + self.name = None self.provisioning_state = None self.endpoint = endpoint self.internal_id = internal_id self.sku = sku self.tags = tags - self.type = type + self.type = None diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_create_parameters.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_create_parameters.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_enumerate_skus_result.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_enumerate_skus_result.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_keys.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_keys.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_paged.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_paged.py old mode 100755 new mode 100644 index 43142f53a931..6a1e5be90b2a --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_paged.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_paged.py @@ -14,7 +14,7 @@ class CognitiveServicesAccountPaged(Paged): """ - A paging container for iterating over a list of CognitiveServicesAccount object + A paging container for iterating over a list of :class:`CognitiveServicesAccount ` object """ _attribute_map = { diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_update_parameters.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_account_update_parameters.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_management_client_enums.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_management_client_enums.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_resource_and_sku.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/cognitive_services_resource_and_sku.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/error.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/error.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/error_body.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/error_body.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_display_info.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_display_info.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity_paged.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity_paged.py old mode 100755 new mode 100644 index 32659be93efe..6eb55311b159 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity_paged.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/operation_entity_paged.py @@ -14,7 +14,7 @@ class OperationEntityPaged(Paged): """ - A paging container for iterating over a list of OperationEntity object + A paging container for iterating over a list of :class:`OperationEntity ` object """ _attribute_map = { diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/regenerate_key_parameters.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/regenerate_key_parameters.py old mode 100755 new mode 100644 index 0d0487503e0f..fff8c15b8bb4 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/regenerate_key_parameters.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/regenerate_key_parameters.py @@ -21,9 +21,13 @@ class RegenerateKeyParameters(Model): ` """ + _validation = { + 'key_name': {'required': True}, + } + _attribute_map = { 'key_name': {'key': 'keyName', 'type': 'KeyName'}, } - def __init__(self, key_name=None): + def __init__(self, key_name): self.key_name = key_name diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/sku.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/sku.py old mode 100755 new mode 100644 diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py old mode 100755 new mode 100644 index 37a5f1d9341c..5c91cb9c82ca --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py @@ -9,13 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .cognitive_services_accounts_operations import CognitiveServicesAccountsOperations from .accounts_operations import AccountsOperations from .operations import Operations from .check_sku_availability_operations import CheckSkuAvailabilityOperations __all__ = [ - 'CognitiveServicesAccountsOperations', 'AccountsOperations', 'Operations', 'CheckSkuAvailabilityOperations', diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/accounts_operations.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/accounts_operations.py old mode 100755 new mode 100644 index fee2b83d3200..f60db1b623db --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/accounts_operations.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/accounts_operations.py @@ -9,8 +9,8 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.pipeline import ClientRawResponse import uuid +from msrest.pipeline import ClientRawResponse from .. import models @@ -34,6 +34,282 @@ def __init__(self, client, config, serializer, deserializer): self.config = config + def create( + self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): + """Create Cognitive Services Account. Accounts is a resource group wide + resource type. It holds the keys for developer to access intelligent + APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param parameters: The parameters to provide for the created account. + :type parameters: :class:`CognitiveServicesAccountCreateParameters + ` + :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`. + :return: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'CognitiveServicesAccountCreateParameters') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccount', response) + if response.status_code == 201: + deserialized = self._deserialize('CognitiveServicesAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, account_name, sku=None, tags=None, custom_headers=None, raw=False, **operation_config): + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param sku: Gets or sets the SKU of the resource. + :type sku: :class:`Sku ` + :param tags: Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource + (across resource groups). A maximum of 15 tags can be provided for a + resource. Each tag must have a key no greater than 128 characters and + value no greater than 256 characters. + :type tags: dict + :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`. + :return: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + parameters = models.CognitiveServicesAccountUpdateParameters(sku=sku, tags=tags) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'CognitiveServicesAccountUpdateParameters') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def delete( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Deletes a Cognitive Services account from the resource group. . + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: 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`. + :return: None or + :class:`ClientRawResponse` if + raw=true + :rtype: None or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def get_properties( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Returns a Cognitive Services account specified by the parameters. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: 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`. + :return: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccount + ` or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccount', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + def list_by_resource_group( self, resource_group_name, custom_headers=None, raw=False, **operation_config): """Returns all the resources of a particular type belonging to a resource @@ -47,6 +323,8 @@ def list_by_resource_group( deserialized response :param operation_config: :ref:`Operation configuration overrides`. + :return: An iterator like instance of :class:`CognitiveServicesAccount + ` :rtype: :class:`CognitiveServicesAccountPaged ` :raises: @@ -111,6 +389,8 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. + :return: An iterator like instance of :class:`CognitiveServicesAccount + ` :rtype: :class:`CognitiveServicesAccountPaged ` :raises: @@ -163,3 +443,209 @@ def internal_paging(next_link=None, raw=False): return client_raw_response return deserialized + + def list_keys( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """Lists the account keys for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: 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`. + :return: :class:`CognitiveServicesAccountKeys + ` or + :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccountKeys + ` or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccountKeys', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def regenerate_key( + self, resource_group_name, account_name, key_name, custom_headers=None, raw=False, **operation_config): + """Regenerates the specified account key for the specified Cognitive + Services account. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param key_name: key name to generate (Key1|Key2). Possible values + include: 'Key1', 'Key2' + :type key_name: str or :class:`KeyName + ` + :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`. + :return: :class:`CognitiveServicesAccountKeys + ` or + :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccountKeys + ` or + :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + parameters = models.RegenerateKeyParameters(key_name=key_name) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccountKeys', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def list_skus( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + """List available SKUs for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group within the + user's subscription. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: 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`. + :return: :class:`CognitiveServicesAccountEnumerateSkusResult + ` + or :class:`ClientRawResponse` if + raw=true + :rtype: :class:`CognitiveServicesAccountEnumerateSkusResult + ` + or :class:`ClientRawResponse` + :raises: + :class:`ErrorException` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccountEnumerateSkusResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/check_sku_availability_operations.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/check_sku_availability_operations.py old mode 100755 new mode 100644 index eb854ad5fd2b..051b20c99ad1 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/check_sku_availability_operations.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/check_sku_availability_operations.py @@ -9,9 +9,9 @@ # regenerated. # -------------------------------------------------------------------------- +import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError -import uuid from .. import models @@ -36,12 +36,14 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def list( - self, skus=None, kind=None, type=None, custom_headers=None, raw=False, **operation_config): + self, location, skus, kind, type, custom_headers=None, raw=False, **operation_config): """Check available SKUs. + :param location: Resource location. + :type location: str :param skus: The SKU of the resource. - :type skus: list of :class:`Sku - ` + :type skus: list of str or :class:`SkuName + ` :param kind: The Kind of the resource. Possible values include: 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', @@ -57,10 +59,13 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. + :return: :class:`CheckSkuAvailabilityResultList + ` + or :class:`ClientRawResponse` if + raw=true :rtype: :class:`CheckSkuAvailabilityResultList ` - :rtype: :class:`ClientRawResponse` - if raw=true + or :class:`ClientRawResponse` :raises: :class:`CloudError` """ parameters = models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) @@ -69,7 +74,7 @@ def list( url = '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'location': self._serialize.url("self.config.location", self.config.location, 'str') + 'location': self._serialize.url("location", location, 'str') } url = self._client.format_url(url, **path_format_arguments) diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/cognitive_services_accounts_operations.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/cognitive_services_accounts_operations.py deleted file mode 100755 index d595b1b9dfd2..000000000000 --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/cognitive_services_accounts_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.pipeline import ClientRawResponse -import uuid - -from .. import models - - -class CognitiveServicesAccountsOperations(object): - """CognitiveServicesAccountsOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: Version of the API to be used with the client request. Current version is 2017-04-18. Constant value: "2017-04-18". - """ - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2017-04-18" - - self.config = config - - def create( - self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): - """Create Cognitive Services Account. Accounts is a resource group wide - resource type. It holds the keys for developer to access intelligent - APIs. It's also the resource type for billing. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: str - :param parameters: The parameters to provide for the created account. - :type parameters: :class:`CognitiveServicesAccountCreateParameters - ` - :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`. - :rtype: :class:`CognitiveServicesAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'CognitiveServicesAccountCreateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200, 201]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) - if response.status_code == 201: - deserialized = self._deserialize('CognitiveServicesAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def update( - self, resource_group_name, account_name, sku=None, tags=None, custom_headers=None, raw=False, **operation_config): - """Updates a Cognitive Services account. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: str - :param sku: Gets or sets the SKU of the resource. - :type sku: :class:`Sku ` - :param tags: Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource - (across resource groups). A maximum of 15 tags can be provided for a - resource. Each tag must have a key no greater than 128 characters and - value no greater than 256 characters. - :type tags: dict - :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`. - :rtype: :class:`CognitiveServicesAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - parameters = models.CognitiveServicesAccountUpdateParameters(sku=sku, tags=tags) - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'CognitiveServicesAccountUpdateParameters') - - # Construct and send request - request = self._client.patch(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def delete( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Deletes a Cognitive Services account from the resource group. . - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: 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`. - :rtype: None - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200, 204]: - raise models.ErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def get_properties( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Returns a Cognitive Services account specified by the parameters. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: 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`. - :rtype: :class:`CognitiveServicesAccount - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_keys( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Lists the account keys for the specified Cognitive Services account. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: 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`. - :rtype: :class:`CognitiveServicesAccountKeys - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountKeys', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def regenerate_key( - self, resource_group_name, account_name, key_name=None, custom_headers=None, raw=False, **operation_config): - """Regenerates the specified account key for the specified Cognitive - Services account. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: str - :param key_name: key name to generate (Key1|Key2). Possible values - include: 'Key1', 'Key2' - :type key_name: str or :class:`KeyName - ` - :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`. - :rtype: :class:`CognitiveServicesAccountKeys - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - parameters = models.RegenerateKeyParameters(key_name=key_name) - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') - - # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountKeys', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_skus( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """List available SKUs for the requested Cognitive Services account. - - :param resource_group_name: The name of the resource group within the - user's subscription. - :type resource_group_name: str - :param account_name: The name of Cognitive Services account. - :type account_name: 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`. - :rtype: :class:`CognitiveServicesAccountEnumerateSkusResult - ` - :rtype: :class:`ClientRawResponse` - if raw=true - :raises: - :class:`ErrorException` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountEnumerateSkusResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/operations.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/operations.py old mode 100755 new mode 100644 index 970699bf644c..118da1c30b9a --- a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/operations.py +++ b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/operations.py @@ -9,9 +9,9 @@ # regenerated. # -------------------------------------------------------------------------- +import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError -import uuid from .. import models @@ -44,6 +44,8 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. + :return: An iterator like instance of :class:`OperationEntity + ` :rtype: :class:`OperationEntityPaged ` :raises: :class:`CloudError` diff --git a/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/version.py b/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/version.py old mode 100755 new mode 100644