diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json index 9dd1cbc422ff..9e4e439e8a41 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "e0b5060d30138df66bd64bf0ca6b2010be18717f", + "commit": "3b2d6675ec2ba228ced29ab9316fd4cd9f349aab", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/cognitiveservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py index ef15f946bbb8..ff24901a0752 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['CognitiveServicesManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py index 72eb985c6bad..c7c1c7fb2600 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_cognitive_services_management_client.py @@ -6,31 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import CognitiveServicesManagementClientConfiguration +from .operations import AccountsOperations, CognitiveServicesManagementClientOperationsMixin, CommitmentPlansOperations, CommitmentTiersOperations, DeletedAccountsOperations, DeploymentsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceSkusOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import CognitiveServicesManagementClientConfiguration -from .operations import AccountsOperations -from .operations import DeletedAccountsOperations -from .operations import ResourceSkusOperations -from .operations import Operations -from .operations import CognitiveServicesManagementClientOperationsMixin -from .operations import CommitmentTiersOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import DeploymentsOperations -from .operations import CommitmentPlansOperations -from . import models - class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin): """Cognitive Services Management Client. @@ -46,9 +35,11 @@ class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperati :ivar commitment_tiers: CommitmentTiersOperations operations :vartype commitment_tiers: azure.mgmt.cognitiveservices.operations.CommitmentTiersOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.cognitiveservices.operations.DeploymentsOperations :ivar commitment_plans: CommitmentPlansOperations operations @@ -57,64 +48,62 @@ class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperati :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = CognitiveServicesManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = CognitiveServicesManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.commitment_tiers = CommitmentTiersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.commitment_plans = CommitmentPlansOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_tiers = CommitmentTiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_plans = CommitmentPlansOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py index db9063efc41f..92d9e4c00fa2 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class CognitiveServicesManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = "2022-03-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-cognitiveservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_metadata.json b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_metadata.json index d1ac26bb7b0d..40429b6f13a9 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_metadata.json +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2021-10-01", - "total_api_version_list": ["2021-10-01"], + "chosen_version": "2022-03-01", + "total_api_version_list": ["2022-03-01"], "client": { "name": "CognitiveServicesManagementClient", "filename": "_cognitive_services_management_client", "description": "Cognitive Services Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CognitiveServicesManagementClientConfiguration\"], \"._operations_mixin\": [\"CognitiveServicesManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CognitiveServicesManagementClientConfiguration\"], \"._operations_mixin\": [\"CognitiveServicesManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CognitiveServicesManagementClientConfiguration\"], \"._operations_mixin\": [\"CognitiveServicesManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CognitiveServicesManagementClientConfiguration\"], \"._operations_mixin\": [\"CognitiveServicesManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "accounts": "AccountsOperations", @@ -109,12 +108,12 @@ "commitment_plans": "CommitmentPlansOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"List\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"List\", \"Optional\"]}}}", "operations": { "check_sku_availability" : { "sync": { - "signature": "def check_sku_availability(\n self,\n location, # type: str\n skus, # type: List[str]\n kind, # type: str\n type, # type: str\n **kwargs # type: Any\n):\n", + "signature": "def check_sku_availability(\n self,\n location, # type: str\n skus, # type: List[str]\n kind, # type: str\n type, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.SkuAvailabilityListResult\"\n", "doc": "\"\"\"Check available SKUs.\n\n:param location: Resource location.\n:type location: str\n:param skus: The SKU of the resource.\n:type skus: list[str]\n:param kind: The Kind of the resource.\n:type kind: str\n:param type: The Type of the resource.\n:type type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: SkuAvailabilityListResult, or the result of cls(response)\n:rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { @@ -126,7 +125,7 @@ }, "check_domain_availability" : { "sync": { - "signature": "def check_domain_availability(\n self,\n subdomain_name, # type: str\n type, # type: str\n kind=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "signature": "def check_domain_availability(\n self,\n subdomain_name, # type: str\n type, # type: str\n kind=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.DomainAvailability\"\n", "doc": "\"\"\"Check whether a domain is available.\n\n:param subdomain_name: The subdomain name to use.\n:type subdomain_name: str\n:param type: The Type of the resource.\n:type type: str\n:param kind: The Kind of the resource.\n:type kind: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: DomainAvailability, or the result of cls(response)\n:rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_patch.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py index fa8e008c199f..75a1436b862f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.0.0" +VERSION = "11.0.0b1" diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py index 33537ef8312c..cf623959fbc9 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py @@ -8,3 +8,8 @@ from ._cognitive_services_management_client import CognitiveServicesManagementClient __all__ = ['CognitiveServicesManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py index b0e16cb0c4fe..772bb162d08c 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py @@ -6,111 +6,107 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import CognitiveServicesManagementClientConfiguration +from .operations import AccountsOperations, CognitiveServicesManagementClientOperationsMixin, CommitmentPlansOperations, CommitmentTiersOperations, DeletedAccountsOperations, DeploymentsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceSkusOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import CognitiveServicesManagementClientConfiguration -from .operations import AccountsOperations -from .operations import DeletedAccountsOperations -from .operations import ResourceSkusOperations -from .operations import Operations -from .operations import CognitiveServicesManagementClientOperationsMixin -from .operations import CommitmentTiersOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import DeploymentsOperations -from .operations import CommitmentPlansOperations -from .. import models - - class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin): """Cognitive Services Management Client. :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.cognitiveservices.aio.operations.AccountsOperations :ivar deleted_accounts: DeletedAccountsOperations operations - :vartype deleted_accounts: azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations + :vartype deleted_accounts: + azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations :ivar resource_skus: ResourceSkusOperations operations :vartype resource_skus: azure.mgmt.cognitiveservices.aio.operations.ResourceSkusOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.cognitiveservices.aio.operations.Operations :ivar commitment_tiers: CommitmentTiersOperations operations - :vartype commitment_tiers: azure.mgmt.cognitiveservices.aio.operations.CommitmentTiersOperations + :vartype commitment_tiers: + azure.mgmt.cognitiveservices.aio.operations.CommitmentTiersOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.cognitiveservices.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.cognitiveservices.aio.operations.PrivateLinkResourcesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations :ivar commitment_plans: CommitmentPlansOperations operations - :vartype commitment_plans: azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations + :vartype commitment_plans: + azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = CognitiveServicesManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = CognitiveServicesManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_tiers = CommitmentTiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_plans = CommitmentPlansOperations(self._client, self._config, self._serialize, self._deserialize) + - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.commitment_tiers = CommitmentTiersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.commitment_plans = CommitmentPlansOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py index 868d790b9a59..d7292d11040e 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = "2022-03-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-cognitiveservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_patch.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py index 062574dafb7a..81bde2bebcd2 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._accounts_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_keys_request, build_list_models_request, build_list_request, build_list_skus_request, build_list_usages_request, build_regenerate_key_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,39 +60,28 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(account, 'Account') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Account', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -122,15 +119,19 @@ async def begin_create( :type account: ~azure.mgmt.cognitiveservices.models.Account :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Account or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', @@ -142,27 +143,21 @@ async def begin_create( resource_group_name=resource_group_name, account_name=account_name, account=account, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -174,6 +169,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore async def _update_initial( @@ -188,39 +184,28 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(account, 'Account') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Account', pipeline_response) @@ -232,8 +217,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -251,15 +239,19 @@ async def begin_update( :type account: ~azure.mgmt.cognitiveservices.models.Account :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Account or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Account or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,27 +263,21 @@ async def begin_update( resource_group_name=resource_group_name, account_name=account_name, account=account, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -303,6 +289,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore async def _delete_initial( @@ -316,40 +303,31 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -364,15 +342,17 @@ async def begin_delete( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -386,21 +366,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -412,8 +385,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -436,33 +411,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -471,8 +436,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -484,7 +452,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountListResult"] @@ -492,35 +461,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -533,17 +498,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -552,7 +519,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountListResult"] @@ -560,34 +528,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -600,17 +563,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -633,33 +598,23 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiKeys', pipeline_response) @@ -668,8 +623,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace_async async def regenerate_key( self, resource_group_name: str, @@ -696,39 +654,28 @@ async def regenerate_key( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.RegenerateKeyParameters(key_name=key_name) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _parameters = _models.RegenerateKeyParameters(key_name=key_name) + _json = self._serialize.body(_parameters, 'RegenerateKeyParameters') + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'RegenerateKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiKeys', pipeline_response) @@ -737,8 +684,11 @@ async def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'} # type: ignore + + @distributed_trace_async async def list_skus( self, resource_group_name: str, @@ -761,33 +711,23 @@ async def list_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccountSkuListResult', pipeline_response) @@ -796,8 +736,11 @@ async def list_skus( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'} # type: ignore + + @distributed_trace_async async def list_usages( self, resource_group_name: str, @@ -824,35 +767,24 @@ async def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_usages_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UsageListResult', pipeline_response) @@ -861,4 +793,82 @@ async def list_usages( return cls(pipeline_response, deserialized, {}) return deserialized + list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'} # type: ignore + + + @distributed_trace + def list_models( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AccountModelListResult"]: + """List available Models for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccountModelListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountModelListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountModelListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_models.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccountModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_models.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py index 1f3166c485a8..e391dd5af6c0 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._cognitive_services_management_client_operations import build_check_domain_availability_request, build_check_sku_availability_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CognitiveServicesManagementClientOperationsMixin: + @distributed_trace_async async def check_sku_availability( self, location: str, @@ -49,38 +54,27 @@ async def check_sku_availability( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_sku_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _parameters = _models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) + _json = self._serialize.body(_parameters, 'CheckSkuAvailabilityParameter') + + request = build_check_sku_availability_request( + subscription_id=self._config.subscription_id, + location=location, + content_type=content_type, + json=_json, + template_url=self.check_sku_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'CheckSkuAvailabilityParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuAvailabilityListResult', pipeline_response) @@ -89,8 +83,11 @@ async def check_sku_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_sku_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'} # type: ignore + + @distributed_trace_async async def check_domain_availability( self, subdomain_name: str, @@ -117,37 +114,26 @@ async def check_domain_availability( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type, kind=kind) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_domain_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _parameters = _models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type, kind=kind) + _json = self._serialize.body(_parameters, 'CheckDomainAvailabilityParameter') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_domain_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_domain_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'CheckDomainAvailabilityParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DomainAvailability', pipeline_response) @@ -156,4 +142,6 @@ async def check_domain_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_domain_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability'} # type: ignore + diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py index 7a1135bcaa92..c7ec75301ea0 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_plans_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._commitment_plans_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list( :param account_name: The name of Cognitive Services account. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommitmentPlanListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanListResult] + :return: An iterator like instance of either CommitmentPlanListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CommitmentPlanListResult"] @@ -65,36 +73,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CommitmentPlanListResult', pipeline_response) + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +112,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,34 +151,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CommitmentPlan', pipeline_response) @@ -180,8 +177,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -211,39 +211,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(commitment_plan, 'CommitmentPlan') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(commitment_plan, 'CommitmentPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -256,8 +246,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -270,41 +262,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -323,15 +306,17 @@ async def begin_delete( :type commitment_plan_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -346,22 +331,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -373,4 +350,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py index 60324826dd91..40f2dfedc7e3 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_commitment_tiers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._commitment_tiers_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, location: str, @@ -51,8 +57,10 @@ def list( :param location: Resource location. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommitmentTierListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTierListResult] + :return: An iterator like instance of either CommitmentTierListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTierListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CommitmentTierListResult"] @@ -60,35 +68,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CommitmentTierListResult', pipeline_response) + deserialized = self._deserialize("CommitmentTierListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,12 +105,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py index cff22f7543df..90188133c5a8 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deleted_accounts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deleted_accounts_operations import build_get_request, build_list_request, build_purge_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, location: str, @@ -68,34 +74,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + async def _purge_initial( self, location: str, @@ -118,41 +116,32 @@ async def _purge_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._purge_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_purge_request_initial( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self._purge_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + + @distributed_trace_async async def begin_purge( self, location: str, @@ -170,15 +159,17 @@ async def begin_purge( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -193,22 +184,14 @@ async def begin_purge( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -220,8 +203,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -230,7 +215,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountListResult"] @@ -238,34 +224,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -278,12 +259,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py index 08654d34f3ee..0e9bc5050fe7 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list( :param account_name: The name of Cognitive Services account. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -65,36 +73,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +112,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,34 +151,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Deployment', pipeline_response) @@ -180,8 +177,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -195,40 +194,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(deployment, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Deployment', pipeline_response) @@ -240,8 +228,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -263,15 +254,19 @@ async def begin_create_or_update( :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Deployment or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Deployment or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Deployment"] lro_delay = kwargs.pop( 'polling_interval', @@ -284,28 +279,21 @@ async def begin_create_or_update( account_name=account_name, deployment_name=deployment_name, deployment=deployment, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Deployment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -317,6 +305,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore async def _delete_initial( @@ -331,41 +320,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -384,15 +364,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -407,22 +389,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -434,4 +408,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py index 52dd882fb983..b6546f326be8 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py index 1799f2b946ae..0447c65e7639 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) @@ -99,8 +94,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -127,34 +125,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -163,8 +151,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -178,40 +168,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(properties, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -223,8 +202,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -247,15 +229,20 @@ async def begin_create_or_update( :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -268,28 +255,21 @@ async def begin_create_or_update( account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -301,6 +281,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -315,41 +296,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -369,15 +341,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -392,22 +366,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -419,4 +385,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py index 967fd1b13c1b..7f9be34702fd 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -62,33 +67,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) @@ -97,4 +92,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources'} # type: ignore + diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py index ddff419a1436..57f4ad3ed30a 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_skus_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkuListResult] + :return: An iterator like instance of either ResourceSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuListResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkuListResult', pipeline_response) + deserialized = self._deserialize("ResourceSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +100,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py index 88e33579c793..b3fc17da012d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py @@ -6,140 +6,76 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Account - from ._models_py3 import AccountListResult - from ._models_py3 import AccountProperties - from ._models_py3 import AccountSku - from ._models_py3 import AccountSkuListResult - from ._models_py3 import ApiKeys - from ._models_py3 import ApiProperties - from ._models_py3 import AzureEntityResource - from ._models_py3 import CallRateLimit - from ._models_py3 import CheckDomainAvailabilityParameter - from ._models_py3 import CheckSkuAvailabilityParameter - from ._models_py3 import CommitmentCost - from ._models_py3 import CommitmentPeriod - from ._models_py3 import CommitmentPlan - from ._models_py3 import CommitmentPlanListResult - from ._models_py3 import CommitmentPlanProperties - from ._models_py3 import CommitmentQuota - from ._models_py3 import CommitmentTier - from ._models_py3 import CommitmentTierListResult - from ._models_py3 import Deployment - from ._models_py3 import DeploymentListResult - from ._models_py3 import DeploymentModel - from ._models_py3 import DeploymentProperties - from ._models_py3 import DeploymentScaleSettings - from ._models_py3 import DomainAvailability - from ._models_py3 import Encryption - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import Identity - from ._models_py3 import IpRule - from ._models_py3 import KeyVaultProperties - from ._models_py3 import MetricName - from ._models_py3 import NetworkRuleSet - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkResourceProperties - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import ProxyResource - from ._models_py3 import QuotaLimit - from ._models_py3 import RegenerateKeyParameters - from ._models_py3 import RequestMatchPattern - from ._models_py3 import Resource - from ._models_py3 import ResourceSku - from ._models_py3 import ResourceSkuListResult - from ._models_py3 import ResourceSkuRestrictionInfo - from ._models_py3 import ResourceSkuRestrictions - from ._models_py3 import Sku - from ._models_py3 import SkuAvailability - from ._models_py3 import SkuAvailabilityListResult - from ._models_py3 import SkuCapability - from ._models_py3 import SkuChangeInfo - from ._models_py3 import SystemData - from ._models_py3 import ThrottlingRule - from ._models_py3 import Usage - from ._models_py3 import UsageListResult - from ._models_py3 import UserAssignedIdentity - from ._models_py3 import UserOwnedStorage - from ._models_py3 import VirtualNetworkRule -except (SyntaxError, ImportError): - from ._models import Account # type: ignore - from ._models import AccountListResult # type: ignore - from ._models import AccountProperties # type: ignore - from ._models import AccountSku # type: ignore - from ._models import AccountSkuListResult # type: ignore - from ._models import ApiKeys # type: ignore - from ._models import ApiProperties # type: ignore - from ._models import AzureEntityResource # type: ignore - from ._models import CallRateLimit # type: ignore - from ._models import CheckDomainAvailabilityParameter # type: ignore - from ._models import CheckSkuAvailabilityParameter # type: ignore - from ._models import CommitmentCost # type: ignore - from ._models import CommitmentPeriod # type: ignore - from ._models import CommitmentPlan # type: ignore - from ._models import CommitmentPlanListResult # type: ignore - from ._models import CommitmentPlanProperties # type: ignore - from ._models import CommitmentQuota # type: ignore - from ._models import CommitmentTier # type: ignore - from ._models import CommitmentTierListResult # type: ignore - from ._models import Deployment # type: ignore - from ._models import DeploymentListResult # type: ignore - from ._models import DeploymentModel # type: ignore - from ._models import DeploymentProperties # type: ignore - from ._models import DeploymentScaleSettings # type: ignore - from ._models import DomainAvailability # type: ignore - from ._models import Encryption # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Identity # type: ignore - from ._models import IpRule # type: ignore - from ._models import KeyVaultProperties # type: ignore - from ._models import MetricName # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkResourceProperties # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import QuotaLimit # type: ignore - from ._models import RegenerateKeyParameters # type: ignore - from ._models import RequestMatchPattern # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceSku # type: ignore - from ._models import ResourceSkuListResult # type: ignore - from ._models import ResourceSkuRestrictionInfo # type: ignore - from ._models import ResourceSkuRestrictions # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuAvailability # type: ignore - from ._models import SkuAvailabilityListResult # type: ignore - from ._models import SkuCapability # type: ignore - from ._models import SkuChangeInfo # type: ignore - from ._models import SystemData # type: ignore - from ._models import ThrottlingRule # type: ignore - from ._models import Usage # type: ignore - from ._models import UsageListResult # type: ignore - from ._models import UserAssignedIdentity # type: ignore - from ._models import UserOwnedStorage # type: ignore - from ._models import VirtualNetworkRule # type: ignore +from ._models_py3 import Account +from ._models_py3 import AccountListResult +from ._models_py3 import AccountModel +from ._models_py3 import AccountModelListResult +from ._models_py3 import AccountProperties +from ._models_py3 import AccountSku +from ._models_py3 import AccountSkuListResult +from ._models_py3 import ApiKeys +from ._models_py3 import ApiProperties +from ._models_py3 import AzureEntityResource +from ._models_py3 import CallRateLimit +from ._models_py3 import CheckDomainAvailabilityParameter +from ._models_py3 import CheckSkuAvailabilityParameter +from ._models_py3 import CommitmentCost +from ._models_py3 import CommitmentPeriod +from ._models_py3 import CommitmentPlan +from ._models_py3 import CommitmentPlanListResult +from ._models_py3 import CommitmentPlanProperties +from ._models_py3 import CommitmentQuota +from ._models_py3 import CommitmentTier +from ._models_py3 import CommitmentTierListResult +from ._models_py3 import Deployment +from ._models_py3 import DeploymentListResult +from ._models_py3 import DeploymentModel +from ._models_py3 import DeploymentProperties +from ._models_py3 import DeploymentScaleSettings +from ._models_py3 import DomainAvailability +from ._models_py3 import Encryption +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Identity +from ._models_py3 import IpRule +from ._models_py3 import KeyVaultProperties +from ._models_py3 import MetricName +from ._models_py3 import ModelDeprecationInfo +from ._models_py3 import NetworkRuleSet +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkResourceProperties +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProxyResource +from ._models_py3 import QuotaLimit +from ._models_py3 import RegenerateKeyParameters +from ._models_py3 import RequestMatchPattern +from ._models_py3 import Resource +from ._models_py3 import ResourceSku +from ._models_py3 import ResourceSkuListResult +from ._models_py3 import ResourceSkuRestrictionInfo +from ._models_py3 import ResourceSkuRestrictions +from ._models_py3 import Sku +from ._models_py3 import SkuAvailability +from ._models_py3 import SkuAvailabilityListResult +from ._models_py3 import SkuCapability +from ._models_py3 import SkuChangeInfo +from ._models_py3 import SystemData +from ._models_py3 import ThrottlingRule +from ._models_py3 import Usage +from ._models_py3 import UsageListResult +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import UserOwnedStorage +from ._models_py3 import VirtualNetworkRule + from ._cognitive_services_management_client_enums import ( ActionType, @@ -166,6 +102,8 @@ __all__ = [ 'Account', 'AccountListResult', + 'AccountModel', + 'AccountModelListResult', 'AccountProperties', 'AccountSku', 'AccountSkuListResult', @@ -197,6 +135,7 @@ 'IpRule', 'KeyVaultProperties', 'MetricName', + 'ModelDeprecationInfo', 'NetworkRuleSet', 'Operation', 'OperationDisplay', diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py index 79c6d0be3be2..c87a0716c018 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_cognitive_services_management_client_enums.py @@ -6,33 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. """ INTERNAL = "Internal" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -41,7 +26,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DeploymentProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the status of the resource at the time the operation was called. """ @@ -52,13 +37,13 @@ class DeploymentProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, FAILED = "Failed" SUCCEEDED = "Succeeded" -class DeploymentScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Deployment scale type. """ MANUAL = "Manual" -class HostingModel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HostingModel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Account hosting model. """ @@ -66,21 +51,21 @@ class HostingModel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONNECTED_CONTAINER = "ConnectedContainer" DISCONNECTED_CONTAINER = "DisconnectedContainer" -class KeyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """key name to generate (Key1|Key2) """ KEY1 = "Key1" KEY2 = "Key2" -class KeySource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enumerates the possible value of keySource for Encryption """ MICROSOFT_COGNITIVE_SERVICES = "Microsoft.CognitiveServices" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class NetworkRuleAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The default action when no rule from ipRules and from virtualNetworkRules match. This is only used after the bypass property has been evaluated. """ @@ -88,7 +73,7 @@ class NetworkRuleAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ALLOW = "Allow" DENY = "Deny" -class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" """ @@ -97,7 +82,7 @@ class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM = "system" USER_SYSTEM = "user,system" -class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current provisioning state. """ @@ -106,7 +91,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitive DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The private endpoint connection status. """ @@ -114,7 +99,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnum APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets the status of the cognitive services account at the time the operation was called. """ @@ -126,15 +111,14 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" RESOLVING_DNS = "ResolvingDNS" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Whether or not public endpoint access is allowed for this account. Value is optional but if - passed in, must be 'Enabled' or 'Disabled' +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Whether or not public endpoint access is allowed for this account. """ ENABLED = "Enabled" DISABLED = "Disabled" -class QuotaUsageStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QuotaUsageStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Cognitive Services account quota usage status. """ @@ -143,7 +127,7 @@ class QuotaUsageStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): IN_OVERAGE = "InOverage" UNKNOWN = "Unknown" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -152,21 +136,21 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" -class ResourceSkuRestrictionsReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of restrictions. """ LOCATION = "Location" ZONE = "Zone" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. """ @@ -177,7 +161,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PREMIUM = "Premium" ENTERPRISE = "Enterprise" -class UnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnitType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py deleted file mode 100644 index 3add4d32205a..000000000000 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py +++ /dev/null @@ -1,2308 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AzureEntityResource(Resource): - """The resource model definition for an Azure Resource Manager resource with an etag. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class Account(AzureEntityResource): - """Cognitive Services account is an Azure resource representing the provisioned account, it's type, location and SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - :param kind: The Kind of the resource. - :type kind: str - :param sku: The resource model definition representing SKU. - :type sku: ~azure.mgmt.cognitiveservices.models.Sku - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cognitiveservices.models.Identity - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The geo-location where the resource lives. - :type location: str - :param properties: Properties of Cognitive Services account. - :type properties: ~azure.mgmt.cognitiveservices.models.AccountProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AccountProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Account, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) - - -class AccountListResult(msrest.serialization.Model): - """The list of cognitive services accounts operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param next_link: The link used to get the next page of accounts. - :type next_link: str - :ivar value: Gets the list of Cognitive Services accounts and their properties. - :vartype value: list[~azure.mgmt.cognitiveservices.models.Account] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Account]'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = None - - -class AccountProperties(msrest.serialization.Model): - """Properties of Cognitive Services account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Gets the status of the cognitive services account at the time the - operation was called. Possible values include: "Accepted", "Creating", "Deleting", "Moving", - "Failed", "Succeeded", "ResolvingDNS". - :vartype provisioning_state: str or ~azure.mgmt.cognitiveservices.models.ProvisioningState - :ivar endpoint: Endpoint of the created account. - :vartype endpoint: str - :ivar internal_id: The internal identifier (deprecated, do not use this property). - :vartype internal_id: str - :ivar capabilities: Gets the capabilities of the cognitive services account. Each item - indicates the capability of a specific feature. The values are read-only and for reference - only. - :vartype capabilities: list[~azure.mgmt.cognitiveservices.models.SkuCapability] - :ivar is_migrated: If the resource is migrated from an existing key. - :vartype is_migrated: bool - :param migration_token: Resource migration token. - :type migration_token: str - :ivar sku_change_info: Sku change info of account. - :vartype sku_change_info: ~azure.mgmt.cognitiveservices.models.SkuChangeInfo - :param custom_sub_domain_name: Optional subdomain name used for token-based authentication. - :type custom_sub_domain_name: str - :param network_acls: A collection of rules governing the accessibility from specific network - locations. - :type network_acls: ~azure.mgmt.cognitiveservices.models.NetworkRuleSet - :param encryption: The encryption properties for this resource. - :type encryption: ~azure.mgmt.cognitiveservices.models.Encryption - :param user_owned_storage: The storage accounts for this resource. - :type user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] - :ivar private_endpoint_connections: The private endpoint connection associated with the - Cognitive Services account. - :vartype private_endpoint_connections: - list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] - :param public_network_access: Whether or not public endpoint access is allowed for this - account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.cognitiveservices.models.PublicNetworkAccess - :param api_properties: The api properties for special APIs. - :type api_properties: ~azure.mgmt.cognitiveservices.models.ApiProperties - :ivar date_created: Gets the date of cognitive services account creation. - :vartype date_created: str - :ivar call_rate_limit: The call rate limit Cognitive Services account. - :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit - :ivar quota_limit: - :vartype quota_limit: ~azure.mgmt.cognitiveservices.models.QuotaLimit - :param restrict_outbound_network_access: - :type restrict_outbound_network_access: bool - :param allowed_fqdn_list: - :type allowed_fqdn_list: list[str] - :param disable_local_auth: - :type disable_local_auth: bool - :ivar endpoints: Dictionary of :code:``. - :vartype endpoints: dict[str, str] - :param restore: - :type restore: bool - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'endpoint': {'readonly': True}, - 'internal_id': {'readonly': True}, - 'capabilities': {'readonly': True}, - 'is_migrated': {'readonly': True}, - 'sku_change_info': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'date_created': {'readonly': True}, - 'call_rate_limit': {'readonly': True}, - 'quota_limit': {'readonly': True}, - 'endpoints': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - 'internal_id': {'key': 'internalId', 'type': 'str'}, - 'capabilities': {'key': 'capabilities', 'type': '[SkuCapability]'}, - 'is_migrated': {'key': 'isMigrated', 'type': 'bool'}, - 'migration_token': {'key': 'migrationToken', 'type': 'str'}, - 'sku_change_info': {'key': 'skuChangeInfo', 'type': 'SkuChangeInfo'}, - 'custom_sub_domain_name': {'key': 'customSubDomainName', 'type': 'str'}, - 'network_acls': {'key': 'networkAcls', 'type': 'NetworkRuleSet'}, - 'encryption': {'key': 'encryption', 'type': 'Encryption'}, - 'user_owned_storage': {'key': 'userOwnedStorage', 'type': '[UserOwnedStorage]'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'api_properties': {'key': 'apiProperties', 'type': 'ApiProperties'}, - 'date_created': {'key': 'dateCreated', 'type': 'str'}, - 'call_rate_limit': {'key': 'callRateLimit', 'type': 'CallRateLimit'}, - 'quota_limit': {'key': 'quotaLimit', 'type': 'QuotaLimit'}, - 'restrict_outbound_network_access': {'key': 'restrictOutboundNetworkAccess', 'type': 'bool'}, - 'allowed_fqdn_list': {'key': 'allowedFqdnList', 'type': '[str]'}, - 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, - 'endpoints': {'key': 'endpoints', 'type': '{str}'}, - 'restore': {'key': 'restore', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.endpoint = None - self.internal_id = None - self.capabilities = None - self.is_migrated = None - self.migration_token = kwargs.get('migration_token', None) - self.sku_change_info = None - self.custom_sub_domain_name = kwargs.get('custom_sub_domain_name', None) - self.network_acls = kwargs.get('network_acls', None) - self.encryption = kwargs.get('encryption', None) - self.user_owned_storage = kwargs.get('user_owned_storage', None) - self.private_endpoint_connections = None - self.public_network_access = kwargs.get('public_network_access', None) - self.api_properties = kwargs.get('api_properties', None) - self.date_created = None - self.call_rate_limit = None - self.quota_limit = None - self.restrict_outbound_network_access = kwargs.get('restrict_outbound_network_access', None) - self.allowed_fqdn_list = kwargs.get('allowed_fqdn_list', None) - self.disable_local_auth = kwargs.get('disable_local_auth', None) - self.endpoints = None - self.restore = kwargs.get('restore', None) - - -class AccountSku(msrest.serialization.Model): - """Cognitive Services resource type and SKU. - - :param resource_type: Resource Namespace and Type. - :type resource_type: str - :param sku: The SKU of Cognitive Services account. - :type sku: ~azure.mgmt.cognitiveservices.models.Sku - """ - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountSku, self).__init__(**kwargs) - self.resource_type = kwargs.get('resource_type', None) - self.sku = kwargs.get('sku', None) - - -class AccountSkuListResult(msrest.serialization.Model): - """The list of cognitive services accounts operation response. - - :param value: Gets the list of Cognitive Services accounts and their properties. - :type value: list[~azure.mgmt.cognitiveservices.models.AccountSku] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccountSku]'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountSkuListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ApiKeys(msrest.serialization.Model): - """The access keys for the cognitive services account. - - :param key1: Gets the value of key 1. - :type key1: str - :param key2: Gets the value of key 2. - :type key2: str - """ - - _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiKeys, self).__init__(**kwargs) - self.key1 = kwargs.get('key1', None) - self.key2 = kwargs.get('key2', None) - - -class ApiProperties(msrest.serialization.Model): - """The api properties for special APIs. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. - :type qna_runtime_endpoint: str - :param qna_azure_search_endpoint_key: (QnAMaker Only) The Azure Search endpoint key of - QnAMaker. - :type qna_azure_search_endpoint_key: str - :param qna_azure_search_endpoint_id: (QnAMaker Only) The Azure Search endpoint id of QnAMaker. - :type qna_azure_search_endpoint_id: str - :param statistics_enabled: (Bing Search Only) The flag to enable statistics of Bing Search. - :type statistics_enabled: bool - :param event_hub_connection_string: (Personalization Only) The flag to enable statistics of - Bing Search. - :type event_hub_connection_string: str - :param storage_account_connection_string: (Personalization Only) The storage account connection - string. - :type storage_account_connection_string: str - :param aad_client_id: (Metrics Advisor Only) The Azure AD Client Id (Application Id). - :type aad_client_id: str - :param aad_tenant_id: (Metrics Advisor Only) The Azure AD Tenant Id. - :type aad_tenant_id: str - :param super_user: (Metrics Advisor Only) The super user of Metrics Advisor. - :type super_user: str - :param website_name: (Metrics Advisor Only) The website name of Metrics Advisor. - :type website_name: str - """ - - _validation = { - 'event_hub_connection_string': {'max_length': 1000, 'min_length': 0, 'pattern': r'^( *)Endpoint=sb://(.*);( *)SharedAccessKeyName=(.*);( *)SharedAccessKey=(.*)$'}, - 'storage_account_connection_string': {'max_length': 1000, 'min_length': 0, 'pattern': r'^(( *)DefaultEndpointsProtocol=(http|https)( *);( *))?AccountName=(.*)AccountKey=(.*)EndpointSuffix=(.*)$'}, - 'aad_client_id': {'max_length': 500, 'min_length': 0}, - 'aad_tenant_id': {'max_length': 500, 'min_length': 0}, - 'super_user': {'max_length': 500, 'min_length': 0}, - 'website_name': {'max_length': 500, 'min_length': 0}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'qna_runtime_endpoint': {'key': 'qnaRuntimeEndpoint', 'type': 'str'}, - 'qna_azure_search_endpoint_key': {'key': 'qnaAzureSearchEndpointKey', 'type': 'str'}, - 'qna_azure_search_endpoint_id': {'key': 'qnaAzureSearchEndpointId', 'type': 'str'}, - 'statistics_enabled': {'key': 'statisticsEnabled', 'type': 'bool'}, - 'event_hub_connection_string': {'key': 'eventHubConnectionString', 'type': 'str'}, - 'storage_account_connection_string': {'key': 'storageAccountConnectionString', 'type': 'str'}, - 'aad_client_id': {'key': 'aadClientId', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'super_user': {'key': 'superUser', 'type': 'str'}, - 'website_name': {'key': 'websiteName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiProperties, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.qna_runtime_endpoint = kwargs.get('qna_runtime_endpoint', None) - self.qna_azure_search_endpoint_key = kwargs.get('qna_azure_search_endpoint_key', None) - self.qna_azure_search_endpoint_id = kwargs.get('qna_azure_search_endpoint_id', None) - self.statistics_enabled = kwargs.get('statistics_enabled', None) - self.event_hub_connection_string = kwargs.get('event_hub_connection_string', None) - self.storage_account_connection_string = kwargs.get('storage_account_connection_string', None) - self.aad_client_id = kwargs.get('aad_client_id', None) - self.aad_tenant_id = kwargs.get('aad_tenant_id', None) - self.super_user = kwargs.get('super_user', None) - self.website_name = kwargs.get('website_name', None) - - -class CallRateLimit(msrest.serialization.Model): - """The call rate limit Cognitive Services account. - - :param count: The count value of Call Rate Limit. - :type count: float - :param renewal_period: The renewal period in seconds of Call Rate Limit. - :type renewal_period: float - :param rules: - :type rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] - """ - - _attribute_map = { - 'count': {'key': 'count', 'type': 'float'}, - 'renewal_period': {'key': 'renewalPeriod', 'type': 'float'}, - 'rules': {'key': 'rules', 'type': '[ThrottlingRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(CallRateLimit, self).__init__(**kwargs) - self.count = kwargs.get('count', None) - self.renewal_period = kwargs.get('renewal_period', None) - self.rules = kwargs.get('rules', None) - - -class CheckDomainAvailabilityParameter(msrest.serialization.Model): - """Check Domain availability parameter. - - All required parameters must be populated in order to send to Azure. - - :param subdomain_name: Required. The subdomain name to use. - :type subdomain_name: str - :param type: Required. The Type of the resource. - :type type: str - :param kind: The Kind of the resource. - :type kind: str - """ - - _validation = { - 'subdomain_name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'subdomain_name': {'key': 'subdomainName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckDomainAvailabilityParameter, self).__init__(**kwargs) - self.subdomain_name = kwargs['subdomain_name'] - self.type = kwargs['type'] - self.kind = kwargs.get('kind', None) - - -class CheckSkuAvailabilityParameter(msrest.serialization.Model): - """Check SKU availability parameter. - - All required parameters must be populated in order to send to Azure. - - :param skus: Required. The SKU of the resource. - :type skus: list[str] - :param kind: Required. The Kind of the resource. - :type kind: str - :param type: Required. The Type of the resource. - :type type: str - """ - - _validation = { - 'skus': {'required': True}, - 'kind': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'skus': {'key': 'skus', 'type': '[str]'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckSkuAvailabilityParameter, self).__init__(**kwargs) - self.skus = kwargs['skus'] - self.kind = kwargs['kind'] - self.type = kwargs['type'] - - -class CommitmentCost(msrest.serialization.Model): - """Cognitive Services account commitment cost. - - :param commitment_meter_id: Commitment meter Id. - :type commitment_meter_id: str - :param overage_meter_id: Overage meter Id. - :type overage_meter_id: str - """ - - _attribute_map = { - 'commitment_meter_id': {'key': 'commitmentMeterId', 'type': 'str'}, - 'overage_meter_id': {'key': 'overageMeterId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentCost, self).__init__(**kwargs) - self.commitment_meter_id = kwargs.get('commitment_meter_id', None) - self.overage_meter_id = kwargs.get('overage_meter_id', None) - - -class CommitmentPeriod(msrest.serialization.Model): - """Cognitive Services account commitment period. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tier: Commitment period commitment tier. - :type tier: str - :param count: Commitment period commitment count. - :type count: int - :ivar quota: Cognitive Services account commitment quota. - :vartype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota - :ivar start_date: Commitment period start date. - :vartype start_date: str - :ivar end_date: Commitment period end date. - :vartype end_date: str - """ - - _validation = { - 'quota': {'readonly': True}, - 'start_date': {'readonly': True}, - 'end_date': {'readonly': True}, - } - - _attribute_map = { - 'tier': {'key': 'tier', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, - 'quota': {'key': 'quota', 'type': 'CommitmentQuota'}, - 'start_date': {'key': 'startDate', 'type': 'str'}, - 'end_date': {'key': 'endDate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentPeriod, self).__init__(**kwargs) - self.tier = kwargs.get('tier', None) - self.count = kwargs.get('count', None) - self.quota = None - self.start_date = None - self.end_date = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class CommitmentPlan(ProxyResource): - """Cognitive Services account commitment plan. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :ivar etag: Resource Etag. - :vartype etag: str - :param properties: Properties of Cognitive Services account commitment plan. - :type properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CommitmentPlanProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentPlan, self).__init__(**kwargs) - self.system_data = None - self.etag = None - self.properties = kwargs.get('properties', None) - - -class CommitmentPlanListResult(msrest.serialization.Model): - """The list of cognitive services accounts operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param next_link: The link used to get the next page of CommitmentPlan. - :type next_link: str - :ivar value: Gets the list of Cognitive Services accounts CommitmentPlan and their properties. - :vartype value: list[~azure.mgmt.cognitiveservices.models.CommitmentPlan] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[CommitmentPlan]'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentPlanListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = None - - -class CommitmentPlanProperties(msrest.serialization.Model): - """Properties of Cognitive Services account commitment plan. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param hosting_model: Account hosting model. Possible values include: "Web", - "ConnectedContainer", "DisconnectedContainer". - :type hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel - :param plan_type: Commitment plan type. - :type plan_type: str - :param current: Cognitive Services account commitment period. - :type current: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod - :param auto_renew: AutoRenew commitment plan. - :type auto_renew: bool - :param next: Cognitive Services account commitment period. - :type next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod - :ivar last: Cognitive Services account commitment period. - :vartype last: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod - """ - - _validation = { - 'last': {'readonly': True}, - } - - _attribute_map = { - 'hosting_model': {'key': 'hostingModel', 'type': 'str'}, - 'plan_type': {'key': 'planType', 'type': 'str'}, - 'current': {'key': 'current', 'type': 'CommitmentPeriod'}, - 'auto_renew': {'key': 'autoRenew', 'type': 'bool'}, - 'next': {'key': 'next', 'type': 'CommitmentPeriod'}, - 'last': {'key': 'last', 'type': 'CommitmentPeriod'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentPlanProperties, self).__init__(**kwargs) - self.hosting_model = kwargs.get('hosting_model', None) - self.plan_type = kwargs.get('plan_type', None) - self.current = kwargs.get('current', None) - self.auto_renew = kwargs.get('auto_renew', None) - self.next = kwargs.get('next', None) - self.last = None - - -class CommitmentQuota(msrest.serialization.Model): - """Cognitive Services account commitment quota. - - :param quantity: Commitment quota quantity. - :type quantity: long - :param unit: Commitment quota unit. - :type unit: str - """ - - _attribute_map = { - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'unit': {'key': 'unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentQuota, self).__init__(**kwargs) - self.quantity = kwargs.get('quantity', None) - self.unit = kwargs.get('unit', None) - - -class CommitmentTier(msrest.serialization.Model): - """Cognitive Services account commitment tier. - - :param kind: The Kind of the resource. - :type kind: str - :param sku_name: The name of the SKU. Ex - P3. It is typically a letter+number code. - :type sku_name: str - :param hosting_model: Account hosting model. Possible values include: "Web", - "ConnectedContainer", "DisconnectedContainer". - :type hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel - :param plan_type: Commitment plan type. - :type plan_type: str - :param tier: Commitment period commitment tier. - :type tier: str - :param max_count: Commitment period commitment max count. - :type max_count: int - :param quota: Cognitive Services account commitment quota. - :type quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota - :param cost: Cognitive Services account commitment cost. - :type cost: ~azure.mgmt.cognitiveservices.models.CommitmentCost - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'sku_name': {'key': 'skuName', 'type': 'str'}, - 'hosting_model': {'key': 'hostingModel', 'type': 'str'}, - 'plan_type': {'key': 'planType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'max_count': {'key': 'maxCount', 'type': 'int'}, - 'quota': {'key': 'quota', 'type': 'CommitmentQuota'}, - 'cost': {'key': 'cost', 'type': 'CommitmentCost'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentTier, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.sku_name = kwargs.get('sku_name', None) - self.hosting_model = kwargs.get('hosting_model', None) - self.plan_type = kwargs.get('plan_type', None) - self.tier = kwargs.get('tier', None) - self.max_count = kwargs.get('max_count', None) - self.quota = kwargs.get('quota', None) - self.cost = kwargs.get('cost', None) - - -class CommitmentTierListResult(msrest.serialization.Model): - """The list of cognitive services accounts operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param next_link: The link used to get the next page of CommitmentTier. - :type next_link: str - :ivar value: Gets the list of Cognitive Services accounts CommitmentTier and their properties. - :vartype value: list[~azure.mgmt.cognitiveservices.models.CommitmentTier] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[CommitmentTier]'}, - } - - def __init__( - self, - **kwargs - ): - super(CommitmentTierListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = None - - -class Deployment(ProxyResource): - """Cognitive Services account deployment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :ivar etag: Resource Etag. - :vartype etag: str - :param properties: Properties of Cognitive Services account deployment. - :type properties: ~azure.mgmt.cognitiveservices.models.DeploymentProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Deployment, self).__init__(**kwargs) - self.system_data = None - self.etag = None - self.properties = kwargs.get('properties', None) - - -class DeploymentListResult(msrest.serialization.Model): - """The list of cognitive services accounts operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param next_link: The link used to get the next page of Deployment. - :type next_link: str - :ivar value: Gets the list of Cognitive Services accounts Deployment and their properties. - :vartype value: list[~azure.mgmt.cognitiveservices.models.Deployment] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Deployment]'}, - } - - def __init__( - self, - **kwargs - ): - super(DeploymentListResult, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = None - - -class DeploymentModel(msrest.serialization.Model): - """Properties of Cognitive Services account deployment model. - - :param format: Deployment model format. - :type format: str - :param name: Deployment model name. - :type name: str - :param version: Deployment model version. - :type version: str - """ - - _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeploymentModel, self).__init__(**kwargs) - self.format = kwargs.get('format', None) - self.name = kwargs.get('name', None) - self.version = kwargs.get('version', None) - - -class DeploymentProperties(msrest.serialization.Model): - """Properties of Cognitive Services account deployment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Gets the status of the resource at the time the operation was called. - Possible values include: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded". - :vartype provisioning_state: str or - ~azure.mgmt.cognitiveservices.models.DeploymentProvisioningState - :param model: Properties of Cognitive Services account deployment model. - :type model: ~azure.mgmt.cognitiveservices.models.DeploymentModel - :param scale_settings: Properties of Cognitive Services account deployment model. - :type scale_settings: ~azure.mgmt.cognitiveservices.models.DeploymentScaleSettings - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'model': {'key': 'model', 'type': 'DeploymentModel'}, - 'scale_settings': {'key': 'scaleSettings', 'type': 'DeploymentScaleSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(DeploymentProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.model = kwargs.get('model', None) - self.scale_settings = kwargs.get('scale_settings', None) - - -class DeploymentScaleSettings(msrest.serialization.Model): - """Properties of Cognitive Services account deployment model. - - :param scale_type: Deployment scale type. Possible values include: "Manual". - :type scale_type: str or ~azure.mgmt.cognitiveservices.models.DeploymentScaleType - :param capacity: Deployment capacity. - :type capacity: int - """ - - _attribute_map = { - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DeploymentScaleSettings, self).__init__(**kwargs) - self.scale_type = kwargs.get('scale_type', None) - self.capacity = kwargs.get('capacity', None) - - -class DomainAvailability(msrest.serialization.Model): - """Domain availability. - - :param is_subdomain_available: Indicates the given SKU is available or not. - :type is_subdomain_available: bool - :param reason: Reason why the SKU is not available. - :type reason: str - :param subdomain_name: The subdomain name to use. - :type subdomain_name: str - :param type: The Type of the resource. - :type type: str - :param kind: The Kind of the resource. - :type kind: str - """ - - _attribute_map = { - 'is_subdomain_available': {'key': 'isSubdomainAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'subdomain_name': {'key': 'subdomainName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DomainAvailability, self).__init__(**kwargs) - self.is_subdomain_available = kwargs.get('is_subdomain_available', None) - self.reason = kwargs.get('reason', None) - self.subdomain_name = kwargs.get('subdomain_name', None) - self.type = kwargs.get('type', None) - self.kind = kwargs.get('kind', None) - - -class Encryption(msrest.serialization.Model): - """Properties to configure Encryption. - - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties - :param key_source: Enumerates the possible value of keySource for Encryption. Possible values - include: "Microsoft.CognitiveServices", "Microsoft.KeyVault". Default value: - "Microsoft.KeyVault". - :type key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource - """ - - _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Encryption, self).__init__(**kwargs) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - self.key_source = kwargs.get('key_source', "Microsoft.KeyVault") - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.cognitiveservices.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.cognitiveservices.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.cognitiveservices.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Identity(msrest.serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: The identity type. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned". - :type type: str or ~azure.mgmt.cognitiveservices.models.ResourceIdentityType - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :param user_assigned_identities: The list of user assigned identities associated with the - resource. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - :type user_assigned_identities: dict[str, - ~azure.mgmt.cognitiveservices.models.UserAssignedIdentity] - """ - - _validation = { - 'tenant_id': {'readonly': True}, - 'principal_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.tenant_id = None - self.principal_id = None - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class IpRule(msrest.serialization.Model): - """A rule governing the accessibility from a specific ip address or ip range. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple - IP address) or '124.56.78.0/24' (all addresses that start with 124.56.78). - :type value: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IpRule, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class KeyVaultProperties(msrest.serialization.Model): - """Properties to configure keyVault Properties. - - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_version: Version of the Key from KeyVault. - :type key_version: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param identity_client_id: - :type identity_client_id: str - """ - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultProperties, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) - self.key_version = kwargs.get('key_version', None) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - self.identity_client_id = kwargs.get('identity_client_id', None) - - -class MetricName(msrest.serialization.Model): - """A metric name. - - :param value: The name of the metric. - :type value: str - :param localized_value: The friendly name of the metric. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricName, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class NetworkRuleSet(msrest.serialization.Model): - """A set of rules governing the network accessibility. - - :param default_action: The default action when no rule from ipRules and from - virtualNetworkRules match. This is only used after the bypass property has been evaluated. - Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.cognitiveservices.models.NetworkRuleAction - :param ip_rules: The list of IP address rules. - :type ip_rules: list[~azure.mgmt.cognitiveservices.models.IpRule] - :param virtual_network_rules: The list of virtual network rules. - :type virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] - """ - - _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IpRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', None) - self.ip_rules = kwargs.get('ip_rules', None) - self.virtual_network_rules = kwargs.get('virtual_network_rules', None) - - -class Operation(msrest.serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :param display: Localized display information for this particular operation. - :type display: ~azure.mgmt.cognitiveservices.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", - "system", "user,system". - :vartype origin: str or ~azure.mgmt.cognitiveservices.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". - :vartype action_type: str or ~azure.mgmt.cognitiveservices.models.ActionType - """ - - _validation = { - 'name': {'readonly': True}, - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, - 'action_type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = kwargs.get('display', None) - self.origin = None - self.action_type = None - - -class OperationDisplay(msrest.serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.cognitiveservices.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(AzureEntityResource): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - :param properties: Resource properties. - :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :param location: The location of the private endpoint connection. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.system_data = None - self.location = kwargs.get('location', None) - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """A list of private endpoint connections. - - :param value: Array of private endpoint connections. - :type value: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """Properties of the PrivateEndpointConnectProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~azure.mgmt.cognitiveservices.models.PrivateEndpoint - :param private_link_service_connection_state: Required. A collection of information about the - state of the connection between service consumer and provider. - :type private_link_service_connection_state: - ~azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProvisioningState - :param group_ids: The private link resource group ids. - :type group_ids: list[str] - """ - - _validation = { - 'private_link_service_connection_state': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'group_ids': {'key': 'groupIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - self.provisioning_state = None - self.group_ids = kwargs.get('group_ids', None) - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param properties: Resource properties. - :type properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - :param value: Array of private link resources. - :type value: list[~azure.mgmt.cognitiveservices.models.PrivateLinkResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkResourceProperties(msrest.serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] - :ivar display_name: The private link resource display name. - :vartype display_name: str - """ - - _validation = { - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'display_name': {'readonly': True}, - } - - _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceProperties, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = kwargs.get('required_zone_names', None) - self.display_name = None - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """A collection of information about the state of the connection between service consumer and provider. - - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or - ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :type actions_required: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - self.actions_required = kwargs.get('actions_required', None) - - -class QuotaLimit(msrest.serialization.Model): - """QuotaLimit. - - :param count: - :type count: float - :param renewal_period: - :type renewal_period: float - :param rules: - :type rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] - """ - - _attribute_map = { - 'count': {'key': 'count', 'type': 'float'}, - 'renewal_period': {'key': 'renewalPeriod', 'type': 'float'}, - 'rules': {'key': 'rules', 'type': '[ThrottlingRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaLimit, self).__init__(**kwargs) - self.count = kwargs.get('count', None) - self.renewal_period = kwargs.get('renewal_period', None) - self.rules = kwargs.get('rules', None) - - -class RegenerateKeyParameters(msrest.serialization.Model): - """Regenerate key parameters. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. key name to generate (Key1|Key2). Possible values include: "Key1", - "Key2". - :type key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName - """ - - _validation = { - 'key_name': {'required': True}, - } - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateKeyParameters, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - - -class RequestMatchPattern(msrest.serialization.Model): - """RequestMatchPattern. - - :param path: - :type path: str - :param method: - :type method: str - """ - - _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RequestMatchPattern, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.method = kwargs.get('method', None) - - -class ResourceSku(msrest.serialization.Model): - """Describes an available Cognitive Services SKU. - - :param resource_type: The type of resource the SKU applies to. - :type resource_type: str - :param name: The name of SKU. - :type name: str - :param tier: Specifies the tier of Cognitive Services account. - :type tier: str - :param kind: The Kind of resources that are supported in this SKU. - :type kind: str - :param locations: The set of locations that the SKU is available. - :type locations: list[str] - :param restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :type restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] - """ - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSku, self).__init__(**kwargs) - self.resource_type = kwargs.get('resource_type', None) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - self.kind = kwargs.get('kind', None) - self.locations = kwargs.get('locations', None) - self.restrictions = kwargs.get('restrictions', None) - - -class ResourceSkuListResult(msrest.serialization.Model): - """The Get Skus operation response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of skus available for the subscription. - :type value: list[~azure.mgmt.cognitiveservices.models.ResourceSku] - :param next_link: The uri to fetch the next page of Skus. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ResourceSkuRestrictionInfo(msrest.serialization.Model): - """ResourceSkuRestrictionInfo. - - :param locations: Locations where the SKU is restricted. - :type locations: list[str] - :param zones: List of availability zones where the SKU is restricted. - :type zones: list[str] - """ - - _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) - self.locations = kwargs.get('locations', None) - self.zones = kwargs.get('zones', None) - - -class ResourceSkuRestrictions(msrest.serialization.Model): - """Describes restrictions of a SKU. - - :param type: The type of restrictions. Possible values include: "Location", "Zone". - :type type: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType - :param values: The value of restrictions. If the restriction type is set to location. This - would be different locations where the SKU is restricted. - :type values: list[str] - :param restriction_info: The information about the restriction where the SKU cannot be used. - :type restriction_info: ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo - :param reason_code: The reason for restriction. Possible values include: "QuotaId", - "NotAvailableForSubscription". - :type reason_code: str or - ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ResourceSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuRestrictions, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.values = kwargs.get('values', None) - self.restriction_info = kwargs.get('restriction_info', None) - self.reason_code = kwargs.get('reason_code', None) - - -class Sku(msrest.serialization.Model): - """The resource model definition representing SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param tier: This field is required to be implemented by the Resource Provider if the service - has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", - "Standard", "Premium", "Enterprise". - :type tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, - this would be the standalone code. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: If the SKU supports scale out/in then the capacity integer should be included. - If scale out/in is not possible for the resource this may be omitted. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.size = kwargs.get('size', None) - self.family = kwargs.get('family', None) - self.capacity = kwargs.get('capacity', None) - - -class SkuAvailability(msrest.serialization.Model): - """SKU availability. - - :param kind: The Kind of the resource. - :type kind: str - :param type: The Type of the resource. - :type type: str - :param sku_name: The SKU of Cognitive Services account. - :type sku_name: str - :param sku_available: Indicates the given SKU is available or not. - :type sku_available: bool - :param reason: Reason why the SKU is not available. - :type reason: str - :param message: Additional error message. - :type message: str - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku_name': {'key': 'skuName', 'type': 'str'}, - 'sku_available': {'key': 'skuAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuAvailability, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.type = kwargs.get('type', None) - self.sku_name = kwargs.get('sku_name', None) - self.sku_available = kwargs.get('sku_available', None) - self.reason = kwargs.get('reason', None) - self.message = kwargs.get('message', None) - - -class SkuAvailabilityListResult(msrest.serialization.Model): - """Check SKU availability result list. - - :param value: Check SKU availability result list. - :type value: list[~azure.mgmt.cognitiveservices.models.SkuAvailability] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuAvailability]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuAvailabilityListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SkuCapability(msrest.serialization.Model): - """SkuCapability indicates the capability of a certain feature. - - :param name: The name of the SkuCapability. - :type name: str - :param value: The value of the SkuCapability. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCapability, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class SkuChangeInfo(msrest.serialization.Model): - """Sku change info of account. - - :param count_of_downgrades: Gets the count of downgrades. - :type count_of_downgrades: float - :param count_of_upgrades_after_downgrades: Gets the count of upgrades after downgrades. - :type count_of_upgrades_after_downgrades: float - :param last_change_date: Gets the last change date. - :type last_change_date: str - """ - - _attribute_map = { - 'count_of_downgrades': {'key': 'countOfDowngrades', 'type': 'float'}, - 'count_of_upgrades_after_downgrades': {'key': 'countOfUpgradesAfterDowngrades', 'type': 'float'}, - 'last_change_date': {'key': 'lastChangeDate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuChangeInfo, self).__init__(**kwargs) - self.count_of_downgrades = kwargs.get('count_of_downgrades', None) - self.count_of_upgrades_after_downgrades = kwargs.get('count_of_upgrades_after_downgrades', None) - self.last_change_date = kwargs.get('last_change_date', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class ThrottlingRule(msrest.serialization.Model): - """ThrottlingRule. - - :param key: - :type key: str - :param renewal_period: - :type renewal_period: float - :param count: - :type count: float - :param min_count: - :type min_count: float - :param dynamic_throttling_enabled: - :type dynamic_throttling_enabled: bool - :param match_patterns: - :type match_patterns: list[~azure.mgmt.cognitiveservices.models.RequestMatchPattern] - """ - - _attribute_map = { - 'key': {'key': 'key', 'type': 'str'}, - 'renewal_period': {'key': 'renewalPeriod', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'float'}, - 'min_count': {'key': 'minCount', 'type': 'float'}, - 'dynamic_throttling_enabled': {'key': 'dynamicThrottlingEnabled', 'type': 'bool'}, - 'match_patterns': {'key': 'matchPatterns', 'type': '[RequestMatchPattern]'}, - } - - def __init__( - self, - **kwargs - ): - super(ThrottlingRule, self).__init__(**kwargs) - self.key = kwargs.get('key', None) - self.renewal_period = kwargs.get('renewal_period', None) - self.count = kwargs.get('count', None) - self.min_count = kwargs.get('min_count', None) - self.dynamic_throttling_enabled = kwargs.get('dynamic_throttling_enabled', None) - self.match_patterns = kwargs.get('match_patterns', None) - - -class Usage(msrest.serialization.Model): - """The usage data for a usage request. - - :param unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", - "Percent", "CountPerSecond", "BytesPerSecond", "Milliseconds". - :type unit: str or ~azure.mgmt.cognitiveservices.models.UnitType - :param name: The name information for the metric. - :type name: ~azure.mgmt.cognitiveservices.models.MetricName - :param quota_period: The quota period used to summarize the usage values. - :type quota_period: str - :param limit: Maximum value for this metric. - :type limit: float - :param current_value: Current value for this metric. - :type current_value: float - :param next_reset_time: Next reset time for current quota. - :type next_reset_time: str - :param status: Cognitive Services account quota usage status. Possible values include: - "Included", "Blocked", "InOverage", "Unknown". - :type status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus - """ - - _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'float'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'next_reset_time': {'key': 'nextResetTime', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Usage, self).__init__(**kwargs) - self.unit = kwargs.get('unit', None) - self.name = kwargs.get('name', None) - self.quota_period = kwargs.get('quota_period', None) - self.limit = kwargs.get('limit', None) - self.current_value = kwargs.get('current_value', None) - self.next_reset_time = kwargs.get('next_reset_time', None) - self.status = kwargs.get('status', None) - - -class UsageListResult(msrest.serialization.Model): - """The response to a list usage request. - - :param value: The list of usages for Cognitive Service account. - :type value: list[~azure.mgmt.cognitiveservices.models.Usage] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UserAssignedIdentity(msrest.serialization.Model): - """User-assigned managed identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: Azure Active Directory principal ID associated with this Identity. - :vartype principal_id: str - :ivar client_id: Client App Id associated with this identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class UserOwnedStorage(msrest.serialization.Model): - """The user owned storage for Cognitive Services account. - - :param resource_id: Full resource id of a Microsoft.Storage resource. - :type resource_id: str - :param identity_client_id: - :type identity_client_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserOwnedStorage, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.identity_client_id = kwargs.get('identity_client_id', None) - - -class VirtualNetworkRule(msrest.serialization.Model): - """A rule governing the accessibility from a specific virtual network. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Full resource id of a vnet subnet, such as - '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - :type id: str - :param state: Gets the state of virtual network rule. - :type state: str - :param ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. - :type ignore_missing_vnet_service_endpoint: bool - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkRule, self).__init__(**kwargs) - self.id = kwargs['id'] - self.state = kwargs.get('state', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py index 0090c012f4e5..c1e81057be51 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models_py3.py @@ -46,6 +46,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -87,6 +89,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureEntityResource, self).__init__(**kwargs) self.etag = None @@ -106,20 +110,20 @@ class Account(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :param kind: The Kind of the resource. - :type kind: str - :param sku: The resource model definition representing SKU. - :type sku: ~azure.mgmt.cognitiveservices.models.Sku - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.cognitiveservices.models.Identity + :ivar kind: The Kind of the resource. + :vartype kind: str + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cognitiveservices.models.Identity :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The geo-location where the resource lives. - :type location: str - :param properties: Properties of Cognitive Services account. - :type properties: ~azure.mgmt.cognitiveservices.models.AccountProperties + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar properties: Properties of Cognitive Services account. + :vartype properties: ~azure.mgmt.cognitiveservices.models.AccountProperties """ _validation = { @@ -155,6 +159,20 @@ def __init__( properties: Optional["AccountProperties"] = None, **kwargs ): + """ + :keyword kind: The Kind of the resource. + :paramtype kind: str + :keyword sku: The resource model definition representing SKU. + :paramtype sku: ~azure.mgmt.cognitiveservices.models.Sku + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.cognitiveservices.models.Identity + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Properties of Cognitive Services account. + :paramtype properties: ~azure.mgmt.cognitiveservices.models.AccountProperties + """ super(Account, self).__init__(**kwargs) self.kind = kind self.sku = sku @@ -170,8 +188,8 @@ class AccountListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param next_link: The link used to get the next page of accounts. - :type next_link: str + :ivar next_link: The link used to get the next page of accounts. + :vartype next_link: str :ivar value: Gets the list of Cognitive Services accounts and their properties. :vartype value: list[~azure.mgmt.cognitiveservices.models.Account] """ @@ -191,11 +209,160 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of accounts. + :paramtype next_link: str + """ super(AccountListResult, self).__init__(**kwargs) self.next_link = next_link self.value = None +class DeploymentModel(msrest.serialization.Model): + """Properties of Cognitive Services account deployment model. + + :ivar format: Deployment model format. + :vartype format: str + :ivar name: Deployment model name. + :vartype name: str + :ivar version: Deployment model version. + :vartype version: str + """ + + _attribute_map = { + 'format': {'key': 'format', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__( + self, + *, + format: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): + """ + :keyword format: Deployment model format. + :paramtype format: str + :keyword name: Deployment model name. + :paramtype name: str + :keyword version: Deployment model version. + :paramtype version: str + """ + super(DeploymentModel, self).__init__(**kwargs) + self.format = format + self.name = name + self.version = version + + +class AccountModel(DeploymentModel): + """Cognitive Services account Model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar format: Deployment model format. + :vartype format: str + :ivar name: Deployment model name. + :vartype name: str + :ivar version: Deployment model version. + :vartype version: str + :ivar base_model: Base Model Identifier. + :vartype base_model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar max_capacity: The max capacity. + :vartype max_capacity: int + :ivar capabilities: The capabilities. + :vartype capabilities: dict[str, str] + :ivar deprecation: Cognitive Services account ModelDeprecationInfo. + :vartype deprecation: ~azure.mgmt.cognitiveservices.models.ModelDeprecationInfo + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + """ + + _validation = { + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'format': {'key': 'format', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + 'base_model': {'key': 'baseModel', 'type': 'DeploymentModel'}, + 'max_capacity': {'key': 'maxCapacity', 'type': 'int'}, + 'capabilities': {'key': 'capabilities', 'type': '{str}'}, + 'deprecation': {'key': 'deprecation', 'type': 'ModelDeprecationInfo'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + format: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + base_model: Optional["DeploymentModel"] = None, + max_capacity: Optional[int] = None, + capabilities: Optional[Dict[str, str]] = None, + deprecation: Optional["ModelDeprecationInfo"] = None, + **kwargs + ): + """ + :keyword format: Deployment model format. + :paramtype format: str + :keyword name: Deployment model name. + :paramtype name: str + :keyword version: Deployment model version. + :paramtype version: str + :keyword base_model: Base Model Identifier. + :paramtype base_model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :keyword max_capacity: The max capacity. + :paramtype max_capacity: int + :keyword capabilities: The capabilities. + :paramtype capabilities: dict[str, str] + :keyword deprecation: Cognitive Services account ModelDeprecationInfo. + :paramtype deprecation: ~azure.mgmt.cognitiveservices.models.ModelDeprecationInfo + """ + super(AccountModel, self).__init__(format=format, name=name, version=version, **kwargs) + self.base_model = base_model + self.max_capacity = max_capacity + self.capabilities = capabilities + self.deprecation = deprecation + self.system_data = None + + +class AccountModelListResult(msrest.serialization.Model): + """The list of cognitive services accounts operation response. + + :ivar next_link: The link used to get the next page of Model. + :vartype next_link: str + :ivar value: Gets the list of Cognitive Services accounts Model and their properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.AccountModel] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[AccountModel]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["AccountModel"]] = None, + **kwargs + ): + """ + :keyword next_link: The link used to get the next page of Model. + :paramtype next_link: str + :keyword value: Gets the list of Cognitive Services accounts Model and their properties. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.AccountModel] + """ + super(AccountModelListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + class AccountProperties(msrest.serialization.Model): """Properties of Cognitive Services account. @@ -215,45 +382,50 @@ class AccountProperties(msrest.serialization.Model): :vartype capabilities: list[~azure.mgmt.cognitiveservices.models.SkuCapability] :ivar is_migrated: If the resource is migrated from an existing key. :vartype is_migrated: bool - :param migration_token: Resource migration token. - :type migration_token: str + :ivar migration_token: Resource migration token. + :vartype migration_token: str :ivar sku_change_info: Sku change info of account. :vartype sku_change_info: ~azure.mgmt.cognitiveservices.models.SkuChangeInfo - :param custom_sub_domain_name: Optional subdomain name used for token-based authentication. - :type custom_sub_domain_name: str - :param network_acls: A collection of rules governing the accessibility from specific network + :ivar custom_sub_domain_name: Optional subdomain name used for token-based authentication. + :vartype custom_sub_domain_name: str + :ivar network_acls: A collection of rules governing the accessibility from specific network locations. - :type network_acls: ~azure.mgmt.cognitiveservices.models.NetworkRuleSet - :param encryption: The encryption properties for this resource. - :type encryption: ~azure.mgmt.cognitiveservices.models.Encryption - :param user_owned_storage: The storage accounts for this resource. - :type user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] + :vartype network_acls: ~azure.mgmt.cognitiveservices.models.NetworkRuleSet + :ivar encryption: The encryption properties for this resource. + :vartype encryption: ~azure.mgmt.cognitiveservices.models.Encryption + :ivar user_owned_storage: The storage accounts for this resource. + :vartype user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] :ivar private_endpoint_connections: The private endpoint connection associated with the Cognitive Services account. :vartype private_endpoint_connections: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] - :param public_network_access: Whether or not public endpoint access is allowed for this - account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.cognitiveservices.models.PublicNetworkAccess - :param api_properties: The api properties for special APIs. - :type api_properties: ~azure.mgmt.cognitiveservices.models.ApiProperties + :ivar public_network_access: Whether or not public endpoint access is allowed for this account. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.cognitiveservices.models.PublicNetworkAccess + :ivar api_properties: The api properties for special APIs. + :vartype api_properties: ~azure.mgmt.cognitiveservices.models.ApiProperties :ivar date_created: Gets the date of cognitive services account creation. :vartype date_created: str :ivar call_rate_limit: The call rate limit Cognitive Services account. :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit + :ivar dynamic_throttling_enabled: The flag to enable dynamic throttling. + :vartype dynamic_throttling_enabled: bool :ivar quota_limit: :vartype quota_limit: ~azure.mgmt.cognitiveservices.models.QuotaLimit - :param restrict_outbound_network_access: - :type restrict_outbound_network_access: bool - :param allowed_fqdn_list: - :type allowed_fqdn_list: list[str] - :param disable_local_auth: - :type disable_local_auth: bool + :ivar restrict_outbound_network_access: + :vartype restrict_outbound_network_access: bool + :ivar allowed_fqdn_list: + :vartype allowed_fqdn_list: list[str] + :ivar disable_local_auth: + :vartype disable_local_auth: bool :ivar endpoints: Dictionary of :code:``. :vartype endpoints: dict[str, str] - :param restore: - :type restore: bool + :ivar restore: + :vartype restore: bool + :ivar deletion_date: The deletion date, only available for deleted account. + :vartype deletion_date: str + :ivar scheduled_purge_date: The scheduled purge date, only available for deleted account. + :vartype scheduled_purge_date: str """ _validation = { @@ -268,6 +440,8 @@ class AccountProperties(msrest.serialization.Model): 'call_rate_limit': {'readonly': True}, 'quota_limit': {'readonly': True}, 'endpoints': {'readonly': True}, + 'deletion_date': {'readonly': True}, + 'scheduled_purge_date': {'readonly': True}, } _attribute_map = { @@ -287,12 +461,15 @@ class AccountProperties(msrest.serialization.Model): 'api_properties': {'key': 'apiProperties', 'type': 'ApiProperties'}, 'date_created': {'key': 'dateCreated', 'type': 'str'}, 'call_rate_limit': {'key': 'callRateLimit', 'type': 'CallRateLimit'}, + 'dynamic_throttling_enabled': {'key': 'dynamicThrottlingEnabled', 'type': 'bool'}, 'quota_limit': {'key': 'quotaLimit', 'type': 'QuotaLimit'}, 'restrict_outbound_network_access': {'key': 'restrictOutboundNetworkAccess', 'type': 'bool'}, 'allowed_fqdn_list': {'key': 'allowedFqdnList', 'type': '[str]'}, 'disable_local_auth': {'key': 'disableLocalAuth', 'type': 'bool'}, 'endpoints': {'key': 'endpoints', 'type': '{str}'}, 'restore': {'key': 'restore', 'type': 'bool'}, + 'deletion_date': {'key': 'deletionDate', 'type': 'str'}, + 'scheduled_purge_date': {'key': 'scheduledPurgeDate', 'type': 'str'}, } def __init__( @@ -305,12 +482,42 @@ def __init__( user_owned_storage: Optional[List["UserOwnedStorage"]] = None, public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, api_properties: Optional["ApiProperties"] = None, + dynamic_throttling_enabled: Optional[bool] = None, restrict_outbound_network_access: Optional[bool] = None, allowed_fqdn_list: Optional[List[str]] = None, disable_local_auth: Optional[bool] = None, restore: Optional[bool] = None, **kwargs ): + """ + :keyword migration_token: Resource migration token. + :paramtype migration_token: str + :keyword custom_sub_domain_name: Optional subdomain name used for token-based authentication. + :paramtype custom_sub_domain_name: str + :keyword network_acls: A collection of rules governing the accessibility from specific network + locations. + :paramtype network_acls: ~azure.mgmt.cognitiveservices.models.NetworkRuleSet + :keyword encryption: The encryption properties for this resource. + :paramtype encryption: ~azure.mgmt.cognitiveservices.models.Encryption + :keyword user_owned_storage: The storage accounts for this resource. + :paramtype user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] + :keyword public_network_access: Whether or not public endpoint access is allowed for this + account. Possible values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.cognitiveservices.models.PublicNetworkAccess + :keyword api_properties: The api properties for special APIs. + :paramtype api_properties: ~azure.mgmt.cognitiveservices.models.ApiProperties + :keyword dynamic_throttling_enabled: The flag to enable dynamic throttling. + :paramtype dynamic_throttling_enabled: bool + :keyword restrict_outbound_network_access: + :paramtype restrict_outbound_network_access: bool + :keyword allowed_fqdn_list: + :paramtype allowed_fqdn_list: list[str] + :keyword disable_local_auth: + :paramtype disable_local_auth: bool + :keyword restore: + :paramtype restore: bool + """ super(AccountProperties, self).__init__(**kwargs) self.provisioning_state = None self.endpoint = None @@ -328,21 +535,24 @@ def __init__( self.api_properties = api_properties self.date_created = None self.call_rate_limit = None + self.dynamic_throttling_enabled = dynamic_throttling_enabled self.quota_limit = None self.restrict_outbound_network_access = restrict_outbound_network_access self.allowed_fqdn_list = allowed_fqdn_list self.disable_local_auth = disable_local_auth self.endpoints = None self.restore = restore + self.deletion_date = None + self.scheduled_purge_date = None class AccountSku(msrest.serialization.Model): """Cognitive Services resource type and SKU. - :param resource_type: Resource Namespace and Type. - :type resource_type: str - :param sku: The SKU of Cognitive Services account. - :type sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar resource_type: Resource Namespace and Type. + :vartype resource_type: str + :ivar sku: The SKU of Cognitive Services account. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku """ _attribute_map = { @@ -357,6 +567,12 @@ def __init__( sku: Optional["Sku"] = None, **kwargs ): + """ + :keyword resource_type: Resource Namespace and Type. + :paramtype resource_type: str + :keyword sku: The SKU of Cognitive Services account. + :paramtype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ super(AccountSku, self).__init__(**kwargs) self.resource_type = resource_type self.sku = sku @@ -365,8 +581,8 @@ def __init__( class AccountSkuListResult(msrest.serialization.Model): """The list of cognitive services accounts operation response. - :param value: Gets the list of Cognitive Services accounts and their properties. - :type value: list[~azure.mgmt.cognitiveservices.models.AccountSku] + :ivar value: Gets the list of Cognitive Services accounts and their properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.AccountSku] """ _attribute_map = { @@ -379,6 +595,10 @@ def __init__( value: Optional[List["AccountSku"]] = None, **kwargs ): + """ + :keyword value: Gets the list of Cognitive Services accounts and their properties. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.AccountSku] + """ super(AccountSkuListResult, self).__init__(**kwargs) self.value = value @@ -386,10 +606,10 @@ def __init__( class ApiKeys(msrest.serialization.Model): """The access keys for the cognitive services account. - :param key1: Gets the value of key 1. - :type key1: str - :param key2: Gets the value of key 2. - :type key2: str + :ivar key1: Gets the value of key 1. + :vartype key1: str + :ivar key2: Gets the value of key 2. + :vartype key2: str """ _attribute_map = { @@ -404,6 +624,12 @@ def __init__( key2: Optional[str] = None, **kwargs ): + """ + :keyword key1: Gets the value of key 1. + :paramtype key1: str + :keyword key2: Gets the value of key 2. + :paramtype key2: str + """ super(ApiKeys, self).__init__(**kwargs) self.key1 = key1 self.key2 = key2 @@ -412,32 +638,31 @@ def __init__( class ApiProperties(msrest.serialization.Model): """The api properties for special APIs. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. - :type qna_runtime_endpoint: str - :param qna_azure_search_endpoint_key: (QnAMaker Only) The Azure Search endpoint key of - QnAMaker. - :type qna_azure_search_endpoint_key: str - :param qna_azure_search_endpoint_id: (QnAMaker Only) The Azure Search endpoint id of QnAMaker. - :type qna_azure_search_endpoint_id: str - :param statistics_enabled: (Bing Search Only) The flag to enable statistics of Bing Search. - :type statistics_enabled: bool - :param event_hub_connection_string: (Personalization Only) The flag to enable statistics of - Bing Search. - :type event_hub_connection_string: str - :param storage_account_connection_string: (Personalization Only) The storage account connection + :vartype additional_properties: dict[str, any] + :ivar qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. + :vartype qna_runtime_endpoint: str + :ivar qna_azure_search_endpoint_key: (QnAMaker Only) The Azure Search endpoint key of QnAMaker. + :vartype qna_azure_search_endpoint_key: str + :ivar qna_azure_search_endpoint_id: (QnAMaker Only) The Azure Search endpoint id of QnAMaker. + :vartype qna_azure_search_endpoint_id: str + :ivar statistics_enabled: (Bing Search Only) The flag to enable statistics of Bing Search. + :vartype statistics_enabled: bool + :ivar event_hub_connection_string: (Personalization Only) The flag to enable statistics of Bing + Search. + :vartype event_hub_connection_string: str + :ivar storage_account_connection_string: (Personalization Only) The storage account connection string. - :type storage_account_connection_string: str - :param aad_client_id: (Metrics Advisor Only) The Azure AD Client Id (Application Id). - :type aad_client_id: str - :param aad_tenant_id: (Metrics Advisor Only) The Azure AD Tenant Id. - :type aad_tenant_id: str - :param super_user: (Metrics Advisor Only) The super user of Metrics Advisor. - :type super_user: str - :param website_name: (Metrics Advisor Only) The website name of Metrics Advisor. - :type website_name: str + :vartype storage_account_connection_string: str + :ivar aad_client_id: (Metrics Advisor Only) The Azure AD Client Id (Application Id). + :vartype aad_client_id: str + :ivar aad_tenant_id: (Metrics Advisor Only) The Azure AD Tenant Id. + :vartype aad_tenant_id: str + :ivar super_user: (Metrics Advisor Only) The super user of Metrics Advisor. + :vartype super_user: str + :ivar website_name: (Metrics Advisor Only) The website name of Metrics Advisor. + :vartype website_name: str """ _validation = { @@ -479,6 +704,35 @@ def __init__( website_name: Optional[str] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. + :paramtype qna_runtime_endpoint: str + :keyword qna_azure_search_endpoint_key: (QnAMaker Only) The Azure Search endpoint key of + QnAMaker. + :paramtype qna_azure_search_endpoint_key: str + :keyword qna_azure_search_endpoint_id: (QnAMaker Only) The Azure Search endpoint id of + QnAMaker. + :paramtype qna_azure_search_endpoint_id: str + :keyword statistics_enabled: (Bing Search Only) The flag to enable statistics of Bing Search. + :paramtype statistics_enabled: bool + :keyword event_hub_connection_string: (Personalization Only) The flag to enable statistics of + Bing Search. + :paramtype event_hub_connection_string: str + :keyword storage_account_connection_string: (Personalization Only) The storage account + connection string. + :paramtype storage_account_connection_string: str + :keyword aad_client_id: (Metrics Advisor Only) The Azure AD Client Id (Application Id). + :paramtype aad_client_id: str + :keyword aad_tenant_id: (Metrics Advisor Only) The Azure AD Tenant Id. + :paramtype aad_tenant_id: str + :keyword super_user: (Metrics Advisor Only) The super user of Metrics Advisor. + :paramtype super_user: str + :keyword website_name: (Metrics Advisor Only) The website name of Metrics Advisor. + :paramtype website_name: str + """ super(ApiProperties, self).__init__(**kwargs) self.additional_properties = additional_properties self.qna_runtime_endpoint = qna_runtime_endpoint @@ -496,12 +750,12 @@ def __init__( class CallRateLimit(msrest.serialization.Model): """The call rate limit Cognitive Services account. - :param count: The count value of Call Rate Limit. - :type count: float - :param renewal_period: The renewal period in seconds of Call Rate Limit. - :type renewal_period: float - :param rules: - :type rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + :ivar count: The count value of Call Rate Limit. + :vartype count: float + :ivar renewal_period: The renewal period in seconds of Call Rate Limit. + :vartype renewal_period: float + :ivar rules: + :vartype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] """ _attribute_map = { @@ -518,6 +772,14 @@ def __init__( rules: Optional[List["ThrottlingRule"]] = None, **kwargs ): + """ + :keyword count: The count value of Call Rate Limit. + :paramtype count: float + :keyword renewal_period: The renewal period in seconds of Call Rate Limit. + :paramtype renewal_period: float + :keyword rules: + :paramtype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + """ super(CallRateLimit, self).__init__(**kwargs) self.count = count self.renewal_period = renewal_period @@ -529,12 +791,12 @@ class CheckDomainAvailabilityParameter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param subdomain_name: Required. The subdomain name to use. - :type subdomain_name: str - :param type: Required. The Type of the resource. - :type type: str - :param kind: The Kind of the resource. - :type kind: str + :ivar subdomain_name: Required. The subdomain name to use. + :vartype subdomain_name: str + :ivar type: Required. The Type of the resource. + :vartype type: str + :ivar kind: The Kind of the resource. + :vartype kind: str """ _validation = { @@ -556,6 +818,14 @@ def __init__( kind: Optional[str] = None, **kwargs ): + """ + :keyword subdomain_name: Required. The subdomain name to use. + :paramtype subdomain_name: str + :keyword type: Required. The Type of the resource. + :paramtype type: str + :keyword kind: The Kind of the resource. + :paramtype kind: str + """ super(CheckDomainAvailabilityParameter, self).__init__(**kwargs) self.subdomain_name = subdomain_name self.type = type @@ -567,12 +837,12 @@ class CheckSkuAvailabilityParameter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param skus: Required. The SKU of the resource. - :type skus: list[str] - :param kind: Required. The Kind of the resource. - :type kind: str - :param type: Required. The Type of the resource. - :type type: str + :ivar skus: Required. The SKU of the resource. + :vartype skus: list[str] + :ivar kind: Required. The Kind of the resource. + :vartype kind: str + :ivar type: Required. The Type of the resource. + :vartype type: str """ _validation = { @@ -595,6 +865,14 @@ def __init__( type: str, **kwargs ): + """ + :keyword skus: Required. The SKU of the resource. + :paramtype skus: list[str] + :keyword kind: Required. The Kind of the resource. + :paramtype kind: str + :keyword type: Required. The Type of the resource. + :paramtype type: str + """ super(CheckSkuAvailabilityParameter, self).__init__(**kwargs) self.skus = skus self.kind = kind @@ -604,10 +882,10 @@ def __init__( class CommitmentCost(msrest.serialization.Model): """Cognitive Services account commitment cost. - :param commitment_meter_id: Commitment meter Id. - :type commitment_meter_id: str - :param overage_meter_id: Overage meter Id. - :type overage_meter_id: str + :ivar commitment_meter_id: Commitment meter Id. + :vartype commitment_meter_id: str + :ivar overage_meter_id: Overage meter Id. + :vartype overage_meter_id: str """ _attribute_map = { @@ -622,6 +900,12 @@ def __init__( overage_meter_id: Optional[str] = None, **kwargs ): + """ + :keyword commitment_meter_id: Commitment meter Id. + :paramtype commitment_meter_id: str + :keyword overage_meter_id: Overage meter Id. + :paramtype overage_meter_id: str + """ super(CommitmentCost, self).__init__(**kwargs) self.commitment_meter_id = commitment_meter_id self.overage_meter_id = overage_meter_id @@ -632,10 +916,10 @@ class CommitmentPeriod(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tier: Commitment period commitment tier. - :type tier: str - :param count: Commitment period commitment count. - :type count: int + :ivar tier: Commitment period commitment tier. + :vartype tier: str + :ivar count: Commitment period commitment count. + :vartype count: int :ivar quota: Cognitive Services account commitment quota. :vartype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota :ivar start_date: Commitment period start date. @@ -665,6 +949,12 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword tier: Commitment period commitment tier. + :paramtype tier: str + :keyword count: Commitment period commitment count. + :paramtype count: int + """ super(CommitmentPeriod, self).__init__(**kwargs) self.tier = tier self.count = count @@ -704,6 +994,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -724,8 +1016,8 @@ class CommitmentPlan(ProxyResource): :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData :ivar etag: Resource Etag. :vartype etag: str - :param properties: Properties of Cognitive Services account commitment plan. - :type properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties + :ivar properties: Properties of Cognitive Services account commitment plan. + :vartype properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties """ _validation = { @@ -751,6 +1043,10 @@ def __init__( properties: Optional["CommitmentPlanProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of Cognitive Services account commitment plan. + :paramtype properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties + """ super(CommitmentPlan, self).__init__(**kwargs) self.system_data = None self.etag = None @@ -762,8 +1058,8 @@ class CommitmentPlanListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param next_link: The link used to get the next page of CommitmentPlan. - :type next_link: str + :ivar next_link: The link used to get the next page of CommitmentPlan. + :vartype next_link: str :ivar value: Gets the list of Cognitive Services accounts CommitmentPlan and their properties. :vartype value: list[~azure.mgmt.cognitiveservices.models.CommitmentPlan] """ @@ -783,6 +1079,10 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of CommitmentPlan. + :paramtype next_link: str + """ super(CommitmentPlanListResult, self).__init__(**kwargs) self.next_link = next_link self.value = None @@ -793,17 +1093,17 @@ class CommitmentPlanProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param hosting_model: Account hosting model. Possible values include: "Web", + :ivar hosting_model: Account hosting model. Possible values include: "Web", "ConnectedContainer", "DisconnectedContainer". - :type hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel - :param plan_type: Commitment plan type. - :type plan_type: str - :param current: Cognitive Services account commitment period. - :type current: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod - :param auto_renew: AutoRenew commitment plan. - :type auto_renew: bool - :param next: Cognitive Services account commitment period. - :type next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :vartype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :ivar plan_type: Commitment plan type. + :vartype plan_type: str + :ivar current: Cognitive Services account commitment period. + :vartype current: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :ivar auto_renew: AutoRenew commitment plan. + :vartype auto_renew: bool + :ivar next: Cognitive Services account commitment period. + :vartype next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod :ivar last: Cognitive Services account commitment period. :vartype last: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod """ @@ -831,6 +1131,19 @@ def __init__( next: Optional["CommitmentPeriod"] = None, **kwargs ): + """ + :keyword hosting_model: Account hosting model. Possible values include: "Web", + "ConnectedContainer", "DisconnectedContainer". + :paramtype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :keyword plan_type: Commitment plan type. + :paramtype plan_type: str + :keyword current: Cognitive Services account commitment period. + :paramtype current: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :keyword auto_renew: AutoRenew commitment plan. + :paramtype auto_renew: bool + :keyword next: Cognitive Services account commitment period. + :paramtype next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + """ super(CommitmentPlanProperties, self).__init__(**kwargs) self.hosting_model = hosting_model self.plan_type = plan_type @@ -843,10 +1156,10 @@ def __init__( class CommitmentQuota(msrest.serialization.Model): """Cognitive Services account commitment quota. - :param quantity: Commitment quota quantity. - :type quantity: long - :param unit: Commitment quota unit. - :type unit: str + :ivar quantity: Commitment quota quantity. + :vartype quantity: long + :ivar unit: Commitment quota unit. + :vartype unit: str """ _attribute_map = { @@ -861,6 +1174,12 @@ def __init__( unit: Optional[str] = None, **kwargs ): + """ + :keyword quantity: Commitment quota quantity. + :paramtype quantity: long + :keyword unit: Commitment quota unit. + :paramtype unit: str + """ super(CommitmentQuota, self).__init__(**kwargs) self.quantity = quantity self.unit = unit @@ -869,23 +1188,23 @@ def __init__( class CommitmentTier(msrest.serialization.Model): """Cognitive Services account commitment tier. - :param kind: The Kind of the resource. - :type kind: str - :param sku_name: The name of the SKU. Ex - P3. It is typically a letter+number code. - :type sku_name: str - :param hosting_model: Account hosting model. Possible values include: "Web", + :ivar kind: The Kind of the resource. + :vartype kind: str + :ivar sku_name: The name of the SKU. Ex - P3. It is typically a letter+number code. + :vartype sku_name: str + :ivar hosting_model: Account hosting model. Possible values include: "Web", "ConnectedContainer", "DisconnectedContainer". - :type hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel - :param plan_type: Commitment plan type. - :type plan_type: str - :param tier: Commitment period commitment tier. - :type tier: str - :param max_count: Commitment period commitment max count. - :type max_count: int - :param quota: Cognitive Services account commitment quota. - :type quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota - :param cost: Cognitive Services account commitment cost. - :type cost: ~azure.mgmt.cognitiveservices.models.CommitmentCost + :vartype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :ivar plan_type: Commitment plan type. + :vartype plan_type: str + :ivar tier: Commitment period commitment tier. + :vartype tier: str + :ivar max_count: Commitment period commitment max count. + :vartype max_count: int + :ivar quota: Cognitive Services account commitment quota. + :vartype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota + :ivar cost: Cognitive Services account commitment cost. + :vartype cost: ~azure.mgmt.cognitiveservices.models.CommitmentCost """ _attribute_map = { @@ -912,6 +1231,25 @@ def __init__( cost: Optional["CommitmentCost"] = None, **kwargs ): + """ + :keyword kind: The Kind of the resource. + :paramtype kind: str + :keyword sku_name: The name of the SKU. Ex - P3. It is typically a letter+number code. + :paramtype sku_name: str + :keyword hosting_model: Account hosting model. Possible values include: "Web", + "ConnectedContainer", "DisconnectedContainer". + :paramtype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :keyword plan_type: Commitment plan type. + :paramtype plan_type: str + :keyword tier: Commitment period commitment tier. + :paramtype tier: str + :keyword max_count: Commitment period commitment max count. + :paramtype max_count: int + :keyword quota: Cognitive Services account commitment quota. + :paramtype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota + :keyword cost: Cognitive Services account commitment cost. + :paramtype cost: ~azure.mgmt.cognitiveservices.models.CommitmentCost + """ super(CommitmentTier, self).__init__(**kwargs) self.kind = kind self.sku_name = sku_name @@ -928,8 +1266,8 @@ class CommitmentTierListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param next_link: The link used to get the next page of CommitmentTier. - :type next_link: str + :ivar next_link: The link used to get the next page of CommitmentTier. + :vartype next_link: str :ivar value: Gets the list of Cognitive Services accounts CommitmentTier and their properties. :vartype value: list[~azure.mgmt.cognitiveservices.models.CommitmentTier] """ @@ -949,6 +1287,10 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of CommitmentTier. + :paramtype next_link: str + """ super(CommitmentTierListResult, self).__init__(**kwargs) self.next_link = next_link self.value = None @@ -971,8 +1313,8 @@ class Deployment(ProxyResource): :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData :ivar etag: Resource Etag. :vartype etag: str - :param properties: Properties of Cognitive Services account deployment. - :type properties: ~azure.mgmt.cognitiveservices.models.DeploymentProperties + :ivar properties: Properties of Cognitive Services account deployment. + :vartype properties: ~azure.mgmt.cognitiveservices.models.DeploymentProperties """ _validation = { @@ -998,6 +1340,10 @@ def __init__( properties: Optional["DeploymentProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of Cognitive Services account deployment. + :paramtype properties: ~azure.mgmt.cognitiveservices.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.system_data = None self.etag = None @@ -1009,8 +1355,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param next_link: The link used to get the next page of Deployment. - :type next_link: str + :ivar next_link: The link used to get the next page of Deployment. + :vartype next_link: str :ivar value: Gets the list of Cognitive Services accounts Deployment and their properties. :vartype value: list[~azure.mgmt.cognitiveservices.models.Deployment] """ @@ -1030,42 +1376,15 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of Deployment. + :paramtype next_link: str + """ super(DeploymentListResult, self).__init__(**kwargs) self.next_link = next_link self.value = None -class DeploymentModel(msrest.serialization.Model): - """Properties of Cognitive Services account deployment model. - - :param format: Deployment model format. - :type format: str - :param name: Deployment model name. - :type name: str - :param version: Deployment model version. - :type version: str - """ - - _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - *, - format: Optional[str] = None, - name: Optional[str] = None, - version: Optional[str] = None, - **kwargs - ): - super(DeploymentModel, self).__init__(**kwargs) - self.format = format - self.name = name - self.version = version - - class DeploymentProperties(msrest.serialization.Model): """Properties of Cognitive Services account deployment. @@ -1075,10 +1394,10 @@ class DeploymentProperties(msrest.serialization.Model): Possible values include: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.cognitiveservices.models.DeploymentProvisioningState - :param model: Properties of Cognitive Services account deployment model. - :type model: ~azure.mgmt.cognitiveservices.models.DeploymentModel - :param scale_settings: Properties of Cognitive Services account deployment model. - :type scale_settings: ~azure.mgmt.cognitiveservices.models.DeploymentScaleSettings + :ivar model: Properties of Cognitive Services account deployment model. + :vartype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar scale_settings: Properties of Cognitive Services account deployment model. + :vartype scale_settings: ~azure.mgmt.cognitiveservices.models.DeploymentScaleSettings """ _validation = { @@ -1098,6 +1417,12 @@ def __init__( scale_settings: Optional["DeploymentScaleSettings"] = None, **kwargs ): + """ + :keyword model: Properties of Cognitive Services account deployment model. + :paramtype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :keyword scale_settings: Properties of Cognitive Services account deployment model. + :paramtype scale_settings: ~azure.mgmt.cognitiveservices.models.DeploymentScaleSettings + """ super(DeploymentProperties, self).__init__(**kwargs) self.provisioning_state = None self.model = model @@ -1107,15 +1432,25 @@ def __init__( class DeploymentScaleSettings(msrest.serialization.Model): """Properties of Cognitive Services account deployment model. - :param scale_type: Deployment scale type. Possible values include: "Manual". - :type scale_type: str or ~azure.mgmt.cognitiveservices.models.DeploymentScaleType - :param capacity: Deployment capacity. - :type capacity: int + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar scale_type: Deployment scale type. Possible values include: "Manual". + :vartype scale_type: str or ~azure.mgmt.cognitiveservices.models.DeploymentScaleType + :ivar capacity: Deployment capacity. + :vartype capacity: int + :ivar active_capacity: Deployment active capacity. This value might be different from + ``capacity`` if customer recently updated ``capacity``. + :vartype active_capacity: int """ + _validation = { + 'active_capacity': {'readonly': True}, + } + _attribute_map = { 'scale_type': {'key': 'scaleType', 'type': 'str'}, 'capacity': {'key': 'capacity', 'type': 'int'}, + 'active_capacity': {'key': 'activeCapacity', 'type': 'int'}, } def __init__( @@ -1125,24 +1460,31 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword scale_type: Deployment scale type. Possible values include: "Manual". + :paramtype scale_type: str or ~azure.mgmt.cognitiveservices.models.DeploymentScaleType + :keyword capacity: Deployment capacity. + :paramtype capacity: int + """ super(DeploymentScaleSettings, self).__init__(**kwargs) self.scale_type = scale_type self.capacity = capacity + self.active_capacity = None class DomainAvailability(msrest.serialization.Model): """Domain availability. - :param is_subdomain_available: Indicates the given SKU is available or not. - :type is_subdomain_available: bool - :param reason: Reason why the SKU is not available. - :type reason: str - :param subdomain_name: The subdomain name to use. - :type subdomain_name: str - :param type: The Type of the resource. - :type type: str - :param kind: The Kind of the resource. - :type kind: str + :ivar is_subdomain_available: Indicates the given SKU is available or not. + :vartype is_subdomain_available: bool + :ivar reason: Reason why the SKU is not available. + :vartype reason: str + :ivar subdomain_name: The subdomain name to use. + :vartype subdomain_name: str + :ivar type: The Type of the resource. + :vartype type: str + :ivar kind: The Kind of the resource. + :vartype kind: str """ _attribute_map = { @@ -1163,6 +1505,18 @@ def __init__( kind: Optional[str] = None, **kwargs ): + """ + :keyword is_subdomain_available: Indicates the given SKU is available or not. + :paramtype is_subdomain_available: bool + :keyword reason: Reason why the SKU is not available. + :paramtype reason: str + :keyword subdomain_name: The subdomain name to use. + :paramtype subdomain_name: str + :keyword type: The Type of the resource. + :paramtype type: str + :keyword kind: The Kind of the resource. + :paramtype kind: str + """ super(DomainAvailability, self).__init__(**kwargs) self.is_subdomain_available = is_subdomain_available self.reason = reason @@ -1174,12 +1528,12 @@ def __init__( class Encryption(msrest.serialization.Model): """Properties to configure Encryption. - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties - :param key_source: Enumerates the possible value of keySource for Encryption. Possible values + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties + :ivar key_source: Enumerates the possible value of keySource for Encryption. Possible values include: "Microsoft.CognitiveServices", "Microsoft.KeyVault". Default value: "Microsoft.KeyVault". - :type key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource + :vartype key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource """ _attribute_map = { @@ -1194,6 +1548,14 @@ def __init__( key_source: Optional[Union[str, "KeySource"]] = "Microsoft.KeyVault", **kwargs ): + """ + :keyword key_vault_properties: Properties of KeyVault. + :paramtype key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties + :keyword key_source: Enumerates the possible value of keySource for Encryption. Possible values + include: "Microsoft.CognitiveServices", "Microsoft.KeyVault". Default value: + "Microsoft.KeyVault". + :paramtype key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource + """ super(Encryption, self).__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source @@ -1224,6 +1586,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1266,6 +1630,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -1277,8 +1643,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.cognitiveservices.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.cognitiveservices.models.ErrorDetail """ _attribute_map = { @@ -1291,6 +1657,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.cognitiveservices.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -1300,17 +1670,17 @@ class Identity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: The identity type. Possible values include: "None", "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned". - :type type: str or ~azure.mgmt.cognitiveservices.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.cognitiveservices.models.ResourceIdentityType :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str - :param user_assigned_identities: The list of user assigned identities associated with the + :ivar user_assigned_identities: The list of user assigned identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.cognitiveservices.models.UserAssignedIdentity] """ @@ -1333,6 +1703,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned". + :paramtype type: str or ~azure.mgmt.cognitiveservices.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user assigned identities associated with the + resource. The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.cognitiveservices.models.UserAssignedIdentity] + """ super(Identity, self).__init__(**kwargs) self.type = type self.tenant_id = None @@ -1345,9 +1725,9 @@ class IpRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple + :ivar value: Required. An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) or '124.56.78.0/24' (all addresses that start with 124.56.78). - :type value: str + :vartype value: str """ _validation = { @@ -1364,6 +1744,11 @@ def __init__( value: str, **kwargs ): + """ + :keyword value: Required. An IPv4 address range in CIDR notation, such as '124.56.78.91' + (simple IP address) or '124.56.78.0/24' (all addresses that start with 124.56.78). + :paramtype value: str + """ super(IpRule, self).__init__(**kwargs) self.value = value @@ -1371,14 +1756,14 @@ def __init__( class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_version: Version of the Key from KeyVault. - :type key_version: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param identity_client_id: - :type identity_client_id: str + :ivar key_name: Name of the Key from KeyVault. + :vartype key_name: str + :ivar key_version: Version of the Key from KeyVault. + :vartype key_version: str + :ivar key_vault_uri: Uri of KeyVault. + :vartype key_vault_uri: str + :ivar identity_client_id: + :vartype identity_client_id: str """ _attribute_map = { @@ -1397,6 +1782,16 @@ def __init__( identity_client_id: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Name of the Key from KeyVault. + :paramtype key_name: str + :keyword key_version: Version of the Key from KeyVault. + :paramtype key_version: str + :keyword key_vault_uri: Uri of KeyVault. + :paramtype key_vault_uri: str + :keyword identity_client_id: + :paramtype identity_client_id: str + """ super(KeyVaultProperties, self).__init__(**kwargs) self.key_name = key_name self.key_version = key_version @@ -1407,10 +1802,10 @@ def __init__( class MetricName(msrest.serialization.Model): """A metric name. - :param value: The name of the metric. - :type value: str - :param localized_value: The friendly name of the metric. - :type localized_value: str + :ivar value: The name of the metric. + :vartype value: str + :ivar localized_value: The friendly name of the metric. + :vartype localized_value: str """ _attribute_map = { @@ -1425,22 +1820,60 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: The name of the metric. + :paramtype value: str + :keyword localized_value: The friendly name of the metric. + :paramtype localized_value: str + """ super(MetricName, self).__init__(**kwargs) self.value = value self.localized_value = localized_value +class ModelDeprecationInfo(msrest.serialization.Model): + """Cognitive Services account ModelDeprecationInfo. + + :ivar fine_tune: The datetime of deprecation of the fineTune Model. + :vartype fine_tune: str + :ivar inference: The datetime of deprecation of the inference Model. + :vartype inference: str + """ + + _attribute_map = { + 'fine_tune': {'key': 'fineTune', 'type': 'str'}, + 'inference': {'key': 'inference', 'type': 'str'}, + } + + def __init__( + self, + *, + fine_tune: Optional[str] = None, + inference: Optional[str] = None, + **kwargs + ): + """ + :keyword fine_tune: The datetime of deprecation of the fineTune Model. + :paramtype fine_tune: str + :keyword inference: The datetime of deprecation of the inference Model. + :paramtype inference: str + """ + super(ModelDeprecationInfo, self).__init__(**kwargs) + self.fine_tune = fine_tune + self.inference = inference + + class NetworkRuleSet(msrest.serialization.Model): """A set of rules governing the network accessibility. - :param default_action: The default action when no rule from ipRules and from - virtualNetworkRules match. This is only used after the bypass property has been evaluated. - Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.cognitiveservices.models.NetworkRuleAction - :param ip_rules: The list of IP address rules. - :type ip_rules: list[~azure.mgmt.cognitiveservices.models.IpRule] - :param virtual_network_rules: The list of virtual network rules. - :type virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] + :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules + match. This is only used after the bypass property has been evaluated. Possible values include: + "Allow", "Deny". + :vartype default_action: str or ~azure.mgmt.cognitiveservices.models.NetworkRuleAction + :ivar ip_rules: The list of IP address rules. + :vartype ip_rules: list[~azure.mgmt.cognitiveservices.models.IpRule] + :ivar virtual_network_rules: The list of virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] """ _attribute_map = { @@ -1457,6 +1890,16 @@ def __init__( virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, **kwargs ): + """ + :keyword default_action: The default action when no rule from ipRules and from + virtualNetworkRules match. This is only used after the bypass property has been evaluated. + Possible values include: "Allow", "Deny". + :paramtype default_action: str or ~azure.mgmt.cognitiveservices.models.NetworkRuleAction + :keyword ip_rules: The list of IP address rules. + :paramtype ip_rules: list[~azure.mgmt.cognitiveservices.models.IpRule] + :keyword virtual_network_rules: The list of virtual network rules. + :paramtype virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] + """ super(NetworkRuleSet, self).__init__(**kwargs) self.default_action = default_action self.ip_rules = ip_rules @@ -1474,8 +1917,8 @@ class Operation(msrest.serialization.Model): :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. :vartype is_data_action: bool - :param display: Localized display information for this particular operation. - :type display: ~azure.mgmt.cognitiveservices.models.OperationDisplay + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.cognitiveservices.models.OperationDisplay :ivar origin: The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", "system", "user,system". @@ -1506,6 +1949,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.cognitiveservices.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.is_data_action = None @@ -1551,6 +1998,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1583,6 +2032,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1609,6 +2060,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -1628,12 +2081,12 @@ class PrivateEndpointConnection(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :param properties: Resource properties. - :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData - :param location: The location of the private endpoint connection. - :type location: str + :ivar location: The location of the private endpoint connection. + :vartype location: str """ _validation = { @@ -1661,6 +2114,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword properties: Resource properties. + :paramtype properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties + :keyword location: The location of the private endpoint connection. + :paramtype location: str + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.properties = properties self.system_data = None @@ -1670,8 +2129,8 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """A list of private endpoint connections. - :param value: Array of private endpoint connections. - :type value: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] """ _attribute_map = { @@ -1684,6 +2143,10 @@ def __init__( value: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value @@ -1695,18 +2158,18 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param private_endpoint: The resource of private end point. - :type private_endpoint: ~azure.mgmt.cognitiveservices.models.PrivateEndpoint - :param private_link_service_connection_state: Required. A collection of information about the + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.cognitiveservices.models.PrivateEndpoint + :ivar private_link_service_connection_state: Required. A collection of information about the state of the connection between service consumer and provider. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. Possible values include: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProvisioningState - :param group_ids: The private link resource group ids. - :type group_ids: list[str] + :ivar group_ids: The private link resource group ids. + :vartype group_ids: list[str] """ _validation = { @@ -1729,6 +2192,16 @@ def __init__( group_ids: Optional[List[str]] = None, **kwargs ): + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.cognitiveservices.models.PrivateEndpoint + :keyword private_link_service_connection_state: Required. A collection of information about the + state of the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState + :keyword group_ids: The private link resource group ids. + :paramtype group_ids: list[str] + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -1749,8 +2222,8 @@ class PrivateLinkResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Resource properties. - :type properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties """ _validation = { @@ -1772,6 +2245,10 @@ def __init__( properties: Optional["PrivateLinkResourceProperties"] = None, **kwargs ): + """ + :keyword properties: Resource properties. + :paramtype properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties + """ super(PrivateLinkResource, self).__init__(**kwargs) self.properties = properties @@ -1779,8 +2256,8 @@ def __init__( class PrivateLinkResourceListResult(msrest.serialization.Model): """A list of private link resources. - :param value: Array of private link resources. - :type value: list[~azure.mgmt.cognitiveservices.models.PrivateLinkResource] + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.cognitiveservices.models.PrivateLinkResource] """ _attribute_map = { @@ -1793,6 +2270,10 @@ def __init__( value: Optional[List["PrivateLinkResource"]] = None, **kwargs ): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.PrivateLinkResource] + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = value @@ -1806,8 +2287,8 @@ class PrivateLinkResourceProperties(msrest.serialization.Model): :vartype group_id: str :ivar required_members: The private link resource required member names. :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] :ivar display_name: The private link resource display name. :vartype display_name: str """ @@ -1831,6 +2312,10 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ super(PrivateLinkResourceProperties, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -1841,15 +2326,15 @@ def __init__( class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. - :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: "Pending", "Approved", "Rejected". - :type status: str or + :vartype status: str or ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus - :param description: The reason for approval/rejection of the connection. - :type description: str - :param actions_required: A message indicating if changes on the service provider require any + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any updates on the consumer. - :type actions_required: str + :vartype actions_required: str """ _attribute_map = { @@ -1866,6 +2351,17 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Possible values include: "Pending", "Approved", "Rejected". + :paramtype status: str or + ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -1875,12 +2371,12 @@ def __init__( class QuotaLimit(msrest.serialization.Model): """QuotaLimit. - :param count: - :type count: float - :param renewal_period: - :type renewal_period: float - :param rules: - :type rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + :ivar count: + :vartype count: float + :ivar renewal_period: + :vartype renewal_period: float + :ivar rules: + :vartype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] """ _attribute_map = { @@ -1897,6 +2393,14 @@ def __init__( rules: Optional[List["ThrottlingRule"]] = None, **kwargs ): + """ + :keyword count: + :paramtype count: float + :keyword renewal_period: + :paramtype renewal_period: float + :keyword rules: + :paramtype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + """ super(QuotaLimit, self).__init__(**kwargs) self.count = count self.renewal_period = renewal_period @@ -1908,9 +2412,9 @@ class RegenerateKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. key name to generate (Key1|Key2). Possible values include: "Key1", + :ivar key_name: Required. key name to generate (Key1|Key2). Possible values include: "Key1", "Key2". - :type key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName + :vartype key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName """ _validation = { @@ -1927,6 +2431,11 @@ def __init__( key_name: Union[str, "KeyName"], **kwargs ): + """ + :keyword key_name: Required. key name to generate (Key1|Key2). Possible values include: "Key1", + "Key2". + :paramtype key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName + """ super(RegenerateKeyParameters, self).__init__(**kwargs) self.key_name = key_name @@ -1934,10 +2443,10 @@ def __init__( class RequestMatchPattern(msrest.serialization.Model): """RequestMatchPattern. - :param path: - :type path: str - :param method: - :type method: str + :ivar path: + :vartype path: str + :ivar method: + :vartype method: str """ _attribute_map = { @@ -1952,6 +2461,12 @@ def __init__( method: Optional[str] = None, **kwargs ): + """ + :keyword path: + :paramtype path: str + :keyword method: + :paramtype method: str + """ super(RequestMatchPattern, self).__init__(**kwargs) self.path = path self.method = method @@ -1960,19 +2475,19 @@ def __init__( class ResourceSku(msrest.serialization.Model): """Describes an available Cognitive Services SKU. - :param resource_type: The type of resource the SKU applies to. - :type resource_type: str - :param name: The name of SKU. - :type name: str - :param tier: Specifies the tier of Cognitive Services account. - :type tier: str - :param kind: The Kind of resources that are supported in this SKU. - :type kind: str - :param locations: The set of locations that the SKU is available. - :type locations: list[str] - :param restrictions: The restrictions because of which SKU cannot be used. This is empty if + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :ivar tier: Specifies the tier of Cognitive Services account. + :vartype tier: str + :ivar kind: The Kind of resources that are supported in this SKU. + :vartype kind: str + :ivar locations: The set of locations that the SKU is available. + :vartype locations: list[str] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. - :type restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] + :vartype restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] """ _attribute_map = { @@ -1995,6 +2510,21 @@ def __init__( restrictions: Optional[List["ResourceSkuRestrictions"]] = None, **kwargs ): + """ + :keyword resource_type: The type of resource the SKU applies to. + :paramtype resource_type: str + :keyword name: The name of SKU. + :paramtype name: str + :keyword tier: Specifies the tier of Cognitive Services account. + :paramtype tier: str + :keyword kind: The Kind of resources that are supported in this SKU. + :paramtype kind: str + :keyword locations: The set of locations that the SKU is available. + :paramtype locations: list[str] + :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :paramtype restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] + """ super(ResourceSku, self).__init__(**kwargs) self.resource_type = resource_type self.name = name @@ -2009,10 +2539,10 @@ class ResourceSkuListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of skus available for the subscription. - :type value: list[~azure.mgmt.cognitiveservices.models.ResourceSku] - :param next_link: The uri to fetch the next page of Skus. - :type next_link: str + :ivar value: Required. The list of skus available for the subscription. + :vartype value: list[~azure.mgmt.cognitiveservices.models.ResourceSku] + :ivar next_link: The uri to fetch the next page of Skus. + :vartype next_link: str """ _validation = { @@ -2031,6 +2561,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. The list of skus available for the subscription. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.ResourceSku] + :keyword next_link: The uri to fetch the next page of Skus. + :paramtype next_link: str + """ super(ResourceSkuListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2039,10 +2575,10 @@ def __init__( class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ResourceSkuRestrictionInfo. - :param locations: Locations where the SKU is restricted. - :type locations: list[str] - :param zones: List of availability zones where the SKU is restricted. - :type zones: list[str] + :ivar locations: Locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: List of availability zones where the SKU is restricted. + :vartype zones: list[str] """ _attribute_map = { @@ -2057,6 +2593,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword locations: Locations where the SKU is restricted. + :paramtype locations: list[str] + :keyword zones: List of availability zones where the SKU is restricted. + :paramtype zones: list[str] + """ super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) self.locations = locations self.zones = zones @@ -2065,16 +2607,16 @@ def __init__( class ResourceSkuRestrictions(msrest.serialization.Model): """Describes restrictions of a SKU. - :param type: The type of restrictions. Possible values include: "Location", "Zone". - :type type: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType - :param values: The value of restrictions. If the restriction type is set to location. This - would be different locations where the SKU is restricted. - :type values: list[str] - :param restriction_info: The information about the restriction where the SKU cannot be used. - :type restriction_info: ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo - :param reason_code: The reason for restriction. Possible values include: "QuotaId", + :ivar type: The type of restrictions. Possible values include: "Location", "Zone". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType + :ivar values: The value of restrictions. If the restriction type is set to location. This would + be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar restriction_info: The information about the restriction where the SKU cannot be used. + :vartype restriction_info: ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo + :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", "NotAvailableForSubscription". - :type reason_code: str or + :vartype reason_code: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode """ @@ -2094,6 +2636,19 @@ def __init__( reason_code: Optional[Union[str, "ResourceSkuRestrictionsReasonCode"]] = None, **kwargs ): + """ + :keyword type: The type of restrictions. Possible values include: "Location", "Zone". + :paramtype type: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType + :keyword values: The value of restrictions. If the restriction type is set to location. This + would be different locations where the SKU is restricted. + :paramtype values: list[str] + :keyword restriction_info: The information about the restriction where the SKU cannot be used. + :paramtype restriction_info: ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo + :keyword reason_code: The reason for restriction. Possible values include: "QuotaId", + "NotAvailableForSubscription". + :paramtype reason_code: str or + ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode + """ super(ResourceSkuRestrictions, self).__init__(**kwargs) self.type = type self.values = values @@ -2106,21 +2661,21 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. - :type name: str - :param tier: This field is required to be implemented by the Resource Provider if the service + :ivar name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :vartype name: str + :ivar tier: This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", "Standard", "Premium", "Enterprise". - :type tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier - :param size: The SKU size. When the name field is the combination of tier and some other value, + :vartype tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier + :ivar size: The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. - :type size: str - :param family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :type family: str - :param capacity: If the SKU supports scale out/in then the capacity integer should be included. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -2145,6 +2700,23 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Ex - P3. It is typically a letter+number code. + :paramtype name: str + :keyword tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Possible values include: "Free", "Basic", + "Standard", "Premium", "Enterprise". + :paramtype tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier + :keyword size: The SKU size. When the name field is the combination of tier and some other + value, this would be the standalone code. + :paramtype size: str + :keyword family: If the service has different generations of hardware, for the same SKU, then + that can be captured here. + :paramtype family: str + :keyword capacity: If the SKU supports scale out/in then the capacity integer should be + included. If scale out/in is not possible for the resource this may be omitted. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2156,18 +2728,18 @@ def __init__( class SkuAvailability(msrest.serialization.Model): """SKU availability. - :param kind: The Kind of the resource. - :type kind: str - :param type: The Type of the resource. - :type type: str - :param sku_name: The SKU of Cognitive Services account. - :type sku_name: str - :param sku_available: Indicates the given SKU is available or not. - :type sku_available: bool - :param reason: Reason why the SKU is not available. - :type reason: str - :param message: Additional error message. - :type message: str + :ivar kind: The Kind of the resource. + :vartype kind: str + :ivar type: The Type of the resource. + :vartype type: str + :ivar sku_name: The SKU of Cognitive Services account. + :vartype sku_name: str + :ivar sku_available: Indicates the given SKU is available or not. + :vartype sku_available: bool + :ivar reason: Reason why the SKU is not available. + :vartype reason: str + :ivar message: Additional error message. + :vartype message: str """ _attribute_map = { @@ -2190,6 +2762,20 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword kind: The Kind of the resource. + :paramtype kind: str + :keyword type: The Type of the resource. + :paramtype type: str + :keyword sku_name: The SKU of Cognitive Services account. + :paramtype sku_name: str + :keyword sku_available: Indicates the given SKU is available or not. + :paramtype sku_available: bool + :keyword reason: Reason why the SKU is not available. + :paramtype reason: str + :keyword message: Additional error message. + :paramtype message: str + """ super(SkuAvailability, self).__init__(**kwargs) self.kind = kind self.type = type @@ -2202,8 +2788,8 @@ def __init__( class SkuAvailabilityListResult(msrest.serialization.Model): """Check SKU availability result list. - :param value: Check SKU availability result list. - :type value: list[~azure.mgmt.cognitiveservices.models.SkuAvailability] + :ivar value: Check SKU availability result list. + :vartype value: list[~azure.mgmt.cognitiveservices.models.SkuAvailability] """ _attribute_map = { @@ -2216,6 +2802,10 @@ def __init__( value: Optional[List["SkuAvailability"]] = None, **kwargs ): + """ + :keyword value: Check SKU availability result list. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.SkuAvailability] + """ super(SkuAvailabilityListResult, self).__init__(**kwargs) self.value = value @@ -2223,10 +2813,10 @@ def __init__( class SkuCapability(msrest.serialization.Model): """SkuCapability indicates the capability of a certain feature. - :param name: The name of the SkuCapability. - :type name: str - :param value: The value of the SkuCapability. - :type value: str + :ivar name: The name of the SkuCapability. + :vartype name: str + :ivar value: The value of the SkuCapability. + :vartype value: str """ _attribute_map = { @@ -2241,6 +2831,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the SkuCapability. + :paramtype name: str + :keyword value: The value of the SkuCapability. + :paramtype value: str + """ super(SkuCapability, self).__init__(**kwargs) self.name = name self.value = value @@ -2249,12 +2845,12 @@ def __init__( class SkuChangeInfo(msrest.serialization.Model): """Sku change info of account. - :param count_of_downgrades: Gets the count of downgrades. - :type count_of_downgrades: float - :param count_of_upgrades_after_downgrades: Gets the count of upgrades after downgrades. - :type count_of_upgrades_after_downgrades: float - :param last_change_date: Gets the last change date. - :type last_change_date: str + :ivar count_of_downgrades: Gets the count of downgrades. + :vartype count_of_downgrades: float + :ivar count_of_upgrades_after_downgrades: Gets the count of upgrades after downgrades. + :vartype count_of_upgrades_after_downgrades: float + :ivar last_change_date: Gets the last change date. + :vartype last_change_date: str """ _attribute_map = { @@ -2271,6 +2867,14 @@ def __init__( last_change_date: Optional[str] = None, **kwargs ): + """ + :keyword count_of_downgrades: Gets the count of downgrades. + :paramtype count_of_downgrades: float + :keyword count_of_upgrades_after_downgrades: Gets the count of upgrades after downgrades. + :paramtype count_of_upgrades_after_downgrades: float + :keyword last_change_date: Gets the last change date. + :paramtype last_change_date: str + """ super(SkuChangeInfo, self).__init__(**kwargs) self.count_of_downgrades = count_of_downgrades self.count_of_upgrades_after_downgrades = count_of_upgrades_after_downgrades @@ -2280,20 +2884,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -2316,6 +2920,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -2328,18 +2948,18 @@ def __init__( class ThrottlingRule(msrest.serialization.Model): """ThrottlingRule. - :param key: - :type key: str - :param renewal_period: - :type renewal_period: float - :param count: - :type count: float - :param min_count: - :type min_count: float - :param dynamic_throttling_enabled: - :type dynamic_throttling_enabled: bool - :param match_patterns: - :type match_patterns: list[~azure.mgmt.cognitiveservices.models.RequestMatchPattern] + :ivar key: + :vartype key: str + :ivar renewal_period: + :vartype renewal_period: float + :ivar count: + :vartype count: float + :ivar min_count: + :vartype min_count: float + :ivar dynamic_throttling_enabled: + :vartype dynamic_throttling_enabled: bool + :ivar match_patterns: + :vartype match_patterns: list[~azure.mgmt.cognitiveservices.models.RequestMatchPattern] """ _attribute_map = { @@ -2362,6 +2982,20 @@ def __init__( match_patterns: Optional[List["RequestMatchPattern"]] = None, **kwargs ): + """ + :keyword key: + :paramtype key: str + :keyword renewal_period: + :paramtype renewal_period: float + :keyword count: + :paramtype count: float + :keyword min_count: + :paramtype min_count: float + :keyword dynamic_throttling_enabled: + :paramtype dynamic_throttling_enabled: bool + :keyword match_patterns: + :paramtype match_patterns: list[~azure.mgmt.cognitiveservices.models.RequestMatchPattern] + """ super(ThrottlingRule, self).__init__(**kwargs) self.key = key self.renewal_period = renewal_period @@ -2374,22 +3008,22 @@ def __init__( class Usage(msrest.serialization.Model): """The usage data for a usage request. - :param unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "Percent", "CountPerSecond", "BytesPerSecond", "Milliseconds". - :type unit: str or ~azure.mgmt.cognitiveservices.models.UnitType - :param name: The name information for the metric. - :type name: ~azure.mgmt.cognitiveservices.models.MetricName - :param quota_period: The quota period used to summarize the usage values. - :type quota_period: str - :param limit: Maximum value for this metric. - :type limit: float - :param current_value: Current value for this metric. - :type current_value: float - :param next_reset_time: Next reset time for current quota. - :type next_reset_time: str - :param status: Cognitive Services account quota usage status. Possible values include: + :vartype unit: str or ~azure.mgmt.cognitiveservices.models.UnitType + :ivar name: The name information for the metric. + :vartype name: ~azure.mgmt.cognitiveservices.models.MetricName + :ivar quota_period: The quota period used to summarize the usage values. + :vartype quota_period: str + :ivar limit: Maximum value for this metric. + :vartype limit: float + :ivar current_value: Current value for this metric. + :vartype current_value: float + :ivar next_reset_time: Next reset time for current quota. + :vartype next_reset_time: str + :ivar status: Cognitive Services account quota usage status. Possible values include: "Included", "Blocked", "InOverage", "Unknown". - :type status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus + :vartype status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus """ _attribute_map = { @@ -2414,6 +3048,24 @@ def __init__( status: Optional[Union[str, "QuotaUsageStatus"]] = None, **kwargs ): + """ + :keyword unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "Percent", "CountPerSecond", "BytesPerSecond", "Milliseconds". + :paramtype unit: str or ~azure.mgmt.cognitiveservices.models.UnitType + :keyword name: The name information for the metric. + :paramtype name: ~azure.mgmt.cognitiveservices.models.MetricName + :keyword quota_period: The quota period used to summarize the usage values. + :paramtype quota_period: str + :keyword limit: Maximum value for this metric. + :paramtype limit: float + :keyword current_value: Current value for this metric. + :paramtype current_value: float + :keyword next_reset_time: Next reset time for current quota. + :paramtype next_reset_time: str + :keyword status: Cognitive Services account quota usage status. Possible values include: + "Included", "Blocked", "InOverage", "Unknown". + :paramtype status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus + """ super(Usage, self).__init__(**kwargs) self.unit = unit self.name = name @@ -2427,8 +3079,8 @@ def __init__( class UsageListResult(msrest.serialization.Model): """The response to a list usage request. - :param value: The list of usages for Cognitive Service account. - :type value: list[~azure.mgmt.cognitiveservices.models.Usage] + :ivar value: The list of usages for Cognitive Service account. + :vartype value: list[~azure.mgmt.cognitiveservices.models.Usage] """ _attribute_map = { @@ -2441,6 +3093,10 @@ def __init__( value: Optional[List["Usage"]] = None, **kwargs ): + """ + :keyword value: The list of usages for Cognitive Service account. + :paramtype value: list[~azure.mgmt.cognitiveservices.models.Usage] + """ super(UsageListResult, self).__init__(**kwargs) self.value = value @@ -2470,6 +3126,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -2478,10 +3136,10 @@ def __init__( class UserOwnedStorage(msrest.serialization.Model): """The user owned storage for Cognitive Services account. - :param resource_id: Full resource id of a Microsoft.Storage resource. - :type resource_id: str - :param identity_client_id: - :type identity_client_id: str + :ivar resource_id: Full resource id of a Microsoft.Storage resource. + :vartype resource_id: str + :ivar identity_client_id: + :vartype identity_client_id: str """ _attribute_map = { @@ -2496,6 +3154,12 @@ def __init__( identity_client_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: Full resource id of a Microsoft.Storage resource. + :paramtype resource_id: str + :keyword identity_client_id: + :paramtype identity_client_id: str + """ super(UserOwnedStorage, self).__init__(**kwargs) self.resource_id = resource_id self.identity_client_id = identity_client_id @@ -2506,13 +3170,13 @@ class VirtualNetworkRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Full resource id of a vnet subnet, such as + :ivar id: Required. Full resource id of a vnet subnet, such as '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. - :type id: str - :param state: Gets the state of virtual network rule. - :type state: str - :param ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. - :type ignore_missing_vnet_service_endpoint: bool + :vartype id: str + :ivar state: Gets the state of virtual network rule. + :vartype state: str + :ivar ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. + :vartype ignore_missing_vnet_service_endpoint: bool """ _validation = { @@ -2533,6 +3197,15 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword id: Required. Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + :paramtype id: str + :keyword state: Gets the state of virtual network rule. + :paramtype state: str + :keyword ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(VirtualNetworkRule, self).__init__(**kwargs) self.id = id self.state = state diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py index ff57f46a9642..99ac551cc8b3 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_accounts_operations.py @@ -5,25 +5,438 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_key_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_skus_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_usages_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_models_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccountsOperations(object): """AccountsOperations operations. @@ -49,50 +462,38 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - account_name, # type: str - account, # type: "_models.Account" - **kwargs # type: Any - ): - # type: (...) -> "_models.Account" + resource_group_name: str, + account_name: str, + account: "_models.Account", + **kwargs: Any + ) -> "_models.Account": cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(account, 'Account') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Account', pipeline_response) @@ -107,16 +508,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - account_name, # type: str - account, # type: "_models.Account" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Account"] + resource_group_name: str, + account_name: str, + account: "_models.Account", + **kwargs: Any + ) -> LROPoller["_models.Account"]: """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. @@ -128,15 +531,18 @@ def begin_create( :type account: ~azure.mgmt.cognitiveservices.models.Account :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', @@ -148,27 +554,21 @@ def begin_create( resource_group_name=resource_group_name, account_name=account_name, account=account, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -180,54 +580,43 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - account_name, # type: str - account, # type: "_models.Account" - **kwargs # type: Any - ): - # type: (...) -> "_models.Account" + resource_group_name: str, + account_name: str, + account: "_models.Account", + **kwargs: Any + ) -> "_models.Account": cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(account, 'Account') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(account, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Account', pipeline_response) @@ -239,16 +628,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - account_name, # type: str - account, # type: "_models.Account" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Account"] + resource_group_name: str, + account_name: str, + account: "_models.Account", + **kwargs: Any + ) -> LROPoller["_models.Account"]: """Updates a Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -259,15 +650,18 @@ def begin_update( :type account: ~azure.mgmt.cognitiveservices.models.Account :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Account or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,27 +673,21 @@ def begin_update( resource_group_name=resource_group_name, account_name=account_name, account=account, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -311,61 +699,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a Cognitive Services account from the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -374,15 +752,17 @@ def begin_delete( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -396,21 +776,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -422,15 +795,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Account" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.Account": """Returns a Cognitive Services account specified by the parameters. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -447,33 +821,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -482,14 +846,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccountListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AccountListResult"]: """Returns all the resources of a particular type belonging to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -504,35 +870,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -545,22 +907,23 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccountListResult"] + **kwargs: Any + ) -> Iterable["_models.AccountListResult"]: """Returns all the resources of a particular type belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -573,34 +936,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -613,24 +971,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore + @distributed_trace def list_keys( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiKeys" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.ApiKeys": """Lists the account keys for the specified Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -647,33 +1006,23 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiKeys', pipeline_response) @@ -682,16 +1031,18 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'} # type: ignore + + @distributed_trace def regenerate_key( self, - resource_group_name, # type: str - account_name, # type: str - key_name, # type: Union[str, "_models.KeyName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiKeys" + resource_group_name: str, + account_name: str, + key_name: Union[str, "_models.KeyName"], + **kwargs: Any + ) -> "_models.ApiKeys": """Regenerates the specified account key for the specified Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -711,39 +1062,28 @@ def regenerate_key( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.RegenerateKeyParameters(key_name=key_name) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _parameters = _models.RegenerateKeyParameters(key_name=key_name) + _json = self._serialize.body(_parameters, 'RegenerateKeyParameters') + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'RegenerateKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiKeys', pipeline_response) @@ -752,15 +1092,17 @@ def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'} # type: ignore + + @distributed_trace def list_skus( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccountSkuListResult" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.AccountSkuListResult": """List available SKUs for the requested Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -777,33 +1119,23 @@ def list_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccountSkuListResult', pipeline_response) @@ -812,16 +1144,18 @@ def list_skus( return cls(pipeline_response, deserialized, {}) return deserialized + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'} # type: ignore + + @distributed_trace def list_usages( self, - resource_group_name, # type: str - account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.UsageListResult" + resource_group_name: str, + account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> "_models.UsageListResult": """Get usages for the requested Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -841,35 +1175,24 @@ def list_usages( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_usages_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_usages.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UsageListResult', pipeline_response) @@ -878,4 +1201,82 @@ def list_usages( return cls(pipeline_response, deserialized, {}) return deserialized + list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'} # type: ignore + + + @distributed_trace + def list_models( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.AccountModelListResult"]: + """List available Models for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccountModelListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.AccountModelListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountModelListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_models.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccountModelListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_models.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py index ab3055670978..b3a746966337 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_cognitive_services_management_client_operations.py @@ -5,34 +5,119 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_sku_availability_request( + subscription_id: str, + location: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_domain_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CognitiveServicesManagementClientOperationsMixin(object): + @distributed_trace def check_sku_availability( self, - location, # type: str - skus, # type: List[str] - kind, # type: str - type, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SkuAvailabilityListResult" + location: str, + skus: List[str], + kind: str, + type: str, + **kwargs: Any + ) -> "_models.SkuAvailabilityListResult": """Check available SKUs. :param location: Resource location. @@ -54,38 +139,27 @@ def check_sku_availability( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_sku_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _parameters = _models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) + _json = self._serialize.body(_parameters, 'CheckSkuAvailabilityParameter') + + request = build_check_sku_availability_request( + subscription_id=self._config.subscription_id, + location=location, + content_type=content_type, + json=_json, + template_url=self.check_sku_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'CheckSkuAvailabilityParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SkuAvailabilityListResult', pipeline_response) @@ -94,16 +168,18 @@ def check_sku_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_sku_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'} # type: ignore + + @distributed_trace def check_domain_availability( self, - subdomain_name, # type: str - type, # type: str - kind=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.DomainAvailability" + subdomain_name: str, + type: str, + kind: Optional[str] = None, + **kwargs: Any + ) -> "_models.DomainAvailability": """Check whether a domain is available. :param subdomain_name: The subdomain name to use. @@ -123,37 +199,26 @@ def check_domain_availability( } error_map.update(kwargs.pop('error_map', {})) - _parameters = _models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type, kind=kind) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_domain_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _parameters = _models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type, kind=kind) + _json = self._serialize.body(_parameters, 'CheckDomainAvailabilityParameter') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_domain_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_domain_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'CheckDomainAvailabilityParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DomainAvailability', pipeline_response) @@ -162,4 +227,6 @@ def check_domain_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_domain_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability'} # type: ignore + diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py index ac596be7642c..d1685b62889f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_plans_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + commitment_plan_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + commitment_plan_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + commitment_plan_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CommitmentPlansOperations(object): """CommitmentPlansOperations operations. @@ -47,13 +205,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CommitmentPlanListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.CommitmentPlanListResult"]: """Gets the commitmentPlans associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,8 +219,10 @@ def list( :param account_name: The name of Cognitive Services account. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommitmentPlanListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanListResult] + :return: An iterator like instance of either CommitmentPlanListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CommitmentPlanListResult"] @@ -70,36 +230,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CommitmentPlanListResult', pipeline_response) + deserialized = self._deserialize("CommitmentPlanListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,25 +269,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - commitment_plan_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CommitmentPlan" + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + **kwargs: Any + ) -> "_models.CommitmentPlan": """Gets the specified commitmentPlans associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -150,34 +308,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CommitmentPlan', pipeline_response) @@ -186,17 +334,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - commitment_plan_name, # type: str - commitment_plan, # type: "_models.CommitmentPlan" - **kwargs # type: Any - ): - # type: (...) -> "_models.CommitmentPlan" + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: "_models.CommitmentPlan", + **kwargs: Any + ) -> "_models.CommitmentPlan": """Update the state of specified commitmentPlans associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -218,39 +368,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(commitment_plan, 'CommitmentPlan') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(commitment_plan, 'CommitmentPlan') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -263,64 +403,55 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - commitment_plan_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + commitment_plan_name=commitment_plan_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - commitment_plan_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified commitmentPlan associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -332,15 +463,17 @@ def begin_delete( :type commitment_plan_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -355,22 +488,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'commitmentPlanName': self._serialize.url("commitment_plan_name", commitment_plan_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -382,4 +507,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py index 1113d4064c6b..b9abb42f5fa6 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_commitment_tiers_operations.py @@ -5,23 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CommitmentTiersOperations(object): """CommitmentTiersOperations operations. @@ -45,19 +80,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CommitmentTierListResult"] + location: str, + **kwargs: Any + ) -> Iterable["_models.CommitmentTierListResult"]: """List Commitment Tiers. :param location: Resource location. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommitmentTierListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTierListResult] + :return: An iterator like instance of either CommitmentTierListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTierListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CommitmentTierListResult"] @@ -65,35 +102,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location=location, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CommitmentTierListResult', pipeline_response) + deserialized = self._deserialize("CommitmentTierListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +139,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py index 6625616fa48e..51588dd4f39b 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deleted_accounts_operations.py @@ -5,25 +5,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + location: str, + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}') + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_purge_request_initial( + location: str, + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}') + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DeletedAccountsOperations(object): """DeletedAccountsOperations operations. @@ -47,14 +154,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - location, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Account" + location: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.Account": """Returns a Cognitive Services account specified by the parameters. :param location: Resource location. @@ -73,34 +180,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -109,64 +206,55 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + def _purge_initial( self, - location, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + location: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._purge_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_purge_request_initial( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self._purge_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + + @distributed_trace def begin_purge( self, - location, # type: str - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + location: str, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a Cognitive Services account from the resource group. :param location: Resource location. @@ -177,15 +265,17 @@ def begin_purge( :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -200,22 +290,14 @@ def begin_purge( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'location': self._serialize.url("location", location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -227,13 +309,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccountListResult"] + **kwargs: Any + ) -> Iterable["_models.AccountListResult"]: """Returns all the resources of a particular type belonging to a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -246,34 +329,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccountListResult', pipeline_response) + deserialized = self._deserialize("AccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,12 +364,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py index 41a60cd392ab..08ef952f9e26 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_deployments_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + deployment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + deployment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -47,13 +205,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeploymentListResult"] + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable["_models.DeploymentListResult"]: """Gets the deployments associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -61,7 +219,8 @@ def list( :param account_name: The name of Cognitive Services account. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +229,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,25 +268,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - deployment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Deployment" + resource_group_name: str, + account_name: str, + deployment_name: str, + **kwargs: Any + ) -> "_models.Deployment": """Gets the specified deployments associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -150,34 +307,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Deployment', pipeline_response) @@ -186,56 +333,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - account_name, # type: str - deployment_name, # type: str - deployment, # type: "_models.Deployment" - **kwargs # type: Any - ): - # type: (...) -> "_models.Deployment" + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: "_models.Deployment", + **kwargs: Any + ) -> "_models.Deployment": cls = kwargs.pop('cls', None) # type: ClsType["_models.Deployment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(deployment, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Deployment', pipeline_response) @@ -247,17 +384,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - deployment_name, # type: str - deployment, # type: "_models.Deployment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Deployment"] + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: "_models.Deployment", + **kwargs: Any + ) -> LROPoller["_models.Deployment"]: """Update the state of specified deployments associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -271,15 +410,18 @@ def begin_create_or_update( :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Deployment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Deployment"] lro_delay = kwargs.pop( 'polling_interval', @@ -292,28 +434,21 @@ def begin_create_or_update( account_name=account_name, deployment_name=deployment_name, deployment=deployment, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Deployment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -325,64 +460,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - deployment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + deployment_name=deployment_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - deployment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + deployment_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified deployment associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -394,15 +519,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -417,22 +544,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -444,4 +563,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py index 39286dbd94ce..34d63170f755 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.CognitiveServices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all the available Cognitive Services account operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py index a138e7b1de42..93ab7161de46 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_endpoint_connections_operations.py @@ -5,24 +5,182 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -46,13 +204,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnectionListResult" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnectionListResult": """Gets the private endpoint connections associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,33 +227,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) @@ -104,16 +252,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets the specified private endpoint connection associated with the Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -133,34 +283,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -169,56 +309,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - properties, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -230,17 +360,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - properties, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update the state of specified private endpoint connection associated with the Cognitive Services account. @@ -255,15 +387,20 @@ def begin_create_or_update( :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -276,28 +413,21 @@ def begin_create_or_update( account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -309,64 +439,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - account_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified private endpoint connection associated with the Cognitive Services account. @@ -379,15 +499,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -402,22 +524,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -429,4 +543,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py index c485187b53fe..7c00748631fc 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_private_link_resources_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=64, min_length=2, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_.-]*$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourceListResult" + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResourceListResult": """Gets the private link resources that need to be created for a Cognitive Services account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,33 +104,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) @@ -102,4 +129,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources'} # type: ignore + diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py index 8cf6c81c4a05..7aec58fb4295 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_resource_skus_operations.py @@ -5,23 +5,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceSkusOperations(object): """ResourceSkusOperations operations. @@ -45,16 +78,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceSkuListResult"] + **kwargs: Any + ) -> Iterable["_models.ResourceSkuListResult"]: """Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceSkuListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkuListResult] + :return: An iterator like instance of either ResourceSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuListResult"] @@ -62,34 +97,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkuListResult', pipeline_response) + deserialized = self._deserialize("ResourceSkuListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +132,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )