diff --git a/sdk/translation/azure-ai-translation-document/CHANGELOG.md b/sdk/translation/azure-ai-translation-document/CHANGELOG.md index cd8b2aca724f..2c045bf1fabf 100644 --- a/sdk/translation/azure-ai-translation-document/CHANGELOG.md +++ b/sdk/translation/azure-ai-translation-document/CHANGELOG.md @@ -2,13 +2,8 @@ ## 1.1.0b2 (Unreleased) -### Features Added - -### Breaking Changes - -### Bugs Fixed - ### Other Changes +- Renamed SingleDocumentTranslationClient's API from `document_translate` to `translate` ## 1.1.0b1 (2024-05-21) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_model_base.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_model_base.py index 9d401b0cf012..e6a2730f9276 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_model_base.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_model_base.py @@ -5,7 +5,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines +# pylint: disable=protected-access, broad-except import copy import calendar @@ -574,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' @@ -585,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di annotations = { k: v for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() } for attr, rf in attr_to_rest_field.items(): rf._module = cls.__module__ @@ -601,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: - if hasattr(base, "__mapping__"): # pylint: disable=no-member - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: @@ -613,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField @classmethod def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + if not hasattr(cls, "__mapping__"): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) if discriminator is None: @@ -633,7 +633,7 @@ def _deserialize(cls, data, exist_discriminators): discriminator_value = data.find(xml_name).text # pyright: ignore else: discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore return mapped_cls._deserialize(data, exist_discriminators) def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py index 8e1efb0ec490..e86f7ccb4210 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_operations.py @@ -81,7 +81,7 @@ def build_document_translation_list_translation_statuses_request( # pylint: dis top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, - ids: Optional[List[str]] = None, + translation_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -105,8 +105,8 @@ def build_document_translation_list_translation_statuses_request( # pylint: dis _params["skip"] = _SERIALIZER.query("skip", skip, "int") if maxpagesize is not None: _params["maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int") - if ids is not None: - _params["ids"] = _SERIALIZER.query("ids", ids, "[str]", div=",") + if translation_ids is not None: + _params["ids"] = _SERIALIZER.query("translation_ids", translation_ids, "[str]", div=",") if statuses is not None: _params["statuses"] = _SERIALIZER.query("statuses", statuses, "[str]", div=",") if created_date_time_utc_start is not None: @@ -211,7 +211,7 @@ def build_document_translation_list_document_statuses_request( # pylint: disabl top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, - ids: Optional[List[str]] = None, + document_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -240,8 +240,8 @@ def build_document_translation_list_document_statuses_request( # pylint: disabl _params["skip"] = _SERIALIZER.query("skip", skip, "int") if maxpagesize is not None: _params["maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int") - if ids is not None: - _params["ids"] = _SERIALIZER.query("ids", ids, "[str]", div=",") + if document_ids is not None: + _params["ids"] = _SERIALIZER.query("document_ids", document_ids, "[str]", div=",") if statuses is not None: _params["statuses"] = _SERIALIZER.query("statuses", statuses, "[str]", div=",") if created_date_time_utc_start is not None: @@ -284,7 +284,7 @@ def build_document_translation_get_supported_formats_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_single_document_translation_document_translate_request( # pylint: disable=name-too-long +def build_single_document_translation_translate_request( # pylint: disable=name-too-long *, target_language: str, source_language: Optional[str] = None, @@ -581,7 +581,7 @@ def list_translation_statuses( *, top: Optional[int] = None, skip: Optional[int] = None, - ids: Optional[List[str]] = None, + translation_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -668,8 +668,8 @@ def list_translation_statuses( server can't honor top and/or skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. Default value is None. :paramtype skip: int - :keyword ids: Ids to use in filtering. Default value is None. - :paramtype ids: list[str] + :keyword translation_ids: Ids to use in filtering. Default value is None. + :paramtype translation_ids: list[str] :keyword statuses: Statuses to use in filtering. Default value is None. :paramtype statuses: list[str] :keyword created_date_time_utc_start: the start datetime to get items after. Default value is @@ -706,7 +706,7 @@ def prepare_request(next_link=None): top=top, skip=skip, maxpagesize=maxpagesize, - ids=ids, + translation_ids=translation_ids, statuses=statuses, created_date_time_utc_start=created_date_time_utc_start, created_date_time_utc_end=created_date_time_utc_end, @@ -975,7 +975,7 @@ def list_document_statuses( *, top: Optional[int] = None, skip: Optional[int] = None, - ids: Optional[List[str]] = None, + document_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -1058,8 +1058,8 @@ def list_document_statuses( server can't honor top and/or skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. Default value is None. :paramtype skip: int - :keyword ids: Ids to use in filtering. Default value is None. - :paramtype ids: list[str] + :keyword document_ids: Ids to use in filtering. Default value is None. + :paramtype document_ids: list[str] :keyword statuses: Statuses to use in filtering. Default value is None. :paramtype statuses: list[str] :keyword created_date_time_utc_start: the start datetime to get items after. Default value is @@ -1097,7 +1097,7 @@ def prepare_request(next_link=None): top=top, skip=skip, maxpagesize=maxpagesize, - ids=ids, + document_ids=document_ids, statuses=statuses, created_date_time_utc_start=created_date_time_utc_start, created_date_time_utc_end=created_date_time_utc_end, @@ -1160,7 +1160,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def _get_supported_formats( # pylint: disable=protected-access + def _get_supported_formats( self, *, type: Optional[Union[str, _models.FileFormatType]] = None, **kwargs: Any ) -> _models._models.SupportedFileFormats: """Returns a list of supported document formats. @@ -1235,7 +1235,7 @@ class SingleDocumentTranslationClientOperationsMixin( # pylint: disable=name-to ): @overload - def document_translate( + def translate( self, body: _models.DocumentTranslateContent, *, @@ -1279,7 +1279,7 @@ def document_translate( """ @overload - def document_translate( + def translate( self, body: JSON, *, @@ -1323,7 +1323,7 @@ def document_translate( """ @distributed_trace - def document_translate( + def translate( self, body: Union[_models.DocumentTranslateContent, JSON], *, @@ -1384,7 +1384,7 @@ def document_translate( _data_fields: List[str] = [] _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_single_document_translation_document_translate_request( + _request = build_single_document_translation_translate_request( target_language=target_language, source_language=source_language, category=category, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py index c3be828b5c72..d597e1c2ed86 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_operations/_patch.py @@ -43,7 +43,7 @@ SingleDocumentTranslationClientOperationsMixin as GeneratedSingleDocumentTranslationClientOperationsMixin, JSON, ClsType, - build_single_document_translation_document_translate_request, + build_single_document_translation_translate_request, ) from .._vendor import prepare_multipart_form_data @@ -336,7 +336,7 @@ class SingleDocumentTranslationClientOperationsMixin( ): # pylint: disable=name-too-long @overload - def document_translate( + def translate( self, body: _models.DocumentTranslateContent, *, @@ -389,7 +389,7 @@ def document_translate( """ @overload - def document_translate( + def translate( self, body: JSON, *, @@ -433,7 +433,7 @@ def document_translate( """ @distributed_trace - def document_translate( + def translate( self, body: Union[_models.DocumentTranslateContent, JSON], *, @@ -502,7 +502,7 @@ def document_translate( _data_fields: List[str] = [] _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_single_document_translation_document_translate_request( + _request = build_single_document_translation_translate_request( target_language=target_language, source_language=source_language, category=category, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py index a49d40e471e2..4eab449fd8c3 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_patch.py @@ -19,7 +19,7 @@ from ._operations._patch import DocumentTranslationLROPoller, DocumentTranslationLROPollingMethod, TranslationPolling from ._client import DocumentTranslationClient as GeneratedDocumentTranslationClient from .models import ( - BatchRequest, + DocumentBatch, SourceInput, TranslationTarget, DocumentFilter, @@ -107,7 +107,7 @@ def get_translation_input(args, kwargs, continuation_token): request = StartTranslationDetails( inputs=[ - BatchRequest( + DocumentBatch( source=SourceInput( source_url=source_url, filter=DocumentFilter(prefix=prefix, suffix=suffix), @@ -552,7 +552,7 @@ def list_translation_statuses( super().list_translation_statuses( created_date_time_utc_start=created_after, created_date_time_utc_end=created_before, - ids=translation_ids, + translation_ids=translation_ids, orderby=order_by, statuses=statuses, top=top, @@ -620,7 +620,7 @@ def list_document_statuses( # type: ignore[override] translation_id=translation_id, created_date_time_utc_start=created_after, created_date_time_utc_end=created_before, - ids=document_ids, + document_ids=document_ids, orderby=order_by, statuses=statuses, top=top, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_serialization.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_serialization.py index 480e941d758f..ce17d1798ce7 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_serialization.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -506,7 +507,6 @@ def _flatten_subtype(cls, key, objects): def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. :param dict response: The initial data :param dict objects: The class objects @@ -518,7 +518,7 @@ def _classify(cls, response, objects): if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_operations.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_operations.py index b6ed59e6a92d..6b8361f2d71a 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_operations.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_operations.py @@ -42,7 +42,7 @@ build_document_translation_get_translation_status_request, build_document_translation_list_document_statuses_request, build_document_translation_list_translation_statuses_request, - build_single_document_translation_document_translate_request, + build_single_document_translation_translate_request, ) from ..._vendor import prepare_multipart_form_data from .._vendor import DocumentTranslationClientMixinABC, SingleDocumentTranslationClientMixinABC @@ -325,7 +325,7 @@ def list_translation_statuses( *, top: Optional[int] = None, skip: Optional[int] = None, - ids: Optional[List[str]] = None, + translation_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -412,8 +412,8 @@ def list_translation_statuses( server can't honor top and/or skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. Default value is None. :paramtype skip: int - :keyword ids: Ids to use in filtering. Default value is None. - :paramtype ids: list[str] + :keyword translation_ids: Ids to use in filtering. Default value is None. + :paramtype translation_ids: list[str] :keyword statuses: Statuses to use in filtering. Default value is None. :paramtype statuses: list[str] :keyword created_date_time_utc_start: the start datetime to get items after. Default value is @@ -451,7 +451,7 @@ def prepare_request(next_link=None): top=top, skip=skip, maxpagesize=maxpagesize, - ids=ids, + translation_ids=translation_ids, statuses=statuses, created_date_time_utc_start=created_date_time_utc_start, created_date_time_utc_end=created_date_time_utc_end, @@ -720,7 +720,7 @@ def list_document_statuses( *, top: Optional[int] = None, skip: Optional[int] = None, - ids: Optional[List[str]] = None, + document_ids: Optional[List[str]] = None, statuses: Optional[List[str]] = None, created_date_time_utc_start: Optional[datetime.datetime] = None, created_date_time_utc_end: Optional[datetime.datetime] = None, @@ -803,8 +803,8 @@ def list_document_statuses( server can't honor top and/or skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. Default value is None. :paramtype skip: int - :keyword ids: Ids to use in filtering. Default value is None. - :paramtype ids: list[str] + :keyword document_ids: Ids to use in filtering. Default value is None. + :paramtype document_ids: list[str] :keyword statuses: Statuses to use in filtering. Default value is None. :paramtype statuses: list[str] :keyword created_date_time_utc_start: the start datetime to get items after. Default value is @@ -843,7 +843,7 @@ def prepare_request(next_link=None): top=top, skip=skip, maxpagesize=maxpagesize, - ids=ids, + document_ids=document_ids, statuses=statuses, created_date_time_utc_start=created_date_time_utc_start, created_date_time_utc_end=created_date_time_utc_end, @@ -906,7 +906,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def _get_supported_formats( # pylint: disable=protected-access + async def _get_supported_formats( self, *, type: Optional[Union[str, _models.FileFormatType]] = None, **kwargs: Any ) -> _models._models.SupportedFileFormats: """Returns a list of supported document formats. @@ -981,7 +981,7 @@ class SingleDocumentTranslationClientOperationsMixin( # pylint: disable=name-to ): @overload - async def document_translate( + async def translate( self, body: _models.DocumentTranslateContent, *, @@ -1025,7 +1025,7 @@ async def document_translate( """ @overload - async def document_translate( + async def translate( self, body: JSON, *, @@ -1069,7 +1069,7 @@ async def document_translate( """ @distributed_trace_async - async def document_translate( + async def translate( self, body: Union[_models.DocumentTranslateContent, JSON], *, @@ -1130,7 +1130,7 @@ async def document_translate( _data_fields: List[str] = [] _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_single_document_translation_document_translate_request( + _request = build_single_document_translation_translate_request( target_language=target_language, source_language=source_language, category=category, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_patch.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_patch.py index 28350637a808..e39a31e52645 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_patch.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_operations/_patch.py @@ -39,7 +39,7 @@ from ._operations import ( DocumentTranslationClientOperationsMixin as GeneratedDocumentTranslationClientOperationsMixin, SingleDocumentTranslationClientOperationsMixin as GeneratedSingleDocumentTranslationClientOperationsMixin, - build_single_document_translation_document_translate_request, + build_single_document_translation_translate_request, JSON, ClsType, ) @@ -248,7 +248,7 @@ class SingleDocumentTranslationClientOperationsMixin( ): # pylint: disable=name-too-long @overload - async def document_translate( + async def translate( self, body: _models.DocumentTranslateContent, *, @@ -301,7 +301,7 @@ async def document_translate( """ @overload - async def document_translate( + async def translate( self, body: JSON, *, @@ -345,7 +345,7 @@ async def document_translate( """ @distributed_trace_async - async def document_translate( + async def translate( self, body: Union[_models.DocumentTranslateContent, JSON], *, @@ -414,7 +414,7 @@ async def document_translate( _data_fields: List[str] = [] _files, _data = prepare_multipart_form_data(_body, _file_fields, _data_fields) - _request = build_single_document_translation_document_translate_request( + _request = build_single_document_translation_translate_request( target_language=target_language, source_language=source_language, category=category, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_patch.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_patch.py index e8190c4275e7..6648cc16d6bc 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_patch.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_patch.py @@ -435,7 +435,7 @@ def list_translation_statuses( super().list_translation_statuses( created_date_time_utc_start=created_after, created_date_time_utc_end=created_before, - ids=translation_ids, + translation_ids=translation_ids, orderby=order_by, statuses=statuses, top=top, @@ -503,7 +503,7 @@ def list_document_statuses( # type: ignore[override] translation_id=translation_id, created_date_time_utc_start=created_after, created_date_time_utc_end=created_before, - ids=document_ids, + document_ids=document_ids, orderby=order_by, statuses=statuses, top=top, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/__init__.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/__init__.py index e05bb40c0a7c..d14cd0756fdf 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/__init__.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/__init__.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._models import BatchRequest +from ._models import DocumentBatch from ._models import DocumentFilter from ._patch import DocumentStatus from ._models import DocumentTranslateContent @@ -15,7 +15,7 @@ from ._models import InnerTranslationError from ._models import SourceInput from ._models import StartTranslationDetails -from ._models import StatusSummary +from ._models import TranslationStatusSummary from ._patch import TranslationTarget from ._models import DocumentTranslationError from ._patch import TranslationStatus @@ -24,13 +24,13 @@ from ._enums import FileFormatType from ._enums import Status from ._enums import StorageInputType -from ._enums import StorageSource +from ._enums import TranslationStorageSource from ._enums import TranslationErrorCode from ._patch import patch_sdk as _patch_sdk __all__ = [ - "BatchRequest", + "DocumentBatch", "DocumentFilter", "DocumentStatus", "DocumentTranslateContent", @@ -39,14 +39,14 @@ "InnerTranslationError", "SourceInput", "StartTranslationDetails", - "StatusSummary", + "TranslationStatusSummary", "TranslationTarget", "DocumentTranslationError", "TranslationStatus", "FileFormatType", "Status", "StorageInputType", - "StorageSource", + "TranslationStorageSource", "TranslationErrorCode", "DocumentTranslationInput", ] diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_enums.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_enums.py index e9191ebab4be..b3012b1998dc 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_enums.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_enums.py @@ -47,13 +47,6 @@ class StorageInputType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """File storage input type""" -class StorageSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Storage Source.""" - - AZURE_BLOB = "AzureBlob" - """Azure blob storage source""" - - class TranslationErrorCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enums containing high level error codes.""" @@ -71,3 +64,10 @@ class TranslationErrorCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Unauthorized""" REQUEST_RATE_TOO_HIGH = "RequestRateTooHigh" """RequestRateTooHigh""" + + +class TranslationStorageSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage Source.""" + + AZURE_BLOB = "AzureBlob" + """Azure blob storage source""" diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_models.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_models.py index 7f3f86562eaa..ab006704ffce 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_models.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_models.py @@ -5,6 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation import datetime from typing import Any, List, Mapping, Optional, TYPE_CHECKING, Union, overload @@ -17,7 +18,7 @@ from .. import models as _models -class BatchRequest(_model_base.Model): +class DocumentBatch(_model_base.Model): """Definition for the input batch translation request. All required parameters must be populated in order to send to server. @@ -54,7 +55,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -97,7 +98,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -177,7 +178,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -212,7 +213,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -276,7 +277,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -294,8 +295,8 @@ class DocumentTranslationFileFormat(_model_base.Model): :vartype default_format_version: str :ivar format_versions: Supported Version. :vartype format_versions: list[str] - :ivar type: Supported Type for this format. - :vartype type: str + :ivar type: Supported Type for this format. Known values are: "document" and "glossary". + :vartype type: str or ~azure.ai.translation.document.models.FileFormatType """ file_format: str = rest_field(name="format") @@ -308,8 +309,8 @@ class DocumentTranslationFileFormat(_model_base.Model): """Default version if none is specified.""" format_versions: Optional[List[str]] = rest_field(name="versions") """Supported Version.""" - type: Optional[str] = rest_field() - """Supported Type for this format.""" + type: Optional[Union[str, "_models.FileFormatType"]] = rest_field() + """Supported Type for this format. Known values are: \"document\" and \"glossary\".""" @overload def __init__( @@ -320,7 +321,7 @@ def __init__( content_types: List[str], default_format_version: Optional[str] = None, format_versions: Optional[List[str]] = None, - type: Optional[str] = None, + type: Optional[Union[str, "_models.FileFormatType"]] = None, ) -> None: ... @overload @@ -330,7 +331,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -394,7 +395,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -412,7 +413,7 @@ class SourceInput(_model_base.Model): If none is specified, we will perform auto detect on the document. :vartype language: str :ivar storage_source: Storage Source. "AzureBlob" - :vartype storage_source: str or ~azure.ai.translation.document.models.StorageSource + :vartype storage_source: str or ~azure.ai.translation.document.models.TranslationStorageSource """ source_url: str = rest_field(name="sourceUrl") @@ -422,7 +423,7 @@ class SourceInput(_model_base.Model): language: Optional[str] = rest_field() """Language code If none is specified, we will perform auto detect on the document.""" - storage_source: Optional[Union[str, "_models.StorageSource"]] = rest_field(name="storageSource") + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = rest_field(name="storageSource") """Storage Source. \"AzureBlob\"""" @overload @@ -432,7 +433,7 @@ def __init__( source_url: str, filter: Optional["_models.DocumentFilter"] = None, # pylint: disable=redefined-builtin language: Optional[str] = None, - storage_source: Optional[Union[str, "_models.StorageSource"]] = None, + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = None, ) -> None: ... @overload @@ -442,7 +443,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -452,17 +453,17 @@ class StartTranslationDetails(_model_base.Model): All required parameters must be populated in order to send to server. :ivar inputs: The input list of documents or folders containing documents. Required. - :vartype inputs: list[~azure.ai.translation.document.models.BatchRequest] + :vartype inputs: list[~azure.ai.translation.document.models.DocumentBatch] """ - inputs: List["_models.BatchRequest"] = rest_field() + inputs: List["_models.DocumentBatch"] = rest_field() """The input list of documents or folders containing documents. Required.""" @overload def __init__( self, *, - inputs: List["_models.BatchRequest"], + inputs: List["_models.DocumentBatch"], ) -> None: ... @overload @@ -472,66 +473,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class StatusSummary(_model_base.Model): - """Status Summary. - - - :ivar total: Total count. Required. - :vartype total: int - :ivar failed: Failed count. Required. - :vartype failed: int - :ivar success: Number of Success. Required. - :vartype success: int - :ivar in_progress: Number of in progress. Required. - :vartype in_progress: int - :ivar not_yet_started: Count of not yet started. Required. - :vartype not_yet_started: int - :ivar canceled: Number of cancelled. Required. - :vartype canceled: int - :ivar total_characters_charged: Total characters charged by the API. Required. - :vartype total_characters_charged: int - """ - - total: int = rest_field() - """Total count. Required.""" - failed: int = rest_field() - """Failed count. Required.""" - success: int = rest_field() - """Number of Success. Required.""" - in_progress: int = rest_field(name="inProgress") - """Number of in progress. Required.""" - not_yet_started: int = rest_field(name="notYetStarted") - """Count of not yet started. Required.""" - canceled: int = rest_field(name="cancelled") - """Number of cancelled. Required.""" - total_characters_charged: int = rest_field(name="totalCharacterCharged") - """Total characters charged by the API. Required.""" - - @overload - def __init__( - self, - *, - total: int, - failed: int, - success: int, - in_progress: int, - not_yet_started: int, - canceled: int, - total_characters_charged: int, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -578,7 +520,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -599,7 +541,7 @@ class TranslationGlossary(_model_base.Model): :ivar format_version: Optional Version. If not specified, default is used. :vartype format_version: str :ivar storage_source: Storage Source. "AzureBlob" - :vartype storage_source: str or ~azure.ai.translation.document.models.StorageSource + :vartype storage_source: str or ~azure.ai.translation.document.models.TranslationStorageSource """ glossary_url: str = rest_field(name="glossaryUrl") @@ -613,7 +555,7 @@ class TranslationGlossary(_model_base.Model): """Format. Required.""" format_version: Optional[str] = rest_field(name="version") """Optional Version. If not specified, default is used.""" - storage_source: Optional[Union[str, "_models.StorageSource"]] = rest_field(name="storageSource") + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = rest_field(name="storageSource") """Storage Source. \"AzureBlob\"""" @overload @@ -623,7 +565,7 @@ def __init__( glossary_url: str, file_format: str, format_version: Optional[str] = None, - storage_source: Optional[Union[str, "_models.StorageSource"]] = None, + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = None, ) -> None: ... @overload @@ -633,7 +575,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -641,7 +583,7 @@ class TranslationStatus(_model_base.Model): """Translation job status response. - :ivar id: Id of the operation. Required. + :ivar id: Id of the translation operation. Required. :vartype id: str :ivar created_on: Operation created date time. Required. :vartype created_on: ~datetime.datetime @@ -655,11 +597,11 @@ class TranslationStatus(_model_base.Model): inner error with more descriptive details. :vartype error: ~azure.ai.translation.document.models.DocumentTranslationError :ivar summary: Status Summary. Required. - :vartype summary: ~azure.ai.translation.document.models.StatusSummary + :vartype summary: ~azure.ai.translation.document.models.TranslationStatusSummary """ id: str = rest_field() - """Id of the operation. Required.""" + """Id of the translation operation. Required.""" created_on: datetime.datetime = rest_field(name="createdDateTimeUtc", format="rfc3339") """Operation created date time. Required.""" last_updated_on: datetime.datetime = rest_field(name="lastActionDateTimeUtc", format="rfc3339") @@ -671,7 +613,7 @@ class TranslationStatus(_model_base.Model): error: Optional["_models.DocumentTranslationError"] = rest_field() """This contains an outer error with error code, message, details, target and an inner error with more descriptive details.""" - summary: "_models.StatusSummary" = rest_field() + summary: "_models.TranslationStatusSummary" = rest_field() """Status Summary. Required.""" @overload @@ -682,7 +624,7 @@ def __init__( created_on: datetime.datetime, last_updated_on: datetime.datetime, status: Union[str, "_models.Status"], - summary: "_models.StatusSummary", + summary: "_models.TranslationStatusSummary", error: Optional["_models.DocumentTranslationError"] = None, ) -> None: ... @@ -693,7 +635,66 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TranslationStatusSummary(_model_base.Model): + """Status Summary. + + + :ivar total: Total count. Required. + :vartype total: int + :ivar failed: Failed count. Required. + :vartype failed: int + :ivar success: Number of Success. Required. + :vartype success: int + :ivar in_progress: Number of in progress. Required. + :vartype in_progress: int + :ivar not_yet_started: Count of not yet started. Required. + :vartype not_yet_started: int + :ivar canceled: Number of cancelled. Required. + :vartype canceled: int + :ivar total_characters_charged: Total characters charged by the API. Required. + :vartype total_characters_charged: int + """ + + total: int = rest_field() + """Total count. Required.""" + failed: int = rest_field() + """Failed count. Required.""" + success: int = rest_field() + """Number of Success. Required.""" + in_progress: int = rest_field(name="inProgress") + """Number of in progress. Required.""" + not_yet_started: int = rest_field(name="notYetStarted") + """Count of not yet started. Required.""" + canceled: int = rest_field(name="cancelled") + """Number of cancelled. Required.""" + total_characters_charged: int = rest_field(name="totalCharacterCharged") + """Total characters charged by the API. Required.""" + + @overload + def __init__( + self, + *, + total: int, + failed: int, + success: int, + in_progress: int, + not_yet_started: int, + canceled: int, + total_characters_charged: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -711,7 +712,7 @@ class TranslationTarget(_model_base.Model): :ivar glossaries: List of Glossary. :vartype glossaries: list[~azure.ai.translation.document.models.TranslationGlossary] :ivar storage_source: Storage Source. "AzureBlob" - :vartype storage_source: str or ~azure.ai.translation.document.models.StorageSource + :vartype storage_source: str or ~azure.ai.translation.document.models.TranslationStorageSource """ target_url: str = rest_field(name="targetUrl") @@ -722,7 +723,7 @@ class TranslationTarget(_model_base.Model): """Target Language. Required.""" glossaries: Optional[List["_models.TranslationGlossary"]] = rest_field() """List of Glossary.""" - storage_source: Optional[Union[str, "_models.StorageSource"]] = rest_field(name="storageSource") + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = rest_field(name="storageSource") """Storage Source. \"AzureBlob\"""" @overload @@ -733,7 +734,7 @@ def __init__( language: str, category_id: Optional[str] = None, glossaries: Optional[List["_models.TranslationGlossary"]] = None, - storage_source: Optional[Union[str, "_models.StorageSource"]] = None, + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = None, ) -> None: ... @overload @@ -743,5 +744,5 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_patch.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_patch.py index 704750fcfd13..8f44b574aca5 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_patch.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/models/_patch.py @@ -14,7 +14,7 @@ TranslationStatus as GeneratedTranslationStatus, TranslationGlossary as GeneratedTranslationGlossary, TranslationTarget as GeneratedTranslationTarget, - BatchRequest, + DocumentBatch, SourceInput, DocumentFilter, ) @@ -114,7 +114,7 @@ def __init__( self.suffix = suffix def _to_generated(self): - return BatchRequest( + return DocumentBatch( source=SourceInput( source_url=self.source_url, filter=DocumentFilter(prefix=self.prefix, suffix=self.suffix), @@ -155,7 +155,7 @@ class TranslationTarget(GeneratedTranslationTarget): :ivar glossaries: List of Glossary. :vartype glossaries: list[~azure.ai.translation.document.models.TranslationGlossary] :ivar storage_source: Storage Source. "AzureBlob" - :vartype storage_source: str or ~azure.ai.translation.document.models.StorageSource + :vartype storage_source: str or ~azure.ai.translation.document.models.TranslationStorageSource """ target_url: str @@ -166,7 +166,7 @@ class TranslationTarget(GeneratedTranslationTarget): """Target Language. Required.""" glossaries: Optional[List["TranslationGlossary"]] """List of Glossary.""" - storage_source: Optional[Union[str, "_models.StorageSource"]] + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] """Storage Source. \"AzureBlob\"""" @overload @@ -177,7 +177,7 @@ def __init__( *, category_id: Optional[str] = None, glossaries: Optional[List["TranslationGlossary"]] = None, - storage_source: Optional[Union[str, "_models.StorageSource"]] = None, + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = None, ): ... @overload @@ -213,7 +213,7 @@ class TranslationGlossary(GeneratedTranslationGlossary): :ivar format_version: Optional Version. If not specified, default is used. :vartype format_version: str :ivar storage_source: Storage Source. "AzureBlob" - :vartype storage_source: str or ~azure.ai.translation.document.models.StorageSource + :vartype storage_source: str or ~azure.ai.translation.document.models.TranslationStorageSource """ glossary_url: str @@ -227,7 +227,7 @@ class TranslationGlossary(GeneratedTranslationGlossary): """Format. Required.""" format_version: Optional[str] """Optional Version. If not specified, default is used.""" - storage_source: Optional[Union[str, "_models.StorageSource"]] + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] """Storage Source. \"AzureBlob\"""" @overload @@ -237,7 +237,7 @@ def __init__( file_format: str, *, format_version: Optional[str] = None, - storage_source: Optional[Union[str, "_models.StorageSource"]] = None, + storage_source: Optional[Union[str, "_models.TranslationStorageSource"]] = None, ): ... @overload @@ -362,7 +362,7 @@ class TranslationStatus(GeneratedTranslationStatus): inner error with more descriptive details. :vartype error: ~azure.ai.translation.document.models.DocumentTranslationError :ivar summary: Status Summary. Required. - :vartype summary: ~azure.ai.translation.document.models.StatusSummary + :vartype summary: ~azure.ai.translation.document.models.TranslationStatusSummary """ id: str @@ -378,7 +378,7 @@ class TranslationStatus(GeneratedTranslationStatus): error: Optional["_models.DocumentTranslationError"] """This contains an outer error with error code, message, details, target and an inner error with more descriptive details.""" - summary: "_models.StatusSummary" + summary: "_models.TranslationStatusSummary" """Status Summary. Required.""" # pylint: disable=too-many-return-statements,inconsistent-return-statements @@ -420,7 +420,7 @@ def __init__( created_on: datetime.datetime, last_updated_on: datetime.datetime, status: Union[str, "_models.Status"], - summary: "_models.StatusSummary", + summary: "_models.TranslationStatusSummary", error: Optional["_models.DocumentTranslationError"] = None, ): ... diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_single_document_translation_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_single_document_translation_async.py index 1f330192947d..a1e119aa8b96 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_single_document_translation_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_single_document_translation_async.py @@ -48,9 +48,7 @@ async def sample_single_document_translation_async(): document_translate_content = DocumentTranslateContent(document=document_content) async with client: - response_stream = await client.document_translate( - body=document_translate_content, target_language=target_languages - ) + response_stream = await client.translate(body=document_translate_content, target_language=target_languages) translated_response = response_stream.decode("utf-8-sig") # type: ignore[attr-defined] print(f"Translated response: {translated_response}") diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_single_document_translation.py b/sdk/translation/azure-ai-translation-document/samples/sample_single_document_translation.py index ea2ba362838c..2236c81a220c 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_single_document_translation.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_single_document_translation.py @@ -44,7 +44,7 @@ def sample_single_document_translation(): document_content = (file_name, file_contents, file_type) document_translate_content = DocumentTranslateContent(document=document_content) - response_stream = client.document_translate(body=document_translate_content, target_language=target_languages) + response_stream = client.translate(body=document_translate_content, target_language=target_languages) translated_response = response_stream.decode("utf-8-sig") # type: ignore[attr-defined] print(f"Translated response: {translated_response}") diff --git a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py index 5097068584e8..70a2b169a88f 100644 --- a/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/asynctestcase.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ -from azure.ai.translation.document.models import BatchRequest, SourceInput, StartTranslationDetails +from azure.ai.translation.document.models import DocumentBatch, SourceInput, StartTranslationDetails from devtools_testutils import AzureRecordedTestCase from testcase import DocumentTranslationTest, Document from azure.ai.translation.document import DocumentTranslationInput, TranslationTarget @@ -116,7 +116,7 @@ async def _prepare_and_validate_start_translation_details_async(self, async_clie blob_data = Document.create_dummy_docs(docs_count=docs_count) source_input = SourceInput(source_url=self.create_source_container(data=blob_data, variables=variables)) target = TranslationTarget(target_url=self.create_target_container(variables=variables), language=language) - batch_request = BatchRequest(source=source_input, targets=[target]) + batch_request = DocumentBatch(source=source_input, targets=[target]) start_translation_details = StartTranslationDetails(inputs=[batch_request]) # submit job diff --git a/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py b/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py index 7fde2857881f..9d644964c52b 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_model_updates.py @@ -8,7 +8,7 @@ from azure.ai.translation.document.models import ( DocumentStatus, FileFormatType, - StatusSummary, + TranslationStatusSummary, TranslationGlossary, TranslationStatus, ) @@ -177,7 +177,7 @@ def test_document_status_args(self, **kwargs): @recorded_by_proxy def test_translation_status_args(self, **kwargs): # Using keyword-only arguments to specify additional optional parameters - status_summary = StatusSummary( + status_summary = TranslationStatusSummary( total=10, failed=2, success=5, diff --git a/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation.py b/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation.py index 6dc91e6270a9..ded8c71215e9 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation.py @@ -73,9 +73,7 @@ def test_translate_text_document(self, **kwargs): document_translate_content = DocumentTranslateContent(document=self._get_document_content()) # Invoke document translation - response_stream = client.document_translate( - body=document_translate_content, target_language=target_languages - ) + response_stream = client.translate(body=document_translate_content, target_language=target_languages) # validate response translated_response = response_stream.decode("utf-8-sig") @@ -97,9 +95,7 @@ def test_translate_single_csv_glossary(self, **kwargs): ) # Invoke document translation - response_stream = client.document_translate( - body=document_translate_content, target_language=target_languages - ) + response_stream = client.translate(body=document_translate_content, target_language=target_languages) # validate response translated_response = response_stream.decode("utf-8-sig") @@ -123,7 +119,7 @@ def test_translate_multiple_csv_glossary(self, **kwargs): # Invoke document translation and validate exception try: - client.document_translate(body=document_translate_content, target_language=target_languages) + client.translate(body=document_translate_content, target_language=target_languages) except HttpResponseError as e: assert e.status_code == 400 return variables diff --git a/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation_async.py b/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation_async.py index 23f6687d8bef..665edc8f032b 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation_async.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_single_document_translation_async.py @@ -45,9 +45,7 @@ async def test_translate_text_document(self, **kwargs): ) # Invoke document translation - response_stream = await client.document_translate( - body=document_translate_content, target_language=target_languages - ) + response_stream = await client.translate(body=document_translate_content, target_language=target_languages) # validate response translated_response = response_stream.decode("utf-8-sig") @@ -70,9 +68,7 @@ async def test_translate_single_csv_glossary(self, **kwargs): ) # Invoke document translation - response_stream = await client.document_translate( - body=document_translate_content, target_language=target_languages - ) + response_stream = await client.translate(body=document_translate_content, target_language=target_languages) # validate response translated_response = response_stream.decode("utf-8-sig") @@ -97,7 +93,7 @@ async def test_translate_multiple_csv_glossary(self, **kwargs): # Invoke document translation and validate exception try: - await client.document_translate(body=document_translate_content, target_language=target_languages) + await client.translate(body=document_translate_content, target_language=target_languages) except HttpResponseError as e: assert e.status_code == 400 return variables diff --git a/sdk/translation/azure-ai-translation-document/tests/testcase.py b/sdk/translation/azure-ai-translation-document/tests/testcase.py index f1c3565a5d44..8d2abead3989 100644 --- a/sdk/translation/azure-ai-translation-document/tests/testcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/testcase.py @@ -7,7 +7,7 @@ import time import datetime import uuid -from azure.ai.translation.document.models import BatchRequest, SourceInput, StartTranslationDetails +from azure.ai.translation.document.models import DocumentBatch, SourceInput, StartTranslationDetails from devtools_testutils import AzureRecordedTestCase, set_custom_default_matcher from azure.storage.blob import generate_container_sas, ContainerClient from azure.ai.translation.document import DocumentTranslationInput, TranslationTarget @@ -313,7 +313,7 @@ def _prepare_and_validate_start_translation_details(self, client, docs_count, ** blob_data = Document.create_dummy_docs(docs_count=docs_count) source_input = SourceInput(source_url=self.create_source_container(data=blob_data, variables=variables)) target = TranslationTarget(target_url=self.create_target_container(variables=variables), language=language) - batch_request = BatchRequest(source=source_input, targets=[target]) + batch_request = DocumentBatch(source=source_input, targets=[target]) start_translation_details = StartTranslationDetails(inputs=[batch_request]) # submit job diff --git a/sdk/translation/azure-ai-translation-document/tsp-location.yaml b/sdk/translation/azure-ai-translation-document/tsp-location.yaml index 6e85c2a1b5ad..b2debc44a67a 100644 --- a/sdk/translation/azure-ai-translation-document/tsp-location.yaml +++ b/sdk/translation/azure-ai-translation-document/tsp-location.yaml @@ -1,3 +1,3 @@ -commit: 4bf64653380a8582fa070b62ae46b86f2455932e +commit: 17a3ee0a2a03dbfbf1359a1370f994862e02925d repo: Azure/azure-rest-api-specs directory: specification/translation/Azure.AI.DocumentTranslation