diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/CHANGELOG.md b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/CHANGELOG.md index 52b0825c96f1..22dbcd9e7bd9 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/CHANGELOG.md +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/CHANGELOG.md @@ -1,5 +1,45 @@ # Release History +## 11.0.0b1 (2020-11-03) + +This is beta preview version. + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +**General breaking changes** + +- Credential system has been completly revamped: + + - `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/ + - `credentials` parameter has been renamed `credential` + +- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of + supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) +- You can't import a `version` module anymore, use `__version__` instead +- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`. +- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed). +- Most of the operation kwarg have changed. Some of the most noticeable: + + - `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user + - For a complete set of + supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) + +**General new features** + +- Type annotations support using `typing`. SDKs are mypy ready. +- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client. +- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview. + +## 6.3.0 (2020-10-09) + +**Features** + + - Model CognitiveServicesAccountApiProperties has a new parameter website_name + - Model CognitiveServicesAccountApiProperties has a new parameter super_user + - Model CognitiveServicesAccountApiProperties has a new parameter aad_client_id + - Model CognitiveServicesAccountApiProperties has a new parameter aad_tenant_id + - Added operation PrivateEndpointConnectionsOperations.list + ## 6.2.0 (2020-05-29) **Features** diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/README.md b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/README.md index 990ff66d1d8c..536b2e89fb4b 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/README.md +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/README.md @@ -7,8 +7,14 @@ For a more complete view of Azure libraries, see the [azure sdk python release]( # Usage -For code examples, see [Cognitive Services Management](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) -on docs.microsoft.com. + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Cognitive Services Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) # Provide Feedback 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 98489cd6e6ab..ef15f946bbb8 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py @@ -1,19 +1,19 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import CognitiveServicesManagementClientConfiguration from ._cognitive_services_management_client import CognitiveServicesManagementClient -__all__ = ['CognitiveServicesManagementClient', 'CognitiveServicesManagementClientConfiguration'] - -from .version import VERSION +from ._version import VERSION __version__ = VERSION +__all__ = ['CognitiveServicesManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 6fcf5687b9e9..6994035541fa 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 @@ -1,70 +1,90 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential from ._configuration import CognitiveServicesManagementClientConfiguration -from .operations import CognitiveServicesManagementClientOperationsMixin from .operations import AccountsOperations from .operations import ResourceSkusOperations from .operations import Operations +from .operations import CognitiveServicesManagementClientOperationsMixin from .operations import PrivateEndpointConnectionsOperations from .operations import PrivateLinkResourcesOperations from . import models -class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin, SDKClient): - """Cognitive Services Management Client - - :ivar config: Configuration for client. - :vartype config: CognitiveServicesManagementClientConfiguration +class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin): + """Cognitive Services Management Client. - :ivar accounts: Accounts operations + :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.cognitiveservices.operations.AccountsOperations - :ivar resource_skus: ResourceSkus operations + :ivar resource_skus: ResourceSkusOperations operations :vartype resource_skus: azure.mgmt.cognitiveservices.operations.ResourceSkusOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.cognitiveservices.operations.Operations - :ivar private_endpoint_connections: PrivateEndpointConnections operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations - :ivar private_link_resources: PrivateLinkResources operations + :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = CognitiveServicesManagementClientConfiguration(credentials, subscription_id, base_url) - super(CognitiveServicesManagementClient, self).__init__(self.config.credentials, self.config) + 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) + 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.api_version = '2017-04-18' 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._client, self._config, self._serialize, self._deserialize) self.resource_skus = ResourceSkusOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> CognitiveServicesManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 265e0501e3d1..60083a4bb46b 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py @@ -1,48 +1,71 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class CognitiveServicesManagementClientConfiguration(Configuration): + """Configuration for CognitiveServicesManagementClient. -class CognitiveServicesManagementClientConfiguration(AzureConfiguration): - """Configuration for CognitiveServicesManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' - - super(CognitiveServicesManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + super(CognitiveServicesManagementClientConfiguration, self).__init__(**kwargs) - self.add_user_agent('azure-mgmt-cognitiveservices/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2017-04-18" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-cognitiveservices/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/version.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py similarity index 84% rename from sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/version.py rename to sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py index 5577b1bdef5b..75a1436b862f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/version.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_version.py @@ -1,13 +1,9 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.2.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 new file mode 100644 index 000000000000..33537ef8312c --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._cognitive_services_management_client import CognitiveServicesManagementClient +__all__ = ['CognitiveServicesManagementClient'] 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 new file mode 100644 index 000000000000..8a47f0f5a784 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_cognitive_services_management_client.py @@ -0,0 +1,84 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +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 ResourceSkusOperations +from .operations import Operations +from .operations import CognitiveServicesManagementClientOperationsMixin +from .operations import PrivateEndpointConnectionsOperations +from .operations import PrivateLinkResourcesOperations +from .. import models + + +class CognitiveServicesManagementClient(CognitiveServicesManagementClientOperationsMixin): + """Cognitive Services Management Client. + + :ivar accounts: AccountsOperations operations + :vartype accounts: azure.mgmt.cognitiveservices.aio.operations.AccountsOperations + :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 private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :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 + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = CognitiveServicesManagementClientConfiguration(credential, 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.accounts = AccountsOperations( + 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.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) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "CognitiveServicesManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 000000000000..056ffde75428 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 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 .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class CognitiveServicesManagementClientConfiguration(Configuration): + """Configuration for CognitiveServicesManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 = "2017-04-18" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-cognitiveservices/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py new file mode 100644 index 000000000000..fee14b0688ba --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._accounts_operations import AccountsOperations +from ._resource_skus_operations import ResourceSkusOperations +from ._operations import Operations +from ._cognitive_services_management_client_operations import CognitiveServicesManagementClientOperationsMixin +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations + +__all__ = [ + 'AccountsOperations', + 'ResourceSkusOperations', + 'Operations', + 'CognitiveServicesManagementClientOperationsMixin', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', +] 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 new file mode 100644 index 000000000000..40d27aae6ba5 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_accounts_operations.py @@ -0,0 +1,693 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccountsOperations: + """AccountsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create( + self, + resource_group_name: str, + account_name: str, + account: "models.CognitiveServicesAccount", + **kwargs + ) -> "models.CognitiveServicesAccount": + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param account: The parameters to provide for the created account. + :type account: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccount, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + '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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + account_name: str, + account: "models.CognitiveServicesAccount", + **kwargs + ) -> "models.CognitiveServicesAccount": + """Updates a 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 + :param account: The parameters to provide for the created account. + :type account: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccount, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.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, pattern=r'^[-\w\._\(\)]+$'), + '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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> 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. + :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: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = "2017-04-18" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + async def get_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> "models.CognitiveServicesAccount": + """Returns a Cognitive Services account specified by the parameters. + + :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: CognitiveServicesAccount, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + + # Construct URL + url = self.get_properties.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.CognitiveServicesAccountListResult"]: + """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. + :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 CognitiveServicesAccountListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CognitiveServicesAccountListResult', 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]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.CognitiveServicesAccountListResult"]: + """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 + :return: An iterator like instance of either CognitiveServicesAccountListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CognitiveServicesAccountListResult', 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]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def list_keys( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> "models.CognitiveServicesAccountKeys": + """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. + :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: CognitiveServicesAccountKeys, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CognitiveServicesAccountKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'} # type: ignore + + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_name: Union[str, "models.KeyName"], + **kwargs + ) -> "models.CognitiveServicesAccountKeys": + """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. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param key_name: key name to generate (Key1|Key2). + :type key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccountKeys, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.RegenerateKeyParameters(key_name=key_name) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CognitiveServicesAccountKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'} # type: ignore + + async def list_skus( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> "models.CognitiveServicesAccountEnumerateSkusResult": + """List available SKUs 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: CognitiveServicesAccountEnumerateSkusResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountEnumerateSkusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountEnumerateSkusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CognitiveServicesAccountEnumerateSkusResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'} # type: ignore + + async def get_usages( + self, + resource_group_name: str, + account_name: str, + filter: Optional[str] = None, + **kwargs + ) -> "models.UsagesResult": + """Get usages 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 + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsagesResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.UsagesResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UsagesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + + # Construct URL + url = self.get_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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('UsagesResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'} # 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 new file mode 100644 index 000000000000..98664eed313b --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_cognitive_services_management_client_operations.py @@ -0,0 +1,154 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CognitiveServicesManagementClientOperationsMixin: + + async def check_sku_availability( + self, + location: str, + skus: List[str], + kind: str, + type: str, + **kwargs + ) -> "models.CheckSkuAvailabilityResultList": + """Check available SKUs. + + :param location: Resource location. + :type location: str + :param skus: The SKU of the resource. + :type skus: list[str] + :param kind: The Kind of the resource. + :type kind: str + :param type: The Type of the resource. + :type type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckSkuAvailabilityResultList, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResultList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckSkuAvailabilityResultList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) + api_version = "2017-04-18" + 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') + + # 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') + + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckSkuAvailabilityResultList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_sku_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'} # type: ignore + + async def check_domain_availability( + self, + subdomain_name: str, + type: str, + **kwargs + ) -> "models.CheckDomainAvailabilityResult": + """Check whether a domain is available. + + :param subdomain_name: The subdomain name to use. + :type subdomain_name: str + :param type: The Type of the resource. + :type type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckDomainAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckDomainAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type) + api_version = "2017-04-18" + 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) + + # 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') + + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckDomainAvailabilityResult', pipeline_response) + + if cls: + 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/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py new file mode 100644 index 000000000000..6836e3ebc0cd --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationEntityListResult"]: + """Lists all the available Cognitive Services account operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationEntityListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.OperationEntityListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationEntityListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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 = 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) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationEntityListResult', 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CognitiveServices/operations'} # type: ignore 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 new file mode 100644 index 000000000000..e95b1e4d129d --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,294 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateEndpointConnectionsOperations: + """PrivateEndpointConnectionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> "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. + :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: PrivateEndpointConnectionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections'} # type: ignore + + async def get( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs + ) -> "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. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + 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( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: "models.PrivateEndpointConnection", + **kwargs + ) -> "models.PrivateEndpointConnection": + """Update the state of 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. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs + ) -> None: + """Deletes 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. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = "2017-04-18" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + '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] + + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 new file mode 100644 index 000000000000..1d754d952d7a --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,99 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateLinkResourcesOperations: + """PrivateLinkResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> "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. + :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: PrivateLinkResourceListResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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, pattern=r'^[-\w\._\(\)]+$'), + '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 = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + + if cls: + 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 new file mode 100644 index 000000000000..52878f1d26e0 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_resource_skus_operations.py @@ -0,0 +1,108 @@ +# 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 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceSkusOperations: + """ResourceSkusOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.ResourceSkusResult"]: + """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 ResourceSkusResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkusResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkusResult', 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus'} # type: ignore 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 8d7136637568..5e4aa53adfd3 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 @@ -1,16 +1,12 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AzureEntityResource from ._models_py3 import CheckDomainAvailabilityParameter from ._models_py3 import CheckDomainAvailabilityResult from ._models_py3 import CheckSkuAvailabilityParameter @@ -20,10 +16,11 @@ from ._models_py3 import CognitiveServicesAccountApiProperties from ._models_py3 import CognitiveServicesAccountEnumerateSkusResult from ._models_py3 import CognitiveServicesAccountKeys + from ._models_py3 import CognitiveServicesAccountListResult from ._models_py3 import CognitiveServicesAccountProperties from ._models_py3 import CognitiveServicesResourceAndSku from ._models_py3 import Encryption - from ._models_py3 import Error, ErrorException + from ._models_py3 import Error from ._models_py3 import ErrorBody from ._models_py3 import Identity from ._models_py3 import IpRule @@ -32,91 +29,90 @@ from ._models_py3 import NetworkRuleSet from ._models_py3 import OperationDisplayInfo from ._models_py3 import OperationEntity + from ._models_py3 import OperationEntityListResult 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 RegenerateKeyParameters from ._models_py3 import Resource from ._models_py3 import ResourceSku from ._models_py3 import ResourceSkuRestrictionInfo from ._models_py3 import ResourceSkuRestrictions + from ._models_py3 import ResourceSkusResult from ._models_py3 import Sku from ._models_py3 import SkuCapability - from ._models_py3 import TrackedResource from ._models_py3 import Usage from ._models_py3 import UsagesResult from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserOwnedStorage from ._models_py3 import VirtualNetworkRule except (SyntaxError, ImportError): - from ._models import AzureEntityResource - from ._models import CheckDomainAvailabilityParameter - from ._models import CheckDomainAvailabilityResult - from ._models import CheckSkuAvailabilityParameter - from ._models import CheckSkuAvailabilityResult - from ._models import CheckSkuAvailabilityResultList - from ._models import CognitiveServicesAccount - from ._models import CognitiveServicesAccountApiProperties - from ._models import CognitiveServicesAccountEnumerateSkusResult - from ._models import CognitiveServicesAccountKeys - from ._models import CognitiveServicesAccountProperties - from ._models import CognitiveServicesResourceAndSku - from ._models import Encryption - from ._models import Error, ErrorException - from ._models import ErrorBody - from ._models import Identity - from ._models import IpRule - from ._models import KeyVaultProperties - from ._models import MetricName - from ._models import NetworkRuleSet - from ._models import OperationDisplayInfo - from ._models import OperationEntity - from ._models import PrivateEndpoint - from ._models import PrivateEndpointConnection - from ._models import PrivateEndpointConnectionProperties - from ._models import PrivateLinkResource - from ._models import PrivateLinkResourceListResult - from ._models import PrivateLinkResourceProperties - from ._models import PrivateLinkServiceConnectionState - from ._models import ProxyResource - from ._models import RegenerateKeyParameters - from ._models import Resource - from ._models import ResourceSku - from ._models import ResourceSkuRestrictionInfo - from ._models import ResourceSkuRestrictions - from ._models import Sku - from ._models import SkuCapability - from ._models import TrackedResource - from ._models import Usage - from ._models import UsagesResult - from ._models import UserAssignedIdentity - from ._models import UserOwnedStorage - from ._models import VirtualNetworkRule -from ._paged_models import CognitiveServicesAccountPaged -from ._paged_models import OperationEntityPaged -from ._paged_models import ResourceSkuPaged + from ._models import CheckDomainAvailabilityParameter # type: ignore + from ._models import CheckDomainAvailabilityResult # type: ignore + from ._models import CheckSkuAvailabilityParameter # type: ignore + from ._models import CheckSkuAvailabilityResult # type: ignore + from ._models import CheckSkuAvailabilityResultList # type: ignore + from ._models import CognitiveServicesAccount # type: ignore + from ._models import CognitiveServicesAccountApiProperties # type: ignore + from ._models import CognitiveServicesAccountEnumerateSkusResult # type: ignore + from ._models import CognitiveServicesAccountKeys # type: ignore + from ._models import CognitiveServicesAccountListResult # type: ignore + from ._models import CognitiveServicesAccountProperties # type: ignore + from ._models import CognitiveServicesResourceAndSku # type: ignore + from ._models import Encryption # type: ignore + from ._models import Error # type: ignore + from ._models import ErrorBody # 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 OperationDisplayInfo # type: ignore + from ._models import OperationEntity # type: ignore + from ._models import OperationEntityListResult # 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 RegenerateKeyParameters # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceSku # type: ignore + from ._models import ResourceSkuRestrictionInfo # type: ignore + from ._models import ResourceSkuRestrictions # type: ignore + from ._models import ResourceSkusResult # type: ignore + from ._models import Sku # type: ignore + from ._models import SkuCapability # type: ignore + from ._models import Usage # type: ignore + from ._models import UsagesResult # type: ignore + from ._models import UserAssignedIdentity # type: ignore + from ._models import UserOwnedStorage # type: ignore + from ._models import VirtualNetworkRule # type: ignore + from ._cognitive_services_management_client_enums import ( - SkuTier, - ProvisioningState, - NetworkRuleAction, + IdentityType, + KeyName, KeySource, + NetworkRuleAction, PrivateEndpointServiceConnectionStatus, + ProvisioningState, PublicNetworkAccess, - IdentityType, - KeyName, - UnitType, QuotaUsageStatus, - ResourceSkuRestrictionsType, ResourceSkuRestrictionsReasonCode, + ResourceSkuRestrictionsType, + SkuTier, + UnitType, ) __all__ = [ - 'AzureEntityResource', 'CheckDomainAvailabilityParameter', 'CheckDomainAvailabilityResult', 'CheckSkuAvailabilityParameter', @@ -126,10 +122,11 @@ 'CognitiveServicesAccountApiProperties', 'CognitiveServicesAccountEnumerateSkusResult', 'CognitiveServicesAccountKeys', + 'CognitiveServicesAccountListResult', 'CognitiveServicesAccountProperties', 'CognitiveServicesResourceAndSku', 'Encryption', - 'Error', 'ErrorException', + 'Error', 'ErrorBody', 'Identity', 'IpRule', @@ -138,40 +135,38 @@ 'NetworkRuleSet', 'OperationDisplayInfo', 'OperationEntity', + 'OperationEntityListResult', 'PrivateEndpoint', 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', 'PrivateEndpointConnectionProperties', 'PrivateLinkResource', 'PrivateLinkResourceListResult', 'PrivateLinkResourceProperties', 'PrivateLinkServiceConnectionState', - 'ProxyResource', 'RegenerateKeyParameters', 'Resource', 'ResourceSku', 'ResourceSkuRestrictionInfo', 'ResourceSkuRestrictions', + 'ResourceSkusResult', 'Sku', 'SkuCapability', - 'TrackedResource', 'Usage', 'UsagesResult', 'UserAssignedIdentity', 'UserOwnedStorage', 'VirtualNetworkRule', - 'CognitiveServicesAccountPaged', - 'ResourceSkuPaged', - 'OperationEntityPaged', - 'SkuTier', - 'ProvisioningState', - 'NetworkRuleAction', + 'IdentityType', + 'KeyName', 'KeySource', + 'NetworkRuleAction', 'PrivateEndpointServiceConnectionStatus', + 'ProvisioningState', 'PublicNetworkAccess', - 'IdentityType', - 'KeyName', - 'UnitType', 'QuotaUsageStatus', - 'ResourceSkuRestrictionsType', 'ResourceSkuRestrictionsReasonCode', + 'ResourceSkuRestrictionsType', + 'SkuTier', + 'UnitType', ] 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 7e3072cc69ca..db502f1f4829 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 @@ -1,99 +1,128 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum - - -class SkuTier(str, Enum): - - free = "Free" - standard = "Standard" - premium = "Premium" - - -class ProvisioningState(str, Enum): - - creating = "Creating" - resolving_dns = "ResolvingDNS" - moving = "Moving" - deleting = "Deleting" - succeeded = "Succeeded" - failed = "Failed" - - -class NetworkRuleAction(str, Enum): - - allow = "Allow" - deny = "Deny" - - -class KeySource(str, Enum): - - microsoft_cognitive_services = "Microsoft.CognitiveServices" - microsoft_key_vault = "Microsoft.KeyVault" - - -class PrivateEndpointServiceConnectionStatus(str, Enum): - - pending = "Pending" - approved = "Approved" - rejected = "Rejected" - disconnected = "Disconnected" - - -class PublicNetworkAccess(str, Enum): - - enabled = "Enabled" - disabled = "Disabled" - - -class IdentityType(str, Enum): - - none = "None" - system_assigned = "SystemAssigned" - user_assigned = "UserAssigned" - - -class KeyName(str, Enum): - - key1 = "Key1" - key2 = "Key2" - - -class UnitType(str, Enum): - - count = "Count" - bytes = "Bytes" - seconds = "Seconds" - percent = "Percent" - count_per_second = "CountPerSecond" - bytes_per_second = "BytesPerSecond" - milliseconds = "Milliseconds" - - -class QuotaUsageStatus(str, Enum): - - included = "Included" - blocked = "Blocked" - in_overage = "InOverage" - unknown = "Unknown" - - -class ResourceSkuRestrictionsType(str, Enum): - - location = "Location" - zone = "Zone" - - -class ResourceSkuRestrictionsReasonCode(str, Enum): - - quota_id = "QuotaId" - not_available_for_subscription = "NotAvailableForSubscription" +from enum import Enum, EnumMeta +from six import with_metaclass + +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 IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of managed service identity. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + +class KeyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """key name to generate (Key1|Key2) + """ + + KEY1 = "Key1" + KEY2 = "Key2" + +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)): + """The default action when no rule from ipRules and from virtualNetworkRules match. This is only + used after the bypass property has been evaluated. + """ + + ALLOW = "Allow" + DENY = "Deny" + +class PrivateEndpointServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The private endpoint connection status. + """ + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Gets the status of the cognitive services account at the time the operation was called. + """ + + CREATING = "Creating" + RESOLVING_DNS = "ResolvingDNS" + MOVING = "Moving" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + +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' + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class QuotaUsageStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Cognitive Services account quota usage status. + """ + + INCLUDED = "Included" + BLOCKED = "Blocked" + IN_OVERAGE = "InOverage" + UNKNOWN = "Unknown" + +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)): + """The type of restrictions. + """ + + LOCATION = "Location" + ZONE = "Zone" + +class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Gets the sku tier. This is based on the SKU name. + """ + + FREE = "Free" + STANDARD = "Standard" + PREMIUM = "Premium" + +class UnitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The unit of the metric. + """ + + COUNT = "Count" + BYTES = "Bytes" + SECONDS = "Seconds" + PERCENT = "Percent" + COUNT_PER_SECOND = "CountPerSecond" + BYTES_PER_SECOND = "BytesPerSecond" + MILLISECONDS = "Milliseconds" 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 index 86f982dd54bf..85b422431d3b 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py @@ -1,92 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): - """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. Ex- - 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 a 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. Ex- - 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 CheckDomainAvailabilityParameter(Model): +class CheckDomainAvailabilityParameter(msrest.serialization.Model): """Check Domain availability parameter. All required parameters must be populated in order to send to Azure. @@ -107,17 +31,19 @@ class CheckDomainAvailabilityParameter(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CheckDomainAvailabilityParameter, self).__init__(**kwargs) - self.subdomain_name = kwargs.get('subdomain_name', None) - self.type = kwargs.get('type', None) + self.subdomain_name = kwargs['subdomain_name'] + self.type = kwargs['type'] -class CheckDomainAvailabilityResult(Model): +class CheckDomainAvailabilityResult(msrest.serialization.Model): """Check Domain availability result. - :param is_subdomain_available: Indicates the given SKU is available or - not. + :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 @@ -134,7 +60,10 @@ class CheckDomainAvailabilityResult(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CheckDomainAvailabilityResult, self).__init__(**kwargs) self.is_subdomain_available = kwargs.get('is_subdomain_available', None) self.reason = kwargs.get('reason', None) @@ -142,7 +71,7 @@ def __init__(self, **kwargs): self.type = kwargs.get('type', None) -class CheckSkuAvailabilityParameter(Model): +class CheckSkuAvailabilityParameter(msrest.serialization.Model): """Check SKU availability parameter. All required parameters must be populated in order to send to Azure. @@ -167,14 +96,17 @@ class CheckSkuAvailabilityParameter(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CheckSkuAvailabilityParameter, self).__init__(**kwargs) - self.skus = kwargs.get('skus', None) - self.kind = kwargs.get('kind', None) - self.type = kwargs.get('type', None) + self.skus = kwargs['skus'] + self.kind = kwargs['kind'] + self.type = kwargs['type'] -class CheckSkuAvailabilityResult(Model): +class CheckSkuAvailabilityResult(msrest.serialization.Model): """Check SKU availability result. :param kind: The Kind of the resource. @@ -200,7 +132,10 @@ class CheckSkuAvailabilityResult(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CheckSkuAvailabilityResult, self).__init__(**kwargs) self.kind = kwargs.get('kind', None) self.type = kwargs.get('type', None) @@ -210,60 +145,50 @@ def __init__(self, **kwargs): self.message = kwargs.get('message', None) -class CheckSkuAvailabilityResultList(Model): +class CheckSkuAvailabilityResultList(msrest.serialization.Model): """Check SKU availability result list. :param value: Check SKU availability result list. - :type value: - list[~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResult] + :type value: list[~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResult] """ _attribute_map = { 'value': {'key': 'value', 'type': '[CheckSkuAvailabilityResult]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CheckSkuAvailabilityResultList, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +class CognitiveServicesAccount(msrest.serialization.Model): + """Cognitive Services Account is an Azure resource representing the provisioned account, its type, location and SKU. + Variables are only populated by the server, and will be ignored when sending a request. -class CognitiveServicesAccount(Model): - """Cognitive Services Account is an Azure resource representing the - provisioned account, its type, location and SKU. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar etag: Entity Tag + :ivar etag: Entity Tag. :vartype etag: str - :ivar id: The id of the created account + :ivar id: The id of the created account. :vartype id: str :param kind: The Kind of the resource. :type kind: str - :param location: The location of the resource + :param location: The location of the resource. :type location: str - :ivar name: The name of the created account + :ivar name: The name of the created account. :vartype name: str :param properties: Properties of Cognitive Services account. - :type properties: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountProperties + :type properties: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountProperties :param sku: The SKU of Cognitive Services account. :type sku: ~azure.mgmt.cognitiveservices.models.Sku - :param tags: Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource - (across resource groups). A maximum of 15 tags can be provided for a - resource. Each tag must have a key no greater than 128 characters and - value no greater than 256 characters. + :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + These tags can be used in viewing and grouping this resource (across resource groups). A + maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 + characters and value no greater than 256 characters. :type tags: dict[str, str] - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str :param identity: The identity of Cognitive Services account. :type identity: ~azure.mgmt.cognitiveservices.models.Identity @@ -289,7 +214,10 @@ class CognitiveServicesAccount(Model): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccount, self).__init__(**kwargs) self.etag = None self.id = None @@ -303,26 +231,36 @@ def __init__(self, **kwargs): self.identity = kwargs.get('identity', None) -class CognitiveServicesAccountApiProperties(Model): +class CognitiveServicesAccountApiProperties(msrest.serialization.Model): """The api properties for special APIs. - :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of - QnAMaker. + :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. :type qna_runtime_endpoint: str - :param statistics_enabled: (Bing Search Only) The flag to enable - statistics of Bing Search. + :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. + :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. + :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, 'pattern': r'^( *)Endpoint=sb://(.*);( *)SharedAccessKeyName=(.*);( *)SharedAccessKey=(.*)$'}, - 'storage_account_connection_string': {'max_length': 1000, 'pattern': r'^(( *)DefaultEndpointsProtocol=(http|https)( *);( *))?AccountName=(.*)AccountKey=(.*)EndpointSuffix=(.*)$'}, + '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 = { @@ -330,26 +268,34 @@ class CognitiveServicesAccountApiProperties(Model): '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): + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccountApiProperties, self).__init__(**kwargs) self.qna_runtime_endpoint = kwargs.get('qna_runtime_endpoint', 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 CognitiveServicesAccountEnumerateSkusResult(Model): +class CognitiveServicesAccountEnumerateSkusResult(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. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Gets the list of Cognitive Services accounts and their - properties. - :vartype value: - list[~azure.mgmt.cognitiveservices.models.CognitiveServicesResourceAndSku] + :ivar value: Gets the list of Cognitive Services accounts and their properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.CognitiveServicesResourceAndSku] """ _validation = { @@ -360,12 +306,15 @@ class CognitiveServicesAccountEnumerateSkusResult(Model): 'value': {'key': 'value', 'type': '[CognitiveServicesResourceAndSku]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccountEnumerateSkusResult, self).__init__(**kwargs) self.value = None -class CognitiveServicesAccountKeys(Model): +class CognitiveServicesAccountKeys(msrest.serialization.Model): """The access keys for the cognitive services account. :param key1: Gets the value of key 1. @@ -379,52 +328,78 @@ class CognitiveServicesAccountKeys(Model): 'key2': {'key': 'key2', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccountKeys, self).__init__(**kwargs) self.key1 = kwargs.get('key1', None) self.key2 = kwargs.get('key2', None) -class CognitiveServicesAccountProperties(Model): +class CognitiveServicesAccountListResult(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.CognitiveServicesAccount] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[CognitiveServicesAccount]'}, + } + + def __init__( + self, + **kwargs + ): + super(CognitiveServicesAccountListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = None + + +class CognitiveServicesAccountProperties(msrest.serialization.Model): """Properties of Cognitive Services account. - Variables are only populated by the server, and will be ignored when - sending a request. + 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: - 'Creating', 'ResolvingDNS', 'Moving', 'Deleting', 'Succeeded', 'Failed' - :vartype provisioning_state: str or - ~azure.mgmt.cognitiveservices.models.ProvisioningState + :ivar provisioning_state: Gets the status of the cognitive services account at the time the + operation was called. Possible values include: "Creating", "ResolvingDNS", "Moving", + "Deleting", "Succeeded", "Failed". + :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. :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] - :param custom_sub_domain_name: Optional subdomain name used for - token-based authentication. + :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] + :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. + :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] - :param private_endpoint_connections: The private endpoint connection - associated with the Cognitive Services account. + :type user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] + :param private_endpoint_connections: The private endpoint connection associated with the + Cognitive Services account. :type 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 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.CognitiveServicesAccountApiProperties @@ -451,7 +426,10 @@ class CognitiveServicesAccountProperties(Model): 'api_properties': {'key': 'apiProperties', 'type': 'CognitiveServicesAccountApiProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccountProperties, self).__init__(**kwargs) self.provisioning_state = None self.endpoint = None @@ -466,10 +444,10 @@ def __init__(self, **kwargs): self.api_properties = kwargs.get('api_properties', None) -class CognitiveServicesResourceAndSku(Model): +class CognitiveServicesResourceAndSku(msrest.serialization.Model): """Cognitive Services resource type and SKU. - :param resource_type: Resource Namespace and Type + :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 @@ -480,21 +458,23 @@ class CognitiveServicesResourceAndSku(Model): 'sku': {'key': 'sku', 'type': 'Sku'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CognitiveServicesResourceAndSku, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.sku = kwargs.get('sku', None) -class Encryption(Model): +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" . + :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 """ @@ -503,13 +483,16 @@ class Encryption(Model): 'key_source': {'key': 'keySource', 'type': 'str'}, } - def __init__(self, **kwargs): + 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 Error(Model): +class Error(msrest.serialization.Model): """Cognitive Services error object. :param error: The error body. @@ -520,31 +503,22 @@ class Error(Model): 'error': {'key': 'error', 'type': 'ErrorBody'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Error, self).__init__(**kwargs) self.error = kwargs.get('error', None) -class ErrorException(HttpOperationError): - """Server responsed with exception of type: 'Error'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorException, self).__init__(deserialize, response, 'Error', *args) - - -class ErrorBody(Model): +class ErrorBody(msrest.serialization.Model): """Cognitive Services error body. All required parameters must be populated in order to send to Azure. - :param code: Required. error code + :param code: Required. error code. :type code: str - :param message: Required. error message + :param message: Required. error message. :type message: str """ @@ -558,29 +532,30 @@ class ErrorBody(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) + self.code = kwargs['code'] + self.message = kwargs['message'] -class Identity(Model): +class Identity(msrest.serialization.Model): """Managed service identity. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of managed service identity. Possible values include: - 'None', 'SystemAssigned', 'UserAssigned' + :param type: Type of managed service identity. Possible values include: "None", + "SystemAssigned", "UserAssigned". :type type: str or ~azure.mgmt.cognitiveservices.models.IdentityType :ivar tenant_id: Tenant of managed service identity. :vartype tenant_id: str :ivar principal_id: Principal Id of managed service 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} + :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] """ @@ -591,13 +566,16 @@ class Identity(Model): } _attribute_map = { - 'type': {'key': 'type', 'type': 'IdentityType'}, + '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): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.tenant_id = None @@ -605,14 +583,13 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IpRule(Model): +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). + :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 """ @@ -624,19 +601,22 @@ class IpRule(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IpRule, self).__init__(**kwargs) - self.value = kwargs.get('value', None) + self.value = kwargs['value'] -class KeyVaultProperties(Model): +class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault + :param key_name: Name of the Key from KeyVault. :type key_name: str - :param key_version: Version of the Key from KeyVault + :param key_version: Version of the Key from KeyVault. :type key_version: str - :param key_vault_uri: Uri of KeyVault + :param key_vault_uri: Uri of KeyVault. :type key_vault_uri: str """ @@ -646,18 +626,20 @@ class KeyVaultProperties(Model): 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, } - def __init__(self, **kwargs): + 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) -class MetricName(Model): +class MetricName(msrest.serialization.Model): """A metric name. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The name of the metric. :vartype value: str @@ -675,25 +657,26 @@ class MetricName(Model): 'localized_value': {'key': 'localizedValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(MetricName, self).__init__(**kwargs) self.value = None self.localized_value = None -class NetworkRuleSet(Model): +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 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] + :type virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] """ _attribute_map = { @@ -702,20 +685,22 @@ class NetworkRuleSet(Model): 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, } - def __init__(self, **kwargs): + 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 OperationDisplayInfo(Model): +class OperationDisplayInfo(msrest.serialization.Model): """The operation supported by Cognitive Services. :param description: The description of the operation. :type description: str - :param operation: The action that users can perform, based on their - permission level. + :param operation: The action that users can perform, based on their permission level. :type operation: str :param provider: Service provider: Microsoft Cognitive Services. :type provider: str @@ -730,7 +715,10 @@ class OperationDisplayInfo(Model): 'resource': {'key': 'resource', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplayInfo, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.operation = kwargs.get('operation', None) @@ -738,7 +726,7 @@ def __init__(self, **kwargs): self.resource = kwargs.get('resource', None) -class OperationEntity(Model): +class OperationEntity(msrest.serialization.Model): """The operation supported by Cognitive Services. :param name: Operation name: {provider}/{resource}/{operation}. @@ -758,7 +746,10 @@ class OperationEntity(Model): 'properties': {'key': 'properties', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationEntity, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -766,13 +757,35 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class PrivateEndpoint(Model): +class OperationEntityListResult(msrest.serialization.Model): + """The list of cognitive services accounts operation response. + + :param next_link: The link used to get the next page of operations. + :type next_link: str + :param value: The list of operations. + :type value: list[~azure.mgmt.cognitiveservices.models.OperationEntity] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[OperationEntity]'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationEntityListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', 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. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ARM identifier for Private Endpoint + :ivar id: The ARM identifier for Private Endpoint. :vartype id: str """ @@ -784,28 +797,66 @@ class PrivateEndpoint(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateEndpoint, self).__init__(**kwargs) self.id = None +class Resource(msrest.serialization.Model): + """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. Ex- 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 PrivateEndpointConnection(Resource): """The Private Endpoint Connection resource. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. :vartype type: str :param properties: Resource properties. - :type properties: - ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties """ _validation = { @@ -821,22 +872,42 @@ class PrivateEndpointConnection(Resource): 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateEndpointConnection, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) -class PrivateEndpointConnectionProperties(Model): +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. 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_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 :param group_ids: The private link resource group ids. @@ -853,30 +924,31 @@ class PrivateEndpointConnectionProperties(Model): 'group_ids': {'key': 'groupIds', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) + self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] 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. + 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} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. :vartype type: str :param properties: Resource properties. - :type properties: - ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties """ _validation = { @@ -892,33 +964,37 @@ class PrivateLinkResource(Resource): 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateLinkResource, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) -class PrivateLinkResourceListResult(Model): +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] + :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): + def __init__( + self, + **kwargs + ): super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class PrivateLinkResourceProperties(Model): +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. + 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 @@ -926,8 +1002,7 @@ class PrivateLinkResourceProperties(Model): :vartype display_name: 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. + :param required_zone_names: The private link resource Private link DNS zone name. :type required_zone_names: list[str] """ @@ -944,7 +1019,10 @@ class PrivateLinkResourceProperties(Model): 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateLinkResourceProperties, self).__init__(**kwargs) self.group_id = None self.display_name = None @@ -952,19 +1030,17 @@ def __init__(self, **kwargs): self.required_zone_names = kwargs.get('required_zone_names', None) -class PrivateLinkServiceConnectionState(Model): - """A collection of information about the state of the connection between - service consumer and provider. +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', 'Disconnected' + :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". :type status: str or ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus :param description: The reason for approval/rejection of the connection. :type description: str - :param action_required: A message indicating if changes on the service - provider require any updates on the consumer. + :param action_required: A message indicating if changes on the service provider require any + updates on the consumer. :type action_required: str """ @@ -974,53 +1050,23 @@ class PrivateLinkServiceConnectionState(Model): 'action_required': {'key': 'actionRequired', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.description = kwargs.get('description', None) self.action_required = kwargs.get('action_required', None) -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - 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 RegenerateKeyParameters(Model): +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' + :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 """ @@ -1029,19 +1075,21 @@ class RegenerateKeyParameters(Model): } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'KeyName'}, + 'key_name': {'key': 'keyName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RegenerateKeyParameters, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) + self.key_name = kwargs['key_name'] -class ResourceSku(Model): +class ResourceSku(msrest.serialization.Model): """Describes an available Cognitive Services SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str @@ -1053,10 +1101,9 @@ class ResourceSku(Model): :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. - :vartype restrictions: - list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] """ _validation = { @@ -1077,7 +1124,10 @@ class ResourceSku(Model): 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceSku, self).__init__(**kwargs) self.resource_type = None self.name = None @@ -1087,13 +1137,12 @@ def __init__(self, **kwargs): self.restrictions = None -class ResourceSkuRestrictionInfo(Model): +class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ResourceSkuRestrictionInfo. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar locations: Locations where the SKU is restricted + :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] @@ -1109,31 +1158,29 @@ class ResourceSkuRestrictionInfo(Model): 'zones': {'key': 'zones', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) self.locations = None self.zones = None -class ResourceSkuRestrictions(Model): +class ResourceSkuRestrictions(msrest.serialization.Model): """Describes restrictions of a SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :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. + :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' + :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". :vartype reason_code: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode """ @@ -1146,13 +1193,16 @@ class ResourceSkuRestrictions(Model): } _attribute_map = { - 'type': {'key': 'type', 'type': 'ResourceSkuRestrictionsType'}, + '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): + def __init__( + self, + **kwargs + ): super(ResourceSkuRestrictions, self).__init__(**kwargs) self.type = None self.values = None @@ -1160,19 +1210,47 @@ def __init__(self, **kwargs): self.reason_code = None -class Sku(Model): +class ResourceSkusResult(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(ResourceSkusResult, self).__init__(**kwargs) + self.value = kwargs['value'] + self.next_link = kwargs.get('next_link', None) + + +class Sku(msrest.serialization.Model): """The SKU of the cognitive services account. - Variables are only populated by the server, and will be ignored when - sending a request. + 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 name: Required. Gets or sets the sku name. Required for account - creation, optional for update. + :param name: Required. Gets or sets the sku name. Required for account creation, optional for + update. :type name: str - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible - values include: 'Free', 'Standard', 'Premium' + :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: "Free", + "Standard", "Premium". :vartype tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier """ @@ -1183,16 +1261,19 @@ class Sku(Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'SkuTier'}, + 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.tier = None -class SkuCapability(Model): +class SkuCapability(msrest.serialization.Model): """SkuCapability indicates the capability of a certain feature. :param name: The name of the SkuCapability. @@ -1206,65 +1287,23 @@ class SkuCapability(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SkuCapability, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - 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. - - :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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - - -class Usage(Model): +class Usage(msrest.serialization.Model): """The usage data for a usage request. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a 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 + :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "Percent", "CountPerSecond", "BytesPerSecond", "Milliseconds". + :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. @@ -1275,12 +1314,13 @@ class Usage(Model): :vartype current_value: float :ivar next_reset_time: Next reset time for current quota. :vartype next_reset_time: str - :param status: Cognitive Services account quota usage status. Possible - values include: 'Included', 'Blocked', 'InOverage', 'Unknown' + :param status: Cognitive Services account quota usage status. Possible values include: + "Included", "Blocked", "InOverage", "Unknown". :type status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus """ _validation = { + 'unit': {'readonly': True}, 'name': {'readonly': True}, 'quota_period': {'readonly': True}, 'limit': {'readonly': True}, @@ -1298,9 +1338,12 @@ class Usage(Model): 'status': {'key': 'status', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Usage, self).__init__(**kwargs) - self.unit = kwargs.get('unit', None) + self.unit = None self.name = None self.quota_period = None self.limit = None @@ -1309,11 +1352,10 @@ def __init__(self, **kwargs): self.status = kwargs.get('status', None) -class UsagesResult(Model): +class UsagesResult(msrest.serialization.Model): """The response to a list usage request. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of usages for Cognitive Service account. :vartype value: list[~azure.mgmt.cognitiveservices.models.Usage] @@ -1327,16 +1369,18 @@ class UsagesResult(Model): 'value': {'key': 'value', 'type': '[Usage]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UsagesResult, self).__init__(**kwargs) self.value = None -class UserAssignedIdentity(Model): +class UserAssignedIdentity(msrest.serialization.Model): """User-assigned managed identity. - :param principal_id: Azure Active Directory principal ID associated with - this Identity. + :param principal_id: Azure Active Directory principal ID associated with this Identity. :type principal_id: str :param client_id: Client App Id associated with this identity. :type client_id: str @@ -1347,13 +1391,16 @@ class UserAssignedIdentity(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = kwargs.get('principal_id', None) self.client_id = kwargs.get('client_id', None) -class UserOwnedStorage(Model): +class UserOwnedStorage(msrest.serialization.Model): """The user owned storage for Cognitive Services account. :param resource_id: Full resource id of a Microsoft.Storage resource. @@ -1364,23 +1411,26 @@ class UserOwnedStorage(Model): 'resource_id': {'key': 'resourceId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserOwnedStorage, self).__init__(**kwargs) self.resource_id = kwargs.get('resource_id', None) -class VirtualNetworkRule(Model): +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'. + '/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. + :param ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. :type ignore_missing_vnet_service_endpoint: bool """ @@ -1394,8 +1444,11 @@ class VirtualNetworkRule(Model): 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(VirtualNetworkRule, self).__init__(**kwargs) - self.id = kwargs.get('id', None) + 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 93ca8d941d8b..ced585a03d62 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 @@ -1,92 +1,20 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): - """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. Ex- - 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) -> None: - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AzureEntityResource(Resource): - """The resource model definition for a 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. Ex- - 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) -> None: - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None +from ._cognitive_services_management_client_enums import * -class CheckDomainAvailabilityParameter(Model): +class CheckDomainAvailabilityParameter(msrest.serialization.Model): """Check Domain availability parameter. All required parameters must be populated in order to send to Azure. @@ -107,17 +35,22 @@ class CheckDomainAvailabilityParameter(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, subdomain_name: str, type: str, **kwargs) -> None: + def __init__( + self, + *, + subdomain_name: str, + type: str, + **kwargs + ): super(CheckDomainAvailabilityParameter, self).__init__(**kwargs) self.subdomain_name = subdomain_name self.type = type -class CheckDomainAvailabilityResult(Model): +class CheckDomainAvailabilityResult(msrest.serialization.Model): """Check Domain availability result. - :param is_subdomain_available: Indicates the given SKU is available or - not. + :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 @@ -134,7 +67,15 @@ class CheckDomainAvailabilityResult(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, is_subdomain_available: bool=None, reason: str=None, subdomain_name: str=None, type: str=None, **kwargs) -> None: + def __init__( + self, + *, + is_subdomain_available: Optional[bool] = None, + reason: Optional[str] = None, + subdomain_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): super(CheckDomainAvailabilityResult, self).__init__(**kwargs) self.is_subdomain_available = is_subdomain_available self.reason = reason @@ -142,7 +83,7 @@ def __init__(self, *, is_subdomain_available: bool=None, reason: str=None, subdo self.type = type -class CheckSkuAvailabilityParameter(Model): +class CheckSkuAvailabilityParameter(msrest.serialization.Model): """Check SKU availability parameter. All required parameters must be populated in order to send to Azure. @@ -167,14 +108,21 @@ class CheckSkuAvailabilityParameter(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, skus, kind: str, type: str, **kwargs) -> None: + def __init__( + self, + *, + skus: List[str], + kind: str, + type: str, + **kwargs + ): super(CheckSkuAvailabilityParameter, self).__init__(**kwargs) self.skus = skus self.kind = kind self.type = type -class CheckSkuAvailabilityResult(Model): +class CheckSkuAvailabilityResult(msrest.serialization.Model): """Check SKU availability result. :param kind: The Kind of the resource. @@ -200,7 +148,17 @@ class CheckSkuAvailabilityResult(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, kind: str=None, type: str=None, sku_name: str=None, sku_available: bool=None, reason: str=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + kind: Optional[str] = None, + type: Optional[str] = None, + sku_name: Optional[str] = None, + sku_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): super(CheckSkuAvailabilityResult, self).__init__(**kwargs) self.kind = kind self.type = type @@ -210,60 +168,52 @@ def __init__(self, *, kind: str=None, type: str=None, sku_name: str=None, sku_av self.message = message -class CheckSkuAvailabilityResultList(Model): +class CheckSkuAvailabilityResultList(msrest.serialization.Model): """Check SKU availability result list. :param value: Check SKU availability result list. - :type value: - list[~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResult] + :type value: list[~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResult] """ _attribute_map = { 'value': {'key': 'value', 'type': '[CheckSkuAvailabilityResult]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["CheckSkuAvailabilityResult"]] = None, + **kwargs + ): super(CheckSkuAvailabilityResultList, self).__init__(**kwargs) self.value = value -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class CognitiveServicesAccount(Model): - """Cognitive Services Account is an Azure resource representing the - provisioned account, its type, location and SKU. +class CognitiveServicesAccount(msrest.serialization.Model): + """Cognitive Services Account is an Azure resource representing the provisioned account, its type, location and SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar etag: Entity Tag + :ivar etag: Entity Tag. :vartype etag: str - :ivar id: The id of the created account + :ivar id: The id of the created account. :vartype id: str :param kind: The Kind of the resource. :type kind: str - :param location: The location of the resource + :param location: The location of the resource. :type location: str - :ivar name: The name of the created account + :ivar name: The name of the created account. :vartype name: str :param properties: Properties of Cognitive Services account. - :type properties: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountProperties + :type properties: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountProperties :param sku: The SKU of Cognitive Services account. :type sku: ~azure.mgmt.cognitiveservices.models.Sku - :param tags: Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource - (across resource groups). A maximum of 15 tags can be provided for a - resource. Each tag must have a key no greater than 128 characters and - value no greater than 256 characters. + :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + These tags can be used in viewing and grouping this resource (across resource groups). A + maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 + characters and value no greater than 256 characters. :type tags: dict[str, str] - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str :param identity: The identity of Cognitive Services account. :type identity: ~azure.mgmt.cognitiveservices.models.Identity @@ -289,7 +239,17 @@ class CognitiveServicesAccount(Model): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, kind: str=None, location: str=None, properties=None, sku=None, tags=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + kind: Optional[str] = None, + location: Optional[str] = None, + properties: Optional["CognitiveServicesAccountProperties"] = None, + sku: Optional["Sku"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(CognitiveServicesAccount, self).__init__(**kwargs) self.etag = None self.id = None @@ -303,26 +263,36 @@ def __init__(self, *, kind: str=None, location: str=None, properties=None, sku=N self.identity = identity -class CognitiveServicesAccountApiProperties(Model): +class CognitiveServicesAccountApiProperties(msrest.serialization.Model): """The api properties for special APIs. - :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of - QnAMaker. + :param qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. :type qna_runtime_endpoint: str - :param statistics_enabled: (Bing Search Only) The flag to enable - statistics of Bing Search. + :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. + :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. + :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, 'pattern': r'^( *)Endpoint=sb://(.*);( *)SharedAccessKeyName=(.*);( *)SharedAccessKey=(.*)$'}, - 'storage_account_connection_string': {'max_length': 1000, 'pattern': r'^(( *)DefaultEndpointsProtocol=(http|https)( *);( *))?AccountName=(.*)AccountKey=(.*)EndpointSuffix=(.*)$'}, + '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 = { @@ -330,26 +300,43 @@ class CognitiveServicesAccountApiProperties(Model): 'statistics_enabled': {'key': 'statisticsEnabled', 'type': 'bool'}, 'event_hub_connection_string': {'key': 'eventHubConnectionString', 'type': 'str'}, 'storage_account_connection_string': {'key': 'storageAccountConnectionString', 'type': 'str'}, - } - - def __init__(self, *, qna_runtime_endpoint: str=None, statistics_enabled: bool=None, event_hub_connection_string: str=None, storage_account_connection_string: str=None, **kwargs) -> None: + '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, + *, + qna_runtime_endpoint: Optional[str] = None, + statistics_enabled: Optional[bool] = None, + event_hub_connection_string: Optional[str] = None, + storage_account_connection_string: Optional[str] = None, + aad_client_id: Optional[str] = None, + aad_tenant_id: Optional[str] = None, + super_user: Optional[str] = None, + website_name: Optional[str] = None, + **kwargs + ): super(CognitiveServicesAccountApiProperties, self).__init__(**kwargs) self.qna_runtime_endpoint = qna_runtime_endpoint self.statistics_enabled = statistics_enabled self.event_hub_connection_string = event_hub_connection_string self.storage_account_connection_string = storage_account_connection_string + self.aad_client_id = aad_client_id + self.aad_tenant_id = aad_tenant_id + self.super_user = super_user + self.website_name = website_name -class CognitiveServicesAccountEnumerateSkusResult(Model): +class CognitiveServicesAccountEnumerateSkusResult(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. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Gets the list of Cognitive Services accounts and their - properties. - :vartype value: - list[~azure.mgmt.cognitiveservices.models.CognitiveServicesResourceAndSku] + :ivar value: Gets the list of Cognitive Services accounts and their properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.CognitiveServicesResourceAndSku] """ _validation = { @@ -360,12 +347,15 @@ class CognitiveServicesAccountEnumerateSkusResult(Model): 'value': {'key': 'value', 'type': '[CognitiveServicesResourceAndSku]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(CognitiveServicesAccountEnumerateSkusResult, self).__init__(**kwargs) self.value = None -class CognitiveServicesAccountKeys(Model): +class CognitiveServicesAccountKeys(msrest.serialization.Model): """The access keys for the cognitive services account. :param key1: Gets the value of key 1. @@ -379,52 +369,83 @@ class CognitiveServicesAccountKeys(Model): 'key2': {'key': 'key2', 'type': 'str'}, } - def __init__(self, *, key1: str=None, key2: str=None, **kwargs) -> None: + def __init__( + self, + *, + key1: Optional[str] = None, + key2: Optional[str] = None, + **kwargs + ): super(CognitiveServicesAccountKeys, self).__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class CognitiveServicesAccountProperties(Model): +class CognitiveServicesAccountListResult(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.CognitiveServicesAccount] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[CognitiveServicesAccount]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(CognitiveServicesAccountListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = None + + +class CognitiveServicesAccountProperties(msrest.serialization.Model): """Properties of Cognitive Services account. - Variables are only populated by the server, and will be ignored when - sending a request. + 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: - 'Creating', 'ResolvingDNS', 'Moving', 'Deleting', 'Succeeded', 'Failed' - :vartype provisioning_state: str or - ~azure.mgmt.cognitiveservices.models.ProvisioningState + :ivar provisioning_state: Gets the status of the cognitive services account at the time the + operation was called. Possible values include: "Creating", "ResolvingDNS", "Moving", + "Deleting", "Succeeded", "Failed". + :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. :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] - :param custom_sub_domain_name: Optional subdomain name used for - token-based authentication. + :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] + :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. + :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] - :param private_endpoint_connections: The private endpoint connection - associated with the Cognitive Services account. + :type user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] + :param private_endpoint_connections: The private endpoint connection associated with the + Cognitive Services account. :type 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 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.CognitiveServicesAccountApiProperties @@ -451,7 +472,18 @@ class CognitiveServicesAccountProperties(Model): 'api_properties': {'key': 'apiProperties', 'type': 'CognitiveServicesAccountApiProperties'}, } - def __init__(self, *, custom_sub_domain_name: str=None, network_acls=None, encryption=None, user_owned_storage=None, private_endpoint_connections=None, public_network_access=None, api_properties=None, **kwargs) -> None: + def __init__( + self, + *, + custom_sub_domain_name: Optional[str] = None, + network_acls: Optional["NetworkRuleSet"] = None, + encryption: Optional["Encryption"] = None, + user_owned_storage: Optional[List["UserOwnedStorage"]] = None, + private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, + public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + api_properties: Optional["CognitiveServicesAccountApiProperties"] = None, + **kwargs + ): super(CognitiveServicesAccountProperties, self).__init__(**kwargs) self.provisioning_state = None self.endpoint = None @@ -466,10 +498,10 @@ def __init__(self, *, custom_sub_domain_name: str=None, network_acls=None, encry self.api_properties = api_properties -class CognitiveServicesResourceAndSku(Model): +class CognitiveServicesResourceAndSku(msrest.serialization.Model): """Cognitive Services resource type and SKU. - :param resource_type: Resource Namespace and Type + :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 @@ -480,21 +512,26 @@ class CognitiveServicesResourceAndSku(Model): 'sku': {'key': 'sku', 'type': 'Sku'}, } - def __init__(self, *, resource_type: str=None, sku=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + sku: Optional["Sku"] = None, + **kwargs + ): super(CognitiveServicesResourceAndSku, self).__init__(**kwargs) self.resource_type = resource_type self.sku = sku -class Encryption(Model): +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" . + :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 """ @@ -503,13 +540,19 @@ class Encryption(Model): 'key_source': {'key': 'keySource', 'type': 'str'}, } - def __init__(self, *, key_vault_properties=None, key_source="Microsoft.KeyVault", **kwargs) -> None: + def __init__( + self, + *, + key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Optional[Union[str, "KeySource"]] = "Microsoft.KeyVault", + **kwargs + ): super(Encryption, self).__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source -class Error(Model): +class Error(msrest.serialization.Model): """Cognitive Services error object. :param error: The error body. @@ -520,31 +563,24 @@ class Error(Model): 'error': {'key': 'error', 'type': 'ErrorBody'}, } - def __init__(self, *, error=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorBody"] = None, + **kwargs + ): super(Error, self).__init__(**kwargs) self.error = error -class ErrorException(HttpOperationError): - """Server responsed with exception of type: 'Error'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorException, self).__init__(deserialize, response, 'Error', *args) - - -class ErrorBody(Model): +class ErrorBody(msrest.serialization.Model): """Cognitive Services error body. All required parameters must be populated in order to send to Azure. - :param code: Required. error code + :param code: Required. error code. :type code: str - :param message: Required. error message + :param message: Required. error message. :type message: str """ @@ -558,29 +594,33 @@ class ErrorBody(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, code: str, message: str, **kwargs) -> None: + def __init__( + self, + *, + code: str, + message: str, + **kwargs + ): super(ErrorBody, self).__init__(**kwargs) self.code = code self.message = message -class Identity(Model): +class Identity(msrest.serialization.Model): """Managed service identity. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of managed service identity. Possible values include: - 'None', 'SystemAssigned', 'UserAssigned' + :param type: Type of managed service identity. Possible values include: "None", + "SystemAssigned", "UserAssigned". :type type: str or ~azure.mgmt.cognitiveservices.models.IdentityType :ivar tenant_id: Tenant of managed service identity. :vartype tenant_id: str :ivar principal_id: Principal Id of managed service 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} + :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] """ @@ -591,13 +631,19 @@ class Identity(Model): } _attribute_map = { - 'type': {'key': 'type', 'type': 'IdentityType'}, + '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, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "IdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.type = type self.tenant_id = None @@ -605,14 +651,13 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IpRule(Model): +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). + :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 """ @@ -624,19 +669,24 @@ class IpRule(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, value: str, **kwargs) -> None: + def __init__( + self, + *, + value: str, + **kwargs + ): super(IpRule, self).__init__(**kwargs) self.value = value -class KeyVaultProperties(Model): +class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault + :param key_name: Name of the Key from KeyVault. :type key_name: str - :param key_version: Version of the Key from KeyVault + :param key_version: Version of the Key from KeyVault. :type key_version: str - :param key_vault_uri: Uri of KeyVault + :param key_vault_uri: Uri of KeyVault. :type key_vault_uri: str """ @@ -646,18 +696,24 @@ class KeyVaultProperties(Model): 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, } - def __init__(self, *, key_name: str=None, key_version: str=None, key_vault_uri: str=None, **kwargs) -> None: + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + **kwargs + ): super(KeyVaultProperties, self).__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class MetricName(Model): +class MetricName(msrest.serialization.Model): """A metric name. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The name of the metric. :vartype value: str @@ -675,25 +731,26 @@ class MetricName(Model): 'localized_value': {'key': 'localizedValue', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(MetricName, self).__init__(**kwargs) self.value = None self.localized_value = None -class NetworkRuleSet(Model): +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 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] + :type virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] """ _attribute_map = { @@ -702,20 +759,26 @@ class NetworkRuleSet(Model): 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, } - def __init__(self, *, default_action=None, ip_rules=None, virtual_network_rules=None, **kwargs) -> None: + def __init__( + self, + *, + default_action: Optional[Union[str, "NetworkRuleAction"]] = None, + ip_rules: Optional[List["IpRule"]] = None, + virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, + **kwargs + ): super(NetworkRuleSet, self).__init__(**kwargs) self.default_action = default_action self.ip_rules = ip_rules self.virtual_network_rules = virtual_network_rules -class OperationDisplayInfo(Model): +class OperationDisplayInfo(msrest.serialization.Model): """The operation supported by Cognitive Services. :param description: The description of the operation. :type description: str - :param operation: The action that users can perform, based on their - permission level. + :param operation: The action that users can perform, based on their permission level. :type operation: str :param provider: Service provider: Microsoft Cognitive Services. :type provider: str @@ -730,7 +793,15 @@ class OperationDisplayInfo(Model): 'resource': {'key': 'resource', 'type': 'str'}, } - def __init__(self, *, description: str=None, operation: str=None, provider: str=None, resource: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + operation: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + **kwargs + ): super(OperationDisplayInfo, self).__init__(**kwargs) self.description = description self.operation = operation @@ -738,7 +809,7 @@ def __init__(self, *, description: str=None, operation: str=None, provider: str= self.resource = resource -class OperationEntity(Model): +class OperationEntity(msrest.serialization.Model): """The operation supported by Cognitive Services. :param name: Operation name: {provider}/{resource}/{operation}. @@ -758,7 +829,15 @@ class OperationEntity(Model): 'properties': {'key': 'properties', 'type': 'object'}, } - def __init__(self, *, name: str=None, display=None, origin: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplayInfo"] = None, + origin: Optional[str] = None, + properties: Optional[object] = None, + **kwargs + ): super(OperationEntity, self).__init__(**kwargs) self.name = name self.display = display @@ -766,13 +845,38 @@ def __init__(self, *, name: str=None, display=None, origin: str=None, properties self.properties = properties -class PrivateEndpoint(Model): +class OperationEntityListResult(msrest.serialization.Model): + """The list of cognitive services accounts operation response. + + :param next_link: The link used to get the next page of operations. + :type next_link: str + :param value: The list of operations. + :type value: list[~azure.mgmt.cognitiveservices.models.OperationEntity] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[OperationEntity]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["OperationEntity"]] = None, + **kwargs + ): + super(OperationEntityListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class PrivateEndpoint(msrest.serialization.Model): """The Private Endpoint resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ARM identifier for Private Endpoint + :ivar id: The ARM identifier for Private Endpoint. :vartype id: str """ @@ -784,28 +888,66 @@ class PrivateEndpoint(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(PrivateEndpoint, self).__init__(**kwargs) self.id = None +class Resource(msrest.serialization.Model): + """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. Ex- 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 PrivateEndpointConnection(Resource): """The Private Endpoint Connection resource. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. :vartype type: str :param properties: Resource properties. - :type properties: - ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties """ _validation = { @@ -821,22 +963,46 @@ class PrivateEndpointConnection(Resource): 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["PrivateEndpointConnectionProperties"] = None, + **kwargs + ): super(PrivateEndpointConnection, self).__init__(**kwargs) self.properties = properties -class PrivateEndpointConnectionProperties(Model): +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, + *, + value: Optional[List["PrivateEndpointConnection"]] = None, + **kwargs + ): + super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateEndpointConnectionProperties(msrest.serialization.Model): """Properties of the PrivateEndpointConnectProperties. 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_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 :param group_ids: The private link resource group ids. @@ -853,7 +1019,14 @@ class PrivateEndpointConnectionProperties(Model): 'group_ids': {'key': 'groupIds', 'type': '[str]'}, } - def __init__(self, *, private_link_service_connection_state, private_endpoint=None, group_ids=None, **kwargs) -> None: + def __init__( + self, + *, + private_link_service_connection_state: "PrivateLinkServiceConnectionState", + private_endpoint: Optional["PrivateEndpoint"] = None, + group_ids: Optional[List[str]] = None, + **kwargs + ): super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -863,20 +1036,18 @@ def __init__(self, *, private_link_service_connection_state, private_endpoint=No class PrivateLinkResource(Resource): """A private link resource. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: The name of the resource + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. :vartype type: str :param properties: Resource properties. - :type properties: - ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties """ _validation = { @@ -892,33 +1063,41 @@ class PrivateLinkResource(Resource): 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["PrivateLinkResourceProperties"] = None, + **kwargs + ): super(PrivateLinkResource, self).__init__(**kwargs) self.properties = properties -class PrivateLinkResourceListResult(Model): +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] + :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, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["PrivateLinkResource"]] = None, + **kwargs + ): super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = value -class PrivateLinkResourceProperties(Model): +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. + 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 @@ -926,8 +1105,7 @@ class PrivateLinkResourceProperties(Model): :vartype display_name: 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. + :param required_zone_names: The private link resource Private link DNS zone name. :type required_zone_names: list[str] """ @@ -944,7 +1122,12 @@ class PrivateLinkResourceProperties(Model): 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, } - def __init__(self, *, required_zone_names=None, **kwargs) -> None: + def __init__( + self, + *, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): super(PrivateLinkResourceProperties, self).__init__(**kwargs) self.group_id = None self.display_name = None @@ -952,19 +1135,17 @@ def __init__(self, *, required_zone_names=None, **kwargs) -> None: self.required_zone_names = required_zone_names -class PrivateLinkServiceConnectionState(Model): - """A collection of information about the state of the connection between - service consumer and provider. +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', 'Disconnected' + :param status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". :type status: str or ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus :param description: The reason for approval/rejection of the connection. :type description: str - :param action_required: A message indicating if changes on the service - provider require any updates on the consumer. + :param action_required: A message indicating if changes on the service provider require any + updates on the consumer. :type action_required: str """ @@ -974,53 +1155,27 @@ class PrivateLinkServiceConnectionState(Model): 'action_required': {'key': 'actionRequired', 'type': 'str'}, } - def __init__(self, *, status=None, description: str=None, action_required: str=None, **kwargs) -> None: + def __init__( + self, + *, + status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + action_required: Optional[str] = None, + **kwargs + ): super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - 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) -> None: - super(ProxyResource, self).__init__(**kwargs) - - -class RegenerateKeyParameters(Model): +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' + :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 """ @@ -1029,19 +1184,23 @@ class RegenerateKeyParameters(Model): } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'KeyName'}, + 'key_name': {'key': 'keyName', 'type': 'str'}, } - def __init__(self, *, key_name, **kwargs) -> None: + def __init__( + self, + *, + key_name: Union[str, "KeyName"], + **kwargs + ): super(RegenerateKeyParameters, self).__init__(**kwargs) self.key_name = key_name -class ResourceSku(Model): +class ResourceSku(msrest.serialization.Model): """Describes an available Cognitive Services SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str @@ -1053,10 +1212,9 @@ class ResourceSku(Model): :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. - :vartype restrictions: - list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] """ _validation = { @@ -1077,7 +1235,10 @@ class ResourceSku(Model): 'restrictions': {'key': 'restrictions', 'type': '[ResourceSkuRestrictions]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceSku, self).__init__(**kwargs) self.resource_type = None self.name = None @@ -1087,13 +1248,12 @@ def __init__(self, **kwargs) -> None: self.restrictions = None -class ResourceSkuRestrictionInfo(Model): +class ResourceSkuRestrictionInfo(msrest.serialization.Model): """ResourceSkuRestrictionInfo. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar locations: Locations where the SKU is restricted + :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] @@ -1109,31 +1269,29 @@ class ResourceSkuRestrictionInfo(Model): 'zones': {'key': 'zones', 'type': '[str]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceSkuRestrictionInfo, self).__init__(**kwargs) self.locations = None self.zones = None -class ResourceSkuRestrictions(Model): +class ResourceSkuRestrictions(msrest.serialization.Model): """Describes restrictions of a SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :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. + :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' + :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". :vartype reason_code: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode """ @@ -1146,13 +1304,16 @@ class ResourceSkuRestrictions(Model): } _attribute_map = { - 'type': {'key': 'type', 'type': 'ResourceSkuRestrictionsType'}, + '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) -> None: + def __init__( + self, + **kwargs + ): super(ResourceSkuRestrictions, self).__init__(**kwargs) self.type = None self.values = None @@ -1160,19 +1321,50 @@ def __init__(self, **kwargs) -> None: self.reason_code = None -class Sku(Model): +class ResourceSkusResult(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, + *, + value: List["ResourceSku"], + next_link: Optional[str] = None, + **kwargs + ): + super(ResourceSkusResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Sku(msrest.serialization.Model): """The SKU of the cognitive services account. - Variables are only populated by the server, and will be ignored when - sending a request. + 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 name: Required. Gets or sets the sku name. Required for account - creation, optional for update. + :param name: Required. Gets or sets the sku name. Required for account creation, optional for + update. :type name: str - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible - values include: 'Free', 'Standard', 'Premium' + :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: "Free", + "Standard", "Premium". :vartype tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier """ @@ -1183,16 +1375,21 @@ class Sku(Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'SkuTier'}, + 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, **kwargs) -> None: + def __init__( + self, + *, + name: str, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = None -class SkuCapability(Model): +class SkuCapability(msrest.serialization.Model): """SkuCapability indicates the capability of a certain feature. :param name: The name of the SkuCapability. @@ -1206,65 +1403,26 @@ class SkuCapability(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, name: str=None, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): super(SkuCapability, self).__init__(**kwargs) self.name = name self.value = value -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - 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. - - :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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__(self, *, location: str, tags=None, **kwargs) -> None: - super(TrackedResource, self).__init__(**kwargs) - self.tags = tags - self.location = location - - -class Usage(Model): +class Usage(msrest.serialization.Model): """The usage data for a usage request. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a 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 + :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "Percent", "CountPerSecond", "BytesPerSecond", "Milliseconds". + :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. @@ -1275,12 +1433,13 @@ class Usage(Model): :vartype current_value: float :ivar next_reset_time: Next reset time for current quota. :vartype next_reset_time: str - :param status: Cognitive Services account quota usage status. Possible - values include: 'Included', 'Blocked', 'InOverage', 'Unknown' + :param status: Cognitive Services account quota usage status. Possible values include: + "Included", "Blocked", "InOverage", "Unknown". :type status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus """ _validation = { + 'unit': {'readonly': True}, 'name': {'readonly': True}, 'quota_period': {'readonly': True}, 'limit': {'readonly': True}, @@ -1298,9 +1457,14 @@ class Usage(Model): 'status': {'key': 'status', 'type': 'str'}, } - def __init__(self, *, unit=None, status=None, **kwargs) -> None: + def __init__( + self, + *, + status: Optional[Union[str, "QuotaUsageStatus"]] = None, + **kwargs + ): super(Usage, self).__init__(**kwargs) - self.unit = unit + self.unit = None self.name = None self.quota_period = None self.limit = None @@ -1309,11 +1473,10 @@ def __init__(self, *, unit=None, status=None, **kwargs) -> None: self.status = status -class UsagesResult(Model): +class UsagesResult(msrest.serialization.Model): """The response to a list usage request. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of usages for Cognitive Service account. :vartype value: list[~azure.mgmt.cognitiveservices.models.Usage] @@ -1327,16 +1490,18 @@ class UsagesResult(Model): 'value': {'key': 'value', 'type': '[Usage]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(UsagesResult, self).__init__(**kwargs) self.value = None -class UserAssignedIdentity(Model): +class UserAssignedIdentity(msrest.serialization.Model): """User-assigned managed identity. - :param principal_id: Azure Active Directory principal ID associated with - this Identity. + :param principal_id: Azure Active Directory principal ID associated with this Identity. :type principal_id: str :param client_id: Client App Id associated with this identity. :type client_id: str @@ -1347,13 +1512,19 @@ class UserAssignedIdentity(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, *, principal_id: str=None, client_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + **kwargs + ): super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class UserOwnedStorage(Model): +class UserOwnedStorage(msrest.serialization.Model): """The user owned storage for Cognitive Services account. :param resource_id: Full resource id of a Microsoft.Storage resource. @@ -1364,23 +1535,28 @@ class UserOwnedStorage(Model): 'resource_id': {'key': 'resourceId', 'type': 'str'}, } - def __init__(self, *, resource_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_id: Optional[str] = None, + **kwargs + ): super(UserOwnedStorage, self).__init__(**kwargs) self.resource_id = resource_id -class VirtualNetworkRule(Model): +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'. + '/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. + :param ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. :type ignore_missing_vnet_service_endpoint: bool """ @@ -1394,7 +1570,14 @@ class VirtualNetworkRule(Model): 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, } - def __init__(self, *, id: str, state: str=None, ignore_missing_vnet_service_endpoint: bool=None, **kwargs) -> None: + def __init__( + self, + *, + id: str, + state: Optional[str] = None, + ignore_missing_vnet_service_endpoint: Optional[bool] = None, + **kwargs + ): super(VirtualNetworkRule, self).__init__(**kwargs) self.id = id self.state = state diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_paged_models.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_paged_models.py deleted file mode 100644 index 312ad7c70438..000000000000 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class CognitiveServicesAccountPaged(Paged): - """ - A paging container for iterating over a list of :class:`CognitiveServicesAccount ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[CognitiveServicesAccount]'} - } - - def __init__(self, *args, **kwargs): - - super(CognitiveServicesAccountPaged, self).__init__(*args, **kwargs) -class ResourceSkuPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceSku ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceSku]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceSkuPaged, self).__init__(*args, **kwargs) -class OperationEntityPaged(Paged): - """ - A paging container for iterating over a list of :class:`OperationEntity ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[OperationEntity]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationEntityPaged, self).__init__(*args, **kwargs) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py index c5b73fb2d0fc..fee14b0688ba 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py @@ -1,26 +1,23 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._accounts_operations import AccountsOperations from ._resource_skus_operations import ResourceSkusOperations from ._operations import Operations +from ._cognitive_services_management_client_operations import CognitiveServicesManagementClientOperationsMixin from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._cognitive_services_management_client_operations import CognitiveServicesManagementClientOperationsMixin __all__ = [ 'AccountsOperations', 'ResourceSkusOperations', 'Operations', + 'CognitiveServicesManagementClientOperationsMixin', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', - 'CognitiveServicesManagementClientOperationsMixin', ] 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 e7923920621b..10cfb77e24cc 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 @@ -1,697 +1,707 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +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.mgmt.core.exceptions import ARMErrorFormat from .. import 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]] class AccountsOperations(object): """AccountsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-04-18". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-18" - - self.config = config + self._config = config def create( - self, resource_group_name, account_name, account, custom_headers=None, raw=False, **operation_config): - """Create Cognitive Services Account. Accounts is a resource group wide - resource type. It holds the keys for developer to access intelligent - APIs. It's also the resource type for billing. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + account_name, # type: str + account, # type: "models.CognitiveServicesAccount" + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccount" + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str :param account: The parameters to provide for the created account. - :type account: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccount or ClientRawResponse if raw=true + :type account: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccount, or the result of cls(response) :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create.metadata['url'] + url = self.create.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + if response.status_code == 202: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def update( - self, resource_group_name, account_name, account, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + account_name, # type: str + account, # type: "models.CognitiveServicesAccount" + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccount" """Updates a Cognitive Services account. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :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 :param account: The parameters to provide for the created account. - :type account: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccount or ClientRawResponse if raw=true + :type account: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccount, or the result of cls(response) :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(account, 'CognitiveServicesAccount') + 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]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) + if response.status_code == 202: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def delete( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """Deletes a Cognitive Services account from the resource group. . - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + 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 = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def get_properties( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccount" """Returns a Cognitive Services account specified by the parameters. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccount or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccount, or the result of cls(response) :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccount"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.get_properties.metadata['url'] + url = self.get_properties.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccount', response) + deserialized = self._deserialize('CognitiveServicesAccount', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} + get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): - """Returns all the resources of a particular type belonging to a resource - group. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CognitiveServicesAccountListResult"] + """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. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of CognitiveServicesAccount - :rtype: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount] - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CognitiveServicesAccountListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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'] + 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, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + 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) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('CognitiveServicesAccountListResult', 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) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.CognitiveServicesAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Returns all the resources of a particular type belonging to a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of CognitiveServicesAccount - :rtype: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccount] - :raises: - :class:`ErrorException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CognitiveServicesAccountListResult"] + """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 + :return: An iterator like instance of either CognitiveServicesAccountListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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'] + 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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + 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) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('CognitiveServicesAccountListResult', 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) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.CognitiveServicesAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts'} # type: ignore def list_keys( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccountKeys" """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. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccountKeys or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccountKeys, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.list_keys.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountKeys', response) + deserialized = self._deserialize('CognitiveServicesAccountKeys', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'} + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'} # type: ignore def regenerate_key( - self, resource_group_name, account_name, key_name, custom_headers=None, raw=False, **operation_config): - """Regenerates the specified account key for the specified Cognitive - Services account. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + account_name, # type: str + key_name, # type: Union[str, "models.KeyName"] + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccountKeys" + """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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param key_name: key name to generate (Key1|Key2). Possible values - include: 'Key1', 'Key2' + :param key_name: key name to generate (Key1|Key2). :type key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccountKeys or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccountKeys, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountKeys + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.RegenerateKeyParameters(key_name=key_name) + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.RegenerateKeyParameters(key_name=key_name) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.regenerate_key.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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') + + 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]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountKeys', response) + deserialized = self._deserialize('CognitiveServicesAccountKeys', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'} + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'} # type: ignore def list_skus( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CognitiveServicesAccountEnumerateSkusResult" """List available SKUs for the requested Cognitive Services account. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CognitiveServicesAccountEnumerateSkusResult or - ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountEnumerateSkusResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CognitiveServicesAccountEnumerateSkusResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CognitiveServicesAccountEnumerateSkusResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CognitiveServicesAccountEnumerateSkusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.list_skus.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CognitiveServicesAccountEnumerateSkusResult', response) + deserialized = self._deserialize('CognitiveServicesAccountEnumerateSkusResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'} + list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'} # type: ignore def get_usages( - self, resource_group_name, account_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + account_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.UsagesResult" """Get usages for the requested Cognitive Services account. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :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 - :param filter: An OData filter expression that describes a subset of - usages to return. The supported parameter is name.value (name of the - metric, can have an or of multiple names). + :param filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: UsagesResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.cognitiveservices.models.UsagesResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsagesResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.UsagesResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UsagesResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.get_usages.metadata['url'] + url = self.get_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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + 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 = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('UsagesResult', response) + deserialized = self._deserialize('UsagesResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'} + get_usages.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'} # 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 a27dde40b0ef..494bf6212c63 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 @@ -1,24 +1,38 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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.mgmt.core.exceptions import ARMErrorFormat -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError from .. import models -import uuid +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]] class CognitiveServicesManagementClientOperationsMixin(object): def check_sku_availability( - self, location, skus, kind, type, custom_headers=None, raw=False, **operation_config): + self, + location, # type: str + skus, # type: List[str] + kind, # type: str + type, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CheckSkuAvailabilityResultList" """Check available SKUs. :param location: Resource location. @@ -29,129 +43,118 @@ def check_sku_availability( :type kind: str :param type: The Type of the resource. :type type: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CheckSkuAvailabilityResultList or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResultList or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckSkuAvailabilityResultList, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityResultList + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckSkuAvailabilityResultList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.CheckSkuAvailabilityParameter(skus=skus, kind=kind, type=type) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.check_sku_availability.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'CheckSkuAvailabilityParameter') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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') + + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CheckSkuAvailabilityResultList', response) + deserialized = self._deserialize('CheckSkuAvailabilityResultList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - check_sku_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'} + check_sku_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'} # type: ignore def check_domain_availability( - self, subdomain_name, type, custom_headers=None, raw=False, **operation_config): + self, + subdomain_name, # type: str + type, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CheckDomainAvailabilityResult" """Check whether a domain is available. :param subdomain_name: The subdomain name to use. :type subdomain_name: str :param type: The Type of the resource. :type type: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CheckDomainAvailabilityResult or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityResult or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckDomainAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type) + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckDomainAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.CheckDomainAvailabilityParameter(subdomain_name=subdomain_name, type=type) + api_version = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.check_domain_availability.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'CheckDomainAvailabilityParameter') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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') + + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CheckDomainAvailabilityResult', response) + deserialized = self._deserialize('CheckDomainAvailabilityResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - check_domain_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability'} + 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/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py index 9a80a1c0ce81..0c4150889846 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 @@ -1,102 +1,109 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat from .. import 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]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-04-18". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-18" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationEntityListResult"] """Lists all the available Cognitive Services account operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of OperationEntity - :rtype: - ~azure.mgmt.cognitiveservices.models.OperationEntityPaged[~azure.mgmt.cognitiveservices.models.OperationEntity] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationEntityListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.OperationEntityListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationEntityListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + 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) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationEntityListResult', 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) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationEntityPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.CognitiveServices/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CognitiveServices/operations'} # type: ignore 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 13119c1e2715..81acac9093c7 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 @@ -1,242 +1,302 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat from .. import 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]] class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-04-18". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-18" + self._config = config + + def list( + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. + :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: PrivateEndpointConnectionListResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" - self.config = config + # 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, pattern=r'^[-\w\._\(\)]+$'), + '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) - def get( - self, resource_group_name, account_name, private_endpoint_connection_name, custom_headers=None, raw=False, **operation_config): - """Gets the specified private endpoint connection associated with the - Cognitive Services account. + # 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - :param resource_group_name: The name of the resource group. The name - is case insensitive. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections'} # type: ignore + + def get( + self, + resource_group_name, # type: str + account_name, # type: str + private_endpoint_connection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param private_endpoint_connection_name: The name of the private - endpoint connection associated with the Cognitive Services Account + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. :type private_endpoint_connection_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PrivateEndpointConnection or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + 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 = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.get.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', response) + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def create_or_update( - self, resource_group_name, account_name, private_endpoint_connection_name, properties=None, custom_headers=None, raw=False, **operation_config): - """Update the state of 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. + 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" + """Update the state of 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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param private_endpoint_connection_name: The name of the private - endpoint connection associated with the Cognitive Services Account + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. :type private_endpoint_connection_name: str - :param properties: Resource properties. - :type properties: - ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PrivateEndpointConnection or ClientRawResponse if raw=true + :param properties: The private endpoint connection properties. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ - properties1 = models.PrivateEndpointConnection(properties=properties) + 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 = "2017-04-18" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(properties1, 'PrivateEndpointConnection') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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') + + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', response) + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def delete( - self, resource_group_name, account_name, private_endpoint_connection_name, custom_headers=None, raw=False, **operation_config): - """Deletes 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. + self, + resource_group_name, # type: str + account_name, # type: str + private_endpoint_connection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes 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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param private_endpoint_connection_name: The name of the private - endpoint connection associated with the Cognitive Services Account + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. :type private_endpoint_connection_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + 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 = "2017-04-18" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 2830c1d84ffb..db890e19bf56 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 @@ -1,105 +1,104 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat from .. import 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]] class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-04-18". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-18" - - self.config = config + self._config = config def list( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + account_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. :type resource_group_name: str :param account_name: The name of Cognitive Services account. :type account_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PrivateLinkResourceListResult or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult, or the result of cls(response) + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + accept = "application/json" + # Construct URL - url = self.list.metadata['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, pattern=r'^[-\w\._\(\)]+$'), '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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkResourceListResult', response) + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources'} + 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 c90936a27a0f..c43563593e0a 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 @@ -1,107 +1,113 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat from .. import 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]] class ResourceSkusOperations(object): """ResourceSkusOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.cognitiveservices.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-04-18". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-18" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the list of Microsoft.CognitiveServices SKUs available for your - Subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceSku - :rtype: - ~azure.mgmt.cognitiveservices.models.ResourceSkuPaged[~azure.mgmt.cognitiveservices.models.ResourceSku] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceSkusResult"] + """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 ResourceSkusResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSkusResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkusResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-04-18" + 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'] + 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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + 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) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkusResult', 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) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceSkuPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus'} # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/py.typed b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/setup.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/setup.py index def498175553..872e2673dc30 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/setup.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/setup.py @@ -81,8 +81,8 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', ], extras_require={ ":python_version<'3.0'": ['azure-mgmt-nspkg'], diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/recordings/test_cli_mgmt_cognitiveservices.test_cognitiveservices.yaml b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/recordings/test_cli_mgmt_cognitiveservices.test_cognitiveservices.yaml index 9221491535ba..03892d21cdd0 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/recordings/test_cli_mgmt_cognitiveservices.test_cognitiveservices.yaml +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/recordings/test_cli_mgmt_cognitiveservices.test_cognitiveservices.yaml @@ -12,45 +12,40 @@ interactions: Content-Length: - '115' Content-Type: - - application/json; charset=utf-8 + - application/json User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount?api-version=2017-04-18 response: body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount","name":"myAccount","type":"Microsoft.CognitiveServices/accounts","etag":"\"40000ae6-0000-0700-0000-5ed072ee0000\"","location":"West - US","sku":{"name":"S0"},"kind":"CognitiveServices","properties":{"endpoint":"https://westus.api.cognitive.microsoft.com/","internalId":"ee88655b4d5548cb896f7b7ac2d04c28","dateCreated":"2020-05-29T02:26:53.8342065Z","apiProperties":{},"callRateLimit":{"rules":[{"key":"token","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"sts/v1.0/*","method":"*"}]},{"key":"face","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"face/v1.0/*","method":"*"}]},{"key":"vision.recognizeText","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"vision/recognizeText","method":"POST"},{"path":"vision/textOperations/*","method":"GET"},{"path":"vision/read/*","method":"*"}]},{"key":"vision","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"vision/*","method":"*"}]},{"key":"contentModerator.list","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"contentmoderator/lists/*","method":"*"}]},{"key":"contentModerator.moderate","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/moderate/*","method":"*"}]},{"key":"contentModerator.review","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/review/*","method":"*"}]},{"key":"luis.endpoint","renewalPeriod":1,"count":50,"matchPatterns":[{"path":"luis/v2.0/apps/*","method":"*"}]},{"key":"textAnalytics","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"text/analytics/*","method":"*"}]},{"key":"bingVisualSearch","renewalPeriod":1,"count":30,"matchPatterns":[{"path":"bing/v7.0/images/visualsearch/*","method":"*"}]},{"key":"bingSearch","renewalPeriod":1,"count":250,"matchPatterns":[{"path":"bing/*","method":"*"}]},{"key":"bingCustomSearch","renewalPeriod":1,"count":150,"matchPatterns":[{"path":"bingcustomsearch/*","method":"*"}]},{"key":"speech.synthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/synthesize","method":"*"}]},{"key":"speech.customvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/customvoicesynthesize","method":"*"}]},{"key":"speech.neuralvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/neuralvoicesynthesize","method":"*"}]},{"key":"speech.speechtotext","renewalPeriod":10,"count":100,"matchPatterns":[{"path":"speechtotext/*","method":"*"}]},{"key":"customvision.prediction","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/prediction/*","method":"*"}]},{"key":"customvision.training","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/training/*","method":"*"}]},{"key":"default","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"*","method":"*"}]}]},"publicNetworkAccess":"Enabled","provisioningState":"Succeeded"},"identity":{"principalId":"8da3e288-420b-4621-b907-d503aad2b9d0","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"}}' + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount","name":"myAccount","type":"Microsoft.CognitiveServices/accounts","etag":"\"27009e80-0000-0700-0000-5fa104da0000\"","location":"West + US","sku":{"name":"S0"},"kind":"CognitiveServices","properties":{"endpoint":"https://westus.api.cognitive.microsoft.com/","internalId":"19b5914657ea44219d7861debd4194b7","dateCreated":"2020-11-03T07:20:57.4562968Z","apiProperties":{},"callRateLimit":{"rules":[{"key":"token","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"sts/v1.0/*","method":"*"}]},{"key":"face","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"face/v1.0/*","method":"*"}]},{"key":"vision.recognizeText","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"vision/recognizeText","method":"POST"},{"path":"vision/textOperations/*","method":"GET"},{"path":"vision/read/*","method":"*"}]},{"key":"vision","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"vision/*","method":"*"}]},{"key":"contentModerator.list","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"contentmoderator/lists/*","method":"*"}]},{"key":"contentModerator.moderate","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/moderate/*","method":"*"}]},{"key":"contentModerator.review","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/review/*","method":"*"}]},{"key":"luis.endpoint","renewalPeriod":1,"count":50,"matchPatterns":[{"path":"luis/v2.0/apps/*","method":"*"},{"path":"luis/apps/*","method":"*"}]},{"key":"textAnalytics","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"text/analytics/*","method":"*"}]},{"key":"bingVisualSearch","renewalPeriod":1,"count":30,"matchPatterns":[{"path":"bing/v7.0/images/visualsearch/*","method":"*"}]},{"key":"bingSearch","renewalPeriod":1,"count":250,"matchPatterns":[{"path":"bing/*","method":"*"}]},{"key":"bingCustomSearch","renewalPeriod":1,"count":150,"matchPatterns":[{"path":"bingcustomsearch/*","method":"*"}]},{"key":"speech.synthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/synthesize","method":"*"}]},{"key":"speech.customvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/customvoicesynthesize","method":"*"}]},{"key":"speech.neuralvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/neuralvoicesynthesize","method":"*"}]},{"key":"speech.speechtotext","renewalPeriod":10,"count":100,"matchPatterns":[{"path":"speechtotext/*","method":"*"}]},{"key":"customvision.prediction","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/prediction/*","method":"*"}]},{"key":"customvision.training","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/training/*","method":"*"}]},{"key":"formrecognizer.custom.train","renewalPeriod":60,"count":1,"matchPatterns":[{"path":"formrecognizer/custom/train","method":"*"}]},{"key":"formrecognizer.custom.copymodels","renewalPeriod":60,"count":1,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/copy","method":"*"}]},{"key":"formrecognizer.custom.models.get","renewalPeriod":60,"count":10,"matchPatterns":[{"path":"formrecognizer/custom/models","method":"GET"}]},{"key":"formrecognizer.analyzeform","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/analyze","method":"POST"}]},{"key":"formrecognizer.analyzeform.result","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/analyzeResults/{resultId}","method":"GET"}]},{"key":"container.billing","renewalPeriod":10,"count":500,"matchPatterns":[{"path":"billing/*","method":"*"}]},{"key":"default","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"*","method":"*"}]}]},"publicNetworkAccess":"Enabled","capabilities":[{"name":"Container","value":"TextAnalytics.*,TextAnalytics.Keyphrase,TextAnalytics.KeyphraseV2,TextAnalytics.Language,TextAnalytics.LanguageV2,TextAnalytics.Sentiment,TextAnalytics.SentimentV2,TextAnalytics.SentimentV3,TextAnalytics.SentimentV3Preview,SpeechServices.*,ContentModerator.*,Face.*,Face.Face,ComputerVision.*,LUIS.LUIS,FormRecognizer.*,FormRecognizer.Forms,FormRecognizer.FormRecognizerCustomSupervised,FormRecognizer.FormRecognizerReadLayout"}],"provisioningState":"Succeeded"},"identity":{"principalId":"0d6fa302-ffa5-42ac-b780-4cd86d214754","tenantId":"00000000-0000-0000-0000-000000000000","type":"SystemAssigned","userAssignedIdentities":{}}}' headers: cache-control: - no-cache content-length: - - '3143' + - '4575' content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:56 GMT + - Tue, 03 Nov 2020 07:21:00 GMT etag: - - '"40000ae6-0000-0700-0000-5ed072ee0000"' + - '"27009e80-0000-0700-0000-5fa104da0000"' expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff + x-envoy-upstream-service-time: + - '1293' x-ms-ratelimit-remaining-subscription-writes: - - '1199' - x-powered-by: - - ASP.NET + - '1198' status: code: 201 message: Created @@ -64,10 +59,7 @@ interactions: Connection: - keep-alive User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount/usages?api-version=2017-04-18 response: @@ -81,25 +73,23 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:56 GMT + - Tue, 03 Nov 2020 07:21:00 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff - x-powered-by: - - ASP.NET + x-envoy-upstream-service-time: + - '10' status: code: 200 message: OK @@ -113,10 +103,7 @@ interactions: Connection: - keep-alive User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount/skus?api-version=2017-04-18 response: @@ -130,25 +117,23 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:56 GMT + - Tue, 03 Nov 2020 07:21:01 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff - x-powered-by: - - ASP.NET + x-envoy-upstream-service-time: + - '12' status: code: 200 message: OK @@ -162,45 +147,40 @@ interactions: Connection: - keep-alive User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount?api-version=2017-04-18 response: body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount","name":"myAccount","type":"Microsoft.CognitiveServices/accounts","etag":"\"40000ae6-0000-0700-0000-5ed072ee0000\"","location":"West - US","sku":{"name":"S0"},"kind":"CognitiveServices","properties":{"endpoint":"https://westus.api.cognitive.microsoft.com/","internalId":"ee88655b4d5548cb896f7b7ac2d04c28","dateCreated":"2020-05-29T02:26:53.8342065Z","apiProperties":{},"callRateLimit":{"rules":[{"key":"token","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"sts/v1.0/*","method":"*"}]},{"key":"face","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"face/v1.0/*","method":"*"}]},{"key":"vision.recognizeText","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"vision/recognizeText","method":"POST"},{"path":"vision/textOperations/*","method":"GET"},{"path":"vision/read/*","method":"*"}]},{"key":"vision","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"vision/*","method":"*"}]},{"key":"contentModerator.list","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"contentmoderator/lists/*","method":"*"}]},{"key":"contentModerator.moderate","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/moderate/*","method":"*"}]},{"key":"contentModerator.review","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/review/*","method":"*"}]},{"key":"luis.endpoint","renewalPeriod":1,"count":50,"matchPatterns":[{"path":"luis/v2.0/apps/*","method":"*"}]},{"key":"textAnalytics","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"text/analytics/*","method":"*"}]},{"key":"bingVisualSearch","renewalPeriod":1,"count":30,"matchPatterns":[{"path":"bing/v7.0/images/visualsearch/*","method":"*"}]},{"key":"bingSearch","renewalPeriod":1,"count":250,"matchPatterns":[{"path":"bing/*","method":"*"}]},{"key":"bingCustomSearch","renewalPeriod":1,"count":150,"matchPatterns":[{"path":"bingcustomsearch/*","method":"*"}]},{"key":"speech.synthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/synthesize","method":"*"}]},{"key":"speech.customvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/customvoicesynthesize","method":"*"}]},{"key":"speech.neuralvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/neuralvoicesynthesize","method":"*"}]},{"key":"speech.speechtotext","renewalPeriod":10,"count":100,"matchPatterns":[{"path":"speechtotext/*","method":"*"}]},{"key":"customvision.prediction","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/prediction/*","method":"*"}]},{"key":"customvision.training","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/training/*","method":"*"}]},{"key":"default","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"*","method":"*"}]}]},"publicNetworkAccess":"Enabled","provisioningState":"Succeeded"},"identity":{"principalId":"8da3e288-420b-4621-b907-d503aad2b9d0","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"}}' + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount","name":"myAccount","type":"Microsoft.CognitiveServices/accounts","etag":"\"27009e80-0000-0700-0000-5fa104da0000\"","location":"West + US","sku":{"name":"S0"},"kind":"CognitiveServices","properties":{"endpoint":"https://westus.api.cognitive.microsoft.com/","internalId":"19b5914657ea44219d7861debd4194b7","dateCreated":"2020-11-03T07:20:57.4562968Z","apiProperties":{},"callRateLimit":{"rules":[{"key":"token","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"sts/v1.0/*","method":"*"}]},{"key":"face","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"face/v1.0/*","method":"*"}]},{"key":"vision.recognizeText","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"vision/recognizeText","method":"POST"},{"path":"vision/textOperations/*","method":"GET"},{"path":"vision/read/*","method":"*"}]},{"key":"vision","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"vision/*","method":"*"}]},{"key":"contentModerator.list","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"contentmoderator/lists/*","method":"*"}]},{"key":"contentModerator.moderate","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/moderate/*","method":"*"}]},{"key":"contentModerator.review","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"contentmoderator/review/*","method":"*"}]},{"key":"luis.endpoint","renewalPeriod":1,"count":50,"matchPatterns":[{"path":"luis/v2.0/apps/*","method":"*"},{"path":"luis/apps/*","method":"*"}]},{"key":"textAnalytics","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"text/analytics/*","method":"*"}]},{"key":"bingVisualSearch","renewalPeriod":1,"count":30,"matchPatterns":[{"path":"bing/v7.0/images/visualsearch/*","method":"*"}]},{"key":"bingSearch","renewalPeriod":1,"count":250,"matchPatterns":[{"path":"bing/*","method":"*"}]},{"key":"bingCustomSearch","renewalPeriod":1,"count":150,"matchPatterns":[{"path":"bingcustomsearch/*","method":"*"}]},{"key":"speech.synthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/synthesize","method":"*"}]},{"key":"speech.customvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/customvoicesynthesize","method":"*"}]},{"key":"speech.neuralvoicesynthesize","renewalPeriod":1,"count":200,"matchPatterns":[{"path":"speech/neuralvoicesynthesize","method":"*"}]},{"key":"speech.speechtotext","renewalPeriod":10,"count":100,"matchPatterns":[{"path":"speechtotext/*","method":"*"}]},{"key":"customvision.prediction","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/prediction/*","method":"*"}]},{"key":"customvision.training","renewalPeriod":1,"count":10,"matchPatterns":[{"path":"customvision/v3.0/training/*","method":"*"}]},{"key":"formrecognizer.custom.train","renewalPeriod":60,"count":1,"matchPatterns":[{"path":"formrecognizer/custom/train","method":"*"}]},{"key":"formrecognizer.custom.copymodels","renewalPeriod":60,"count":1,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/copy","method":"*"}]},{"key":"formrecognizer.custom.models.get","renewalPeriod":60,"count":10,"matchPatterns":[{"path":"formrecognizer/custom/models","method":"GET"}]},{"key":"formrecognizer.analyzeform","renewalPeriod":1,"count":15,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/analyze","method":"POST"}]},{"key":"formrecognizer.analyzeform.result","renewalPeriod":1,"count":100,"matchPatterns":[{"path":"formrecognizer/custom/models/{modelId}/analyzeResults/{resultId}","method":"GET"}]},{"key":"container.billing","renewalPeriod":10,"count":500,"matchPatterns":[{"path":"billing/*","method":"*"}]},{"key":"default","renewalPeriod":1,"count":20,"matchPatterns":[{"path":"*","method":"*"}]}]},"publicNetworkAccess":"Enabled","capabilities":[{"name":"Container","value":"TextAnalytics.*,TextAnalytics.Keyphrase,TextAnalytics.KeyphraseV2,TextAnalytics.Language,TextAnalytics.LanguageV2,TextAnalytics.Sentiment,TextAnalytics.SentimentV2,TextAnalytics.SentimentV3,TextAnalytics.SentimentV3Preview,SpeechServices.*,ContentModerator.*,Face.*,Face.Face,ComputerVision.*,LUIS.LUIS,FormRecognizer.*,FormRecognizer.Forms,FormRecognizer.FormRecognizerCustomSupervised,FormRecognizer.FormRecognizerReadLayout"}],"provisioningState":"Succeeded"},"identity":{"principalId":"0d6fa302-ffa5-42ac-b780-4cd86d214754","tenantId":"00000000-0000-0000-0000-000000000000","type":"SystemAssigned","userAssignedIdentities":{}}}' headers: cache-control: - no-cache content-length: - - '3143' + - '4575' content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:57 GMT + - Tue, 03 Nov 2020 07:21:01 GMT etag: - - '"40000ae6-0000-0700-0000-5ed072ee0000"' + - '"27009e80-0000-0700-0000-5fa104da0000"' expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff - x-powered-by: - - ASP.NET + x-envoy-upstream-service-time: + - '12' status: code: 200 message: OK @@ -216,17 +196,14 @@ interactions: Content-Length: - '19' Content-Type: - - application/json; charset=utf-8 + - application/json User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount/regenerateKey?api-version=2017-04-18 response: body: - string: '{"key1":"e789c8946734409fac70b8cb47c798d1","key2":"049826d0605e4f3ab90d3fb0f5c9fce0"}' + string: '{"key1":"2c7c4cf8e0324af1b6986c705930737c","key2":"bc3b54b8ad384752a1a58f7dc60a5cb3"}' headers: cache-control: - no-cache @@ -235,27 +212,25 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:57 GMT + - Tue, 03 Nov 2020 07:21:02 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff + x-envoy-upstream-service-time: + - '273' x-ms-ratelimit-remaining-subscription-writes: - '1199' - x-powered-by: - - ASP.NET status: code: 200 message: OK @@ -271,15 +246,12 @@ interactions: Content-Length: - '0' User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount/listKeys?api-version=2017-04-18 response: body: - string: '{"key1":"e789c8946734409fac70b8cb47c798d1","key2":"049826d0605e4f3ab90d3fb0f5c9fce0"}' + string: '{"key1":"2c7c4cf8e0324af1b6986c705930737c","key2":"bc3b54b8ad384752a1a58f7dc60a5cb3"}' headers: cache-control: - no-cache @@ -288,27 +260,25 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:57 GMT + - Tue, 03 Nov 2020 07:21:02 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff + x-envoy-upstream-service-time: + - '126' x-ms-ratelimit-remaining-subscription-writes: - '1198' - x-powered-by: - - ASP.NET status: code: 200 message: OK @@ -324,12 +294,9 @@ interactions: Content-Length: - '80' Content-Type: - - application/json; charset=utf-8 + - application/json User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/eastus/checkSkuAvailability?api-version=2017-04-18 response: @@ -343,27 +310,25 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 29 May 2020 02:26:59 GMT + - Tue, 03 Nov 2020 07:21:03 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains transfer-encoding: - chunked vary: - Accept-Encoding - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff + x-envoy-upstream-service-time: + - '17' x-ms-ratelimit-remaining-subscription-writes: - '1197' - x-powered-by: - - ASP.NET status: code: 200 message: OK @@ -379,10 +344,7 @@ interactions: Content-Length: - '0' User-Agent: - - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.13 msrest_azure/0.6.3 - azure-mgmt-cognitiveservices/6.2.0 Azure-SDK-For-Python - accept-language: - - en-US + - azsdk-python-mgmt-cognitiveservices/11.0.0b1 Python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) method: DELETE uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_cognitiveservices_test_cognitiveservices680f1670/providers/Microsoft.CognitiveServices/accounts/myAccount?api-version=2017-04-18 response: @@ -394,23 +356,21 @@ interactions: content-length: - '0' date: - - Fri, 29 May 2020 02:27:02 GMT + - Tue, 03 Nov 2020 07:21:09 GMT expires: - '-1' pragma: - no-cache server: - - Microsoft-IIS/10.0 + - istio-envoy strict-transport-security: - max-age=31536000; includeSubDomains - x-aspnet-version: - - 4.0.30319 x-content-type-options: - nosniff + x-envoy-upstream-service-time: + - '266' x-ms-ratelimit-remaining-subscription-deletes: - '14999' - x-powered-by: - - ASP.NET status: code: 200 message: OK