diff --git a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md index b8185904438e..3ce1de250829 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md +++ b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md @@ -5,6 +5,8 @@ **Breaking changes** - Removed property `length` from `CategorizedEntity`, `SentenceSentiment`, `LinkedEntityMatch`, `AspectSentiment`, `OpinionSentiment`, and `PiiEntity`. To get the length of the text in these models, just call `len()` on the `text` property. +- When a parameter or endpoint is not compatible with the API version you specify, we will now return a `ValueError` instead of a `NotImplementedError`. +- Client side validation of input is now disabled by default. This means there will be no `ValidationError`s thrown by the client SDK in the case of malformed input, the service will throw an error instead in an `HttpResponseError` ## 5.1.0b1 (2020-09-17) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_operations_mixin.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_operations_mixin.py index 7eced5ce74c8..1f230fc06a5d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_operations_mixin.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_operations_mixin.py @@ -12,7 +12,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -52,16 +52,15 @@ def entities_linking( api_version = self._get_api_version('entities_linking') if api_version == 'v3.0': from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_linking'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.entities_linking(documents, model_version, show_stats, **kwargs) @@ -95,16 +94,15 @@ def entities_recognition_general( api_version = self._get_api_version('entities_recognition_general') if api_version == 'v3.0': from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_recognition_general'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.entities_recognition_general(documents, model_version, show_stats, **kwargs) @@ -145,16 +143,15 @@ def entities_recognition_pii( :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('entities_recognition_pii') - if api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.2': + if api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_recognition_pii'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, **kwargs) @@ -187,16 +184,15 @@ def key_phrases( api_version = self._get_api_version('key_phrases') if api_version == 'v3.0': from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'key_phrases'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.key_phrases(documents, model_version, show_stats, **kwargs) @@ -230,16 +226,15 @@ def languages( api_version = self._get_api_version('languages') if api_version == 'v3.0': from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'languages'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.languages(documents, model_version, show_stats, **kwargs) @@ -273,15 +268,14 @@ def sentiment( api_version = self._get_api_version('sentiment') if api_version == 'v3.0': from .v3_0.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from .v3_1_preview_2.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'sentiment'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.sentiment(documents, model_version, show_stats, **kwargs) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_text_analytics_client.py index 21f45b0de3d3..e4c9a798546e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/_text_analytics_client.py @@ -63,12 +63,10 @@ def __init__( ): if api_version == 'v3.0': base_url = '{Endpoint}/text/analytics/v3.0' - elif api_version == 'v3.1-preview.1': - base_url = '{Endpoint}/text/analytics/v3.1-preview.1' elif api_version == 'v3.1-preview.2': base_url = '{Endpoint}/text/analytics/v3.1-preview.2' else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} is not available".format(api_version)) self._config = TextAnalyticsClientConfiguration(credential, endpoint, **kwargs) self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) super(TextAnalyticsClient, self).__init__( @@ -85,19 +83,15 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * v3.0: :mod:`v3_0.models` - * v3.1-preview.1: :mod:`v3_1_preview_1.models` * v3.1-preview.2: :mod:`v3_1_preview_2.models` """ if api_version == 'v3.0': from .v3_0 import models return models - elif api_version == 'v3.1-preview.1': - from .v3_1_preview_1 import models - return models elif api_version == 'v3.1-preview.2': from .v3_1_preview_2 import models return models - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} is not available".format(api_version)) def close(self): self._client.close() diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_operations_mixin.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_operations_mixin.py index 21d8aa60ea33..8262099df631 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_operations_mixin.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_operations_mixin.py @@ -12,7 +12,7 @@ from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -48,16 +48,15 @@ async def entities_linking( api_version = self._get_api_version('entities_linking') if api_version == 'v3.0': from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_linking'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.entities_linking(documents, model_version, show_stats, **kwargs) @@ -91,16 +90,15 @@ async def entities_recognition_general( api_version = self._get_api_version('entities_recognition_general') if api_version == 'v3.0': from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_recognition_general'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.entities_recognition_general(documents, model_version, show_stats, **kwargs) @@ -141,16 +139,15 @@ async def entities_recognition_pii( :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('entities_recognition_pii') - if api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.2': + if api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'entities_recognition_pii'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.entities_recognition_pii(documents, model_version, show_stats, domain, string_index_type, **kwargs) @@ -183,16 +180,15 @@ async def key_phrases( api_version = self._get_api_version('key_phrases') if api_version == 'v3.0': from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'key_phrases'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.key_phrases(documents, model_version, show_stats, **kwargs) @@ -226,16 +222,15 @@ async def languages( api_version = self._get_api_version('languages') if api_version == 'v3.0': from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'languages'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.languages(documents, model_version, show_stats, **kwargs) @@ -269,15 +264,14 @@ async def sentiment( api_version = self._get_api_version('sentiment') if api_version == 'v3.0': from ..v3_0.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2.aio.operations import TextAnalyticsClientOperationsMixin as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} does not have operation 'sentiment'".format(api_version)) mixin_instance = OperationClass() mixin_instance._client = self._client mixin_instance._config = self._config mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return await mixin_instance.sentiment(documents, model_version, show_stats, **kwargs) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_text_analytics_client.py index 7e0ad529d83d..8f864b88e72b 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/aio/_text_analytics_client.py @@ -63,12 +63,10 @@ def __init__( ) -> None: if api_version == 'v3.0': base_url = '{Endpoint}/text/analytics/v3.0' - elif api_version == 'v3.1-preview.1': - base_url = '{Endpoint}/text/analytics/v3.1-preview.1' elif api_version == 'v3.1-preview.2': base_url = '{Endpoint}/text/analytics/v3.1-preview.2' else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} is not available".format(api_version)) self._config = TextAnalyticsClientConfiguration(credential, endpoint, **kwargs) self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) super(TextAnalyticsClient, self).__init__( @@ -85,19 +83,15 @@ def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * v3.0: :mod:`v3_0.models` - * v3.1-preview.1: :mod:`v3_1_preview_1.models` * v3.1-preview.2: :mod:`v3_1_preview_2.models` """ if api_version == 'v3.0': from ..v3_0 import models return models - elif api_version == 'v3.1-preview.1': - from ..v3_1_preview_1 import models - return models elif api_version == 'v3.1-preview.2': from ..v3_1_preview_2 import models return models - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} is not available".format(api_version)) async def close(self): await self._client.close() diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_metadata.json b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_metadata.json index 0cecd36ac90b..aa353a1f074d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_metadata.json +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_metadata.json @@ -8,32 +8,33 @@ "base_url": null, "custom_base_url": "\u0027{Endpoint}/text/analytics/v3.0\u0027", "azure_arm": false, - "has_lro_operations": false + "has_lro_operations": false, + "client_side_validation": false }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "endpoint": { - "method_signature": "endpoint, # type: str", + "signature": "endpoint, # type: str", "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", "docstring_type": "str", "required": true } }, - "async_method": { + "async": { "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential, # type: \"AsyncTokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "endpoint": { - "method_signature": "endpoint, # type: str", + "signature": "endpoint, # type: str", "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", "docstring_type": "str", "required": true @@ -114,6 +115,6 @@ "call": "documents, model_version, show_stats" } }, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}" + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}" } \ No newline at end of file diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py index c7754a163d67..3a7c99f7257a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py @@ -44,6 +44,7 @@ def __init__( 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) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py index 23c10e40524f..9e658f7b4af9 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py @@ -41,6 +41,7 @@ def __init__( 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) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py index f7bdb178b87b..53333fa3e5f2 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -47,7 +47,9 @@ async def entities_recognition_general( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -120,7 +122,9 @@ async def entities_linking( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntityLinkingResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -193,7 +197,9 @@ async def key_phrases( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.KeyPhraseResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -267,7 +273,9 @@ async def languages( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.LanguageResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.LanguageBatchInput(documents=documents) @@ -341,7 +349,9 @@ async def sentiment( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.SentimentResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py index 0fc2c25d14ef..9e2a8ff5f01e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -52,7 +52,9 @@ def entities_recognition_general( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -126,7 +128,9 @@ def entities_linking( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntityLinkingResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -200,7 +204,9 @@ def key_phrases( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.KeyPhraseResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -275,7 +281,9 @@ def languages( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.LanguageResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.LanguageBatchInput(documents=documents) @@ -350,7 +358,9 @@ def sentiment( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.SentimentResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_metadata.json b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_metadata.json index 1fe442b56d2f..6169e7300adc 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_metadata.json +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_metadata.json @@ -8,32 +8,33 @@ "base_url": null, "custom_base_url": "\u0027{Endpoint}/text/analytics/v3.1-preview.2\u0027", "azure_arm": false, - "has_lro_operations": false + "has_lro_operations": false, + "client_side_validation": false }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "endpoint": { - "method_signature": "endpoint, # type: str", + "signature": "endpoint, # type: str", "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", "docstring_type": "str", "required": true } }, - "async_method": { + "async": { "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential, # type: \"AsyncTokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "endpoint": { - "method_signature": "endpoint, # type: str", + "signature": "endpoint, # type: str", "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).", "docstring_type": "str", "required": true @@ -126,6 +127,6 @@ "call": "documents, model_version, show_stats, opinion_mining, string_index_type" } }, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}" + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}" } \ No newline at end of file diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_text_analytics_client.py index 816d79abf80c..1e3c9bad5e20 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/_text_analytics_client.py @@ -44,6 +44,7 @@ def __init__( 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) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/_text_analytics_client.py index cd8b14f4ad6f..823e21b32690 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/_text_analytics_client.py @@ -41,6 +41,7 @@ def __init__( 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) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/operations/_text_analytics_client_operations.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/operations/_text_analytics_client_operations.py index e9c991e24f82..41a0fe680745 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/operations/_text_analytics_client_operations.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/aio/operations/_text_analytics_client_operations.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -52,7 +52,9 @@ async def entities_recognition_general( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -137,7 +139,9 @@ async def entities_recognition_pii( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PiiEntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -219,7 +223,9 @@ async def entities_linking( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntityLinkingResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -294,7 +300,9 @@ async def key_phrases( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.KeyPhraseResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -368,7 +376,9 @@ async def languages( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.LanguageResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.LanguageBatchInput(documents=documents) @@ -450,7 +460,9 @@ async def sentiment( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.SentimentResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models.py index 285699e441d1..e1a68a8f3518 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models.py @@ -891,7 +891,7 @@ class PiiDocumentEntities(msrest.serialization.Model): :param statistics: if showStats=true was specified in the request this field will contain information about the document payload. :type statistics: ~azure.ai.textanalytics.v3_1_preview_2.models.DocumentStatistics - :param redacted_text: Returns redacted text. + :param redacted_text: Required. Returns redacted text. :type redacted_text: str """ @@ -899,6 +899,7 @@ class PiiDocumentEntities(msrest.serialization.Model): 'id': {'required': True}, 'entities': {'required': True}, 'warnings': {'required': True}, + 'redacted_text': {'required': True}, } _attribute_map = { @@ -918,7 +919,7 @@ def __init__( self.entities = kwargs['entities'] self.warnings = kwargs['warnings'] self.statistics = kwargs.get('statistics', None) - self.redacted_text = kwargs.get('redacted_text', None) + self.redacted_text = kwargs['redacted_text'] class PiiEntitiesResult(msrest.serialization.Model): diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models_py3.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models_py3.py index 11130a54922a..0e46fdbdb097 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models_py3.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/models/_models_py3.py @@ -998,7 +998,7 @@ class PiiDocumentEntities(msrest.serialization.Model): :param statistics: if showStats=true was specified in the request this field will contain information about the document payload. :type statistics: ~azure.ai.textanalytics.v3_1_preview_2.models.DocumentStatistics - :param redacted_text: Returns redacted text. + :param redacted_text: Required. Returns redacted text. :type redacted_text: str """ @@ -1006,6 +1006,7 @@ class PiiDocumentEntities(msrest.serialization.Model): 'id': {'required': True}, 'entities': {'required': True}, 'warnings': {'required': True}, + 'redacted_text': {'required': True}, } _attribute_map = { @@ -1022,8 +1023,8 @@ def __init__( id: str, entities: List["Entity"], warnings: List["TextAnalyticsWarning"], + redacted_text: str, statistics: Optional["DocumentStatistics"] = None, - redacted_text: Optional[str] = None, **kwargs ): super(PiiDocumentEntities, self).__init__(**kwargs) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/operations/_text_analytics_client_operations.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/operations/_text_analytics_client_operations.py index 2a63ac9ecb1a..1097a08f74a7 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/operations/_text_analytics_client_operations.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_generated/v3_1_preview_2/operations/_text_analytics_client_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -57,7 +57,9 @@ def entities_recognition_general( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -143,7 +145,9 @@ def entities_recognition_pii( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PiiEntitiesResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -226,7 +230,9 @@ def entities_linking( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EntityLinkingResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -302,7 +308,9 @@ def key_phrases( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.KeyPhraseResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) @@ -377,7 +385,9 @@ def languages( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.LanguageResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.LanguageBatchInput(documents=documents) @@ -460,7 +470,9 @@ def sentiment( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.SentimentResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) _input = models.MultiLanguageBatchInput(documents=documents) diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py index a9551bdaac9e..c28ba4195874 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_text_analytics_client.py @@ -269,7 +269,7 @@ def recognize_pii_entities( # type: ignore were passed in. :rtype: list[~azure.ai.textanalytics.RecognizePiiEntitiesResult, ~azure.ai.textanalytics.DocumentError] - :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError: + :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError: .. admonition:: Example: @@ -297,9 +297,9 @@ def recognize_pii_entities( # type: ignore cls=kwargs.pop("cls", pii_entities_result), **kwargs ) - except NotImplementedError as error: - if "APIVersion v3.0 is not available" in str(error): - raise NotImplementedError( + except ValueError as error: + if "API version v3.0 does not have operation 'entities_recognition_pii'" in str(error): + raise ValueError( "'recognize_pii_entities' endpoint is only available for API version v3.1-preview and up" ) raise error @@ -518,7 +518,7 @@ def analyze_sentiment( # type: ignore ) except TypeError as error: if "opinion_mining" in str(error): - raise NotImplementedError( + raise ValueError( "'show_opinion_mining' is only available for API version v3.1-preview and up" ) raise error diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py index 7c918f60d6d1..29e66880f9d1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/aio/_text_analytics_client_async.py @@ -271,7 +271,7 @@ async def recognize_pii_entities( # type: ignore were passed in. :rtype: list[~azure.ai.textanalytics.RecognizePiiEntitiesResult, ~azure.ai.textanalytics.DocumentError] - :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError or NotImplementedError: + :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError: .. admonition:: Example: @@ -300,9 +300,9 @@ async def recognize_pii_entities( # type: ignore cls=kwargs.pop("cls", pii_entities_result), **kwargs ) - except NotImplementedError as error: - if "APIVersion v3.0 is not available" in str(error): - raise NotImplementedError( + except ValueError as error: + if "API version v3.0 does not have operation 'entities_recognition_pii'" in str(error): + raise ValueError( "'recognize_pii_entities' endpoint is only available for API version v3.1-preview and up" ) raise error @@ -519,7 +519,7 @@ async def analyze_sentiment( # type: ignore ) except TypeError as error: if "opinion_mining" in str(error): - raise NotImplementedError( + raise ValueError( "'show_opinion_mining' is only available for API version v3.1-preview and up" ) raise error diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py index b7999dfb8ce1..f7766b0215b0 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment.py @@ -690,7 +690,7 @@ def test_opinion_mining_no_mined_opinions(self, client): @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer(client_kwargs={"api_version": TextAnalyticsApiVersion.V3_0}) def test_opinion_mining_v3(self, client): - with pytest.raises(NotImplementedError) as excinfo: + with pytest.raises(ValueError) as excinfo: client.analyze_sentiment(["will fail"], show_opinion_mining=True) assert "'show_opinion_mining' is only available for API version v3.1-preview and up" in str(excinfo.value) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py index fef0c7111d1a..c709b9967152 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_analyze_sentiment_async.py @@ -705,7 +705,7 @@ async def test_opinion_mining_no_mined_opinions(self, client): @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer(client_kwargs={"api_version": TextAnalyticsApiVersion.V3_0}) async def test_opinion_mining_v3(self, client): - with pytest.raises(NotImplementedError) as excinfo: + with pytest.raises(ValueError) as excinfo: await client.analyze_sentiment(["will fail"], show_opinion_mining=True) assert "'show_opinion_mining' is only available for API version v3.1-preview and up" in str(excinfo.value) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py index fc62d6510e03..df84800efccd 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities.py @@ -565,7 +565,7 @@ def callback(response): @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer(client_kwargs={"api_version": TextAnalyticsApiVersion.V3_0}) def test_recognize_pii_entities_v3(self, client): - with pytest.raises(NotImplementedError) as excinfo: + with pytest.raises(ValueError) as excinfo: client.recognize_pii_entities(["this should fail"]) assert "'recognize_pii_entities' endpoint is only available for API version v3.1-preview and up" in str(excinfo.value) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py index 4949bc54b1e5..7d062f5fff28 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_recognize_pii_entities_async.py @@ -566,7 +566,7 @@ def callback(response): @GlobalTextAnalyticsAccountPreparer() @TextAnalyticsClientPreparer(client_kwargs={"api_version": TextAnalyticsApiVersion.V3_0}) async def test_recognize_pii_entities_v3(self, client): - with pytest.raises(NotImplementedError) as excinfo: + with pytest.raises(ValueError) as excinfo: await client.recognize_pii_entities(["this should fail"]) assert "'recognize_pii_entities' endpoint is only available for API version v3.1-preview and up" in str(excinfo.value)