From 56475b030bf5bd08644264ca7efe94edf8c2f28e Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Wed, 25 Aug 2021 10:43:05 -0700 Subject: [PATCH] [translation] naming alignment (#20406) * list_all_translation_statuses -> list_translation_statuses * list_all_document_statuses -> list_document_statuses * cancelled -> canceled, cancelling -> canceling * FileFormat -> DocumentTranslationFileFormat * update changelog --- .../CHANGELOG.md | 9 ++-- .../azure-ai-translation-document/README.md | 12 ++--- .../azure/ai/translation/document/__init__.py | 4 +- .../azure/ai/translation/document/_client.py | 49 +++++++++++-------- .../azure/ai/translation/document/_models.py | 43 ++++++++++------ .../translation/document/aio/_client_async.py | 49 +++++++++++-------- .../samples/README.md | 6 +-- .../sample_check_document_statuses_async.py | 6 +-- ...st_document_statuses_with_filters_async.py | 4 +- ...c.py => sample_list_translations_async.py} | 16 +++--- ...le_list_translations_with_filters_async.py | 6 +-- ...ple_translation_with_custom_model_async.py | 2 +- .../samples/sample_check_document_statuses.py | 6 +-- ...ple_list_document_statuses_with_filters.py | 4 +- ...lations.py => sample_list_translations.py} | 16 +++--- .../sample_list_translations_with_filters.py | 6 +-- .../sample_translation_with_custom_model.py | 2 +- .../perfstress_tests/perf_translation.py | 4 +- ...statuses.test_list_document_statuses.yaml} | 0 ...list_document_statuses_filter_by_ids.yaml} | 0 ...t_document_statuses_filter_by_status.yaml} | 0 ...list_document_statuses_mixed_filters.yaml} | 0 ..._statuses_order_by_creation_time_asc.yaml} | 0 ...statuses_order_by_creation_time_desc.yaml} | 0 ...st_document_statuses_with_pagination.yaml} | 0 ...est_list_document_statuses_with_skip.yaml} | 0 ...es_async.test_list_document_statuses.yaml} | 0 ...list_document_statuses_filter_by_ids.yaml} | 0 ...t_document_statuses_filter_by_status.yaml} | 0 ...list_document_statuses_mixed_filters.yaml} | 0 ..._statuses_order_by_creation_time_asc.yaml} | 0 ...statuses_order_by_creation_time_desc.yaml} | 0 ...st_document_statuses_with_pagination.yaml} | 0 ...est_list_document_statuses_with_skip.yaml} | 0 .../tests/test_cancel_translation.py | 4 +- .../tests/test_cancel_translation_async.py | 4 +- .../tests/test_document_status.py | 2 +- .../tests/test_document_status_async.py | 2 +- ...uses.py => test_list_document_statuses.py} | 24 ++++----- ...y => test_list_document_statuses_async.py} | 24 ++++----- .../tests/test_list_translations.py | 28 +++++------ .../tests/test_list_translations_async.py | 28 +++++------ .../tests/testcase.py | 10 ++-- 43 files changed, 202 insertions(+), 168 deletions(-) rename sdk/translation/azure-ai-translation-document/samples/async_samples/{sample_list_all_translations_async.py => sample_list_translations_async.py} (81%) rename sdk/translation/azure-ai-translation-document/samples/{sample_list_all_translations.py => sample_list_translations.py} (82%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses.yaml => test_list_document_statuses.test_list_document_statuses.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_filter_by_ids.yaml => test_list_document_statuses.test_list_document_statuses_filter_by_ids.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_filter_by_status.yaml => test_list_document_statuses.test_list_document_statuses_filter_by_status.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_mixed_filters.yaml => test_list_document_statuses.test_list_document_statuses_mixed_filters.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml => test_list_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml => test_list_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_with_pagination.yaml => test_list_document_statuses.test_list_document_statuses_with_pagination.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses.test_list_document_statuses_with_skip.yaml => test_list_document_statuses.test_list_document_statuses_with_skip.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses.yaml => test_list_document_statuses_async.test_list_document_statuses.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml => test_list_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_filter_by_status.yaml => test_list_document_statuses_async.test_list_document_statuses_filter_by_status.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_mixed_filters.yaml => test_list_document_statuses_async.test_list_document_statuses_mixed_filters.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml => test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml => test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_with_pagination.yaml => test_list_document_statuses_async.test_list_document_statuses_with_pagination.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/recordings/{test_all_document_statuses_async.test_list_document_statuses_with_skip.yaml => test_list_document_statuses_async.test_list_document_statuses_with_skip.yaml} (100%) rename sdk/translation/azure-ai-translation-document/tests/{test_all_document_statuses.py => test_list_document_statuses.py} (84%) rename sdk/translation/azure-ai-translation-document/tests/{test_all_document_statuses_async.py => test_list_document_statuses_async.py} (88%) diff --git a/sdk/translation/azure-ai-translation-document/CHANGELOG.md b/sdk/translation/azure-ai-translation-document/CHANGELOG.md index 8f9a925025e8..4f5682d7ab0b 100644 --- a/sdk/translation/azure-ai-translation-document/CHANGELOG.md +++ b/sdk/translation/azure-ai-translation-document/CHANGELOG.md @@ -2,15 +2,16 @@ ## 1.0.0b5 (Unreleased) -### Features Added - ### Breaking Changes +- Changed: `list_all_translation_statuses` has been renamed to `list_translation_statuses` +- Changed: `list_all_document_statuses` has been renamed to `list_document_statuses` +- Changed: `TranslationStatus` property `documents_cancelled_count` has been renamed to `documents_canceled_count` +- Changed: `FileFormat` has been renamed to `DocumentTranslationFileFormat` +- Changed: Operation statuses `Cancelled` and `Cancelling` have been renamed to `Canceled` and `Canceling`, respectively. ### Bugs Fixed - The operation `id` under `details` of the poller object now populates correctly. -### Other Changes - ## 1.0.0b4 (2021-08-10) ### Features Added diff --git a/sdk/translation/azure-ai-translation-document/README.md b/sdk/translation/azure-ai-translation-document/README.md index d533f60e5585..18476cb83a3c 100644 --- a/sdk/translation/azure-ai-translation-document/README.md +++ b/sdk/translation/azure-ai-translation-document/README.md @@ -303,7 +303,7 @@ credential = AzureKeyCredential("") document_translation_client = DocumentTranslationClient(endpoint, credential) -operations = document_translation_client.list_all_translation_statuses() # type: ItemPaged[TranslationStatus] +operations = document_translation_client.list_translation_statuses() # type: ItemPaged[TranslationStatus] for operation in operations: print("\nID: {}".format(operation.id)) @@ -316,7 +316,7 @@ for operation in operations: print("Of total documents...") print("{} failed".format(operation.documents_failed_count)) print("{} succeeded".format(operation.documents_succeeded_count)) - print("{} cancelled".format(operation.documents_cancelled_count)) + print("{} canceled".format(operation.documents_canceled_count)) ``` To see how to use the Document Translation client library with Azure Storage Blob to upload documents, create SAS tokens @@ -391,7 +391,7 @@ These code samples show common scenario operations with the Azure Document Trans * Begin translating documents: [sample_begin_translation.py][sample_begin_translation] * Translate with multiple inputs: [sample_translate_multiple_inputs.py][sample_translate_multiple_inputs] * Check the status of documents: [sample_check_document_statuses.py][sample_check_document_statuses] -* List all submitted translation operations: [sample_list_all_translations.py][sample_list_all_translations] +* List all submitted translation operations: [sample_list_translations.py][sample_list_translations] * Apply a custom glossary to translation: [sample_translation_with_glossaries.py][sample_translation_with_glossaries] * Use Azure Blob Storage to set up translation resources: [sample_translation_with_azure_blob.py][sample_translation_with_azure_blob] @@ -405,7 +405,7 @@ are found under the `azure.ai.translation.document.aio` namespace. * Begin translating documents: [sample_begin_translation_async.py][sample_begin_translation_async] * Translate with multiple inputs: [sample_translate_multiple_inputs_async.py][sample_translate_multiple_inputs_async] * Check the status of documents: [sample_check_document_statuses_async.py][sample_check_document_statuses_async] -* List all submitted translation operations: [sample_list_all_translations_async.py][sample_list_all_translations_async] +* List all submitted translation operations: [sample_list_translations_async.py][sample_list_translations_async] * Apply a custom glossary to translation: [sample_translation_with_glossaries_async.py][sample_translation_with_glossaries_async] * Use Azure Blob Storage to set up translation resources: [sample_translation_with_azure_blob_async.py][sample_translation_with_azure_blob_async] @@ -464,8 +464,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [sample_translate_multiple_inputs_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translate_multiple_inputs_async.py [sample_check_document_statuses]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py [sample_check_document_statuses_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py -[sample_list_all_translations]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_list_all_translations.py -[sample_list_all_translations_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_all_translations_async.py +[sample_list_translations]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py +[sample_list_translations_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_async.py [sample_translation_with_glossaries]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_glossaries.py [sample_translation_with_glossaries_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_glossaries_async.py [sample_translation_with_azure_blob]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_azure_blob.py diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/__init__.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/__init__.py index 5baaff7595f5..255f820559af 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/__init__.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/__init__.py @@ -18,7 +18,7 @@ DocumentTranslationError, TranslationGlossary, DocumentTranslationInput, - FileFormat, + DocumentTranslationFileFormat, ) __VERSION__ = VERSION @@ -30,7 +30,7 @@ "DocumentTranslationInput", "TranslationGlossary", "StorageInputType", - "FileFormat", + "DocumentTranslationFileFormat", "TranslationTarget", "TranslationStatus", "DocumentStatus", diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py index 39dfbdbcce64..f46d46774234 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py @@ -14,7 +14,8 @@ TranslationStatus, DocumentStatus, DocumentTranslationInput, - FileFormat, + DocumentTranslationFileFormat, + convert_status ) from ._user_agent import USER_AGENT from ._polling import TranslationPolling, DocumentTranslationLROPollingMethod @@ -174,7 +175,7 @@ def deserialization_callback( raw_response, _, headers ): # pylint: disable=unused-argument translation_status = json.loads(raw_response.http_response.text()) - return self.list_all_document_statuses(translation_status["id"]) + return self.list_document_statuses(translation_status["id"]) polling_interval = kwargs.pop( "polling_interval", @@ -228,9 +229,9 @@ def cancel_translation(self, translation_id, **kwargs): # type: (str, **Any) -> None """Cancel a currently processing or queued translation operation. - A translation will not be cancelled if it is already completed, failed, or cancelling. - All documents that have completed translation will not be cancelled and will be charged. - If possible, all pending documents will be cancelled. + A translation will not be canceled if it is already completed, failed, or canceling. + All documents that have completed translation will not be canceled and will be charged. + If possible, all pending documents will be canceled. :param str translation_id: The translation operation ID. :return: None @@ -241,7 +242,7 @@ def cancel_translation(self, translation_id, **kwargs): self._client.document_translation.cancel_translation(translation_id, **kwargs) @distributed_trace - def list_all_translation_statuses(self, **kwargs): + def list_translation_statuses(self, **kwargs): # type: (**Any) -> ItemPaged[TranslationStatus] """List all the submitted translation operations under the Document Translation resource. @@ -251,7 +252,7 @@ def list_all_translation_statuses(self, **kwargs): :keyword int results_per_page: is the number of operations returned per page. :keyword list[str] translation_ids: translation operations ids to filter by. :keyword list[str] statuses: translation operation statuses to filter by. Options include - 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling', + 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling', and 'ValidationFailed'. :keyword created_after: get operations created after certain datetime. :paramtype created_after: Union[str, datetime.datetime] @@ -267,14 +268,17 @@ def list_all_translation_statuses(self, **kwargs): .. admonition:: Example: - .. literalinclude:: ../samples/sample_list_all_translations.py - :start-after: [START list_all_translations] - :end-before: [END list_all_translations] + .. literalinclude:: ../samples/sample_list_translations.py + :start-after: [START list_translations] + :end-before: [END list_translations] :language: python :dedent: 4 :caption: List all submitted translations under the resource. """ + statuses = kwargs.pop("statuses", None) + if statuses: + statuses = [convert_status(status, ll=True) for status in statuses] order_by = convert_order_by(kwargs.pop("order_by", None)) created_after = kwargs.pop("created_after", None) created_before = kwargs.pop("created_before", None) @@ -304,11 +308,12 @@ def _convert_from_generated_model( created_date_time_utc_end=created_before, ids=translation_ids, order_by=order_by, + statuses=statuses, **kwargs ) @distributed_trace - def list_all_document_statuses(self, translation_id, **kwargs): + def list_document_statuses(self, translation_id, **kwargs): # type: (str, **Any) -> ItemPaged[DocumentStatus] """List all the document statuses for a given translation operation. @@ -319,7 +324,7 @@ def list_all_document_statuses(self, translation_id, **kwargs): :keyword int results_per_page: is the number of documents returned per page. :keyword list[str] document_ids: document IDs to filter by. :keyword list[str] statuses: document statuses to filter by. Options include - 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling', + 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling', and 'ValidationFailed'. :keyword created_after: get document created after certain datetime. :paramtype created_after: Union[str, datetime.datetime] @@ -336,13 +341,16 @@ def list_all_document_statuses(self, translation_id, **kwargs): .. admonition:: Example: .. literalinclude:: ../samples/sample_check_document_statuses.py - :start-after: [START list_all_document_statuses] - :end-before: [END list_all_document_statuses] + :start-after: [START list_document_statuses] + :end-before: [END list_document_statuses] :language: python :dedent: 4 :caption: List all the document statuses as they are being translated. """ + statuses = kwargs.pop("statuses", None) + if statuses: + statuses = [convert_status(status, ll=True) for status in statuses] order_by = convert_order_by(kwargs.pop("order_by", None)) created_after = kwargs.pop("created_after", None) created_before = kwargs.pop("created_before", None) @@ -375,6 +383,7 @@ def _convert_from_generated_model(generated_model): created_date_time_utc_end=created_before, ids=document_ids, order_by=order_by, + statuses=statuses, **kwargs ) @@ -399,34 +408,34 @@ def get_document_status(self, translation_id, document_id, **kwargs): @distributed_trace def get_supported_glossary_formats(self, **kwargs): - # type: (**Any) -> List[FileFormat] + # type: (**Any) -> List[DocumentTranslationFileFormat] """Get the list of the glossary formats supported by the Document Translation service. :return: A list of supported glossary formats. - :rtype: List[FileFormat] + :rtype: List[DocumentTranslationFileFormat] :raises ~azure.core.exceptions.HttpResponseError: """ glossary_formats = ( self._client.document_translation.get_supported_glossary_formats(**kwargs) ) - return FileFormat._from_generated_list( # pylint: disable=protected-access + return DocumentTranslationFileFormat._from_generated_list( # pylint: disable=protected-access glossary_formats.value ) @distributed_trace def get_supported_document_formats(self, **kwargs): - # type: (**Any) -> List[FileFormat] + # type: (**Any) -> List[DocumentTranslationFileFormat] """Get the list of the document formats supported by the Document Translation service. :return: A list of supported document formats for translation. - :rtype: List[FileFormat] + :rtype: List[DocumentTranslationFileFormat] :raises ~azure.core.exceptions.HttpResponseError: """ document_formats = ( self._client.document_translation.get_supported_document_formats(**kwargs) ) - return FileFormat._from_generated_list( # pylint: disable=protected-access + return DocumentTranslationFileFormat._from_generated_list( # pylint: disable=protected-access document_formats.value ) diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_models.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_models.py index d301c9e6a204..b918a42697de 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_models.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_models.py @@ -15,6 +15,20 @@ ) +def convert_status(status, ll=False): + if ll is False: + if status == "Cancelled": + return "Canceled" + if status == "Cancelling": + return "Canceling" + elif ll is True: + if status == "Canceled": + return "Cancelled" + if status == "Canceling": + return "Cancelling" + return status + + class TranslationGlossary(object): # pylint: disable=useless-object-inheritance """Glossary / translation memory to apply to the translation. @@ -256,8 +270,8 @@ class TranslationStatus( * `NotStarted` - the operation has not begun yet. * `Running` - translation is in progress. * `Succeeded` - at least one document translated successfully within the operation. - * `Cancelled` - the operation was cancelled. - * `Cancelling` - the operation is being cancelled. + * `Canceled` - the operation was canceled. + * `Canceling` - the operation is being canceled. * `ValidationFailed` - the input failed validation. E.g. there was insufficient permissions on blob containers. * `Failed` - all the documents within the operation failed. @@ -269,7 +283,7 @@ class TranslationStatus( :ivar int documents_succeeded_count: Number of successful translations on documents. :ivar int documents_in_progress_count: Number of translations on documents in progress. :ivar int documents_not_yet_started_count: Number of documents that have not yet started being translated. - :ivar int documents_cancelled_count: Number of documents that were cancelled for translation. + :ivar int documents_canceled_count: Number of documents that were canceled for translation. :ivar int total_characters_charged: Total characters charged across all documents within the translation operation. """ @@ -289,18 +303,19 @@ def __init__(self, **kwargs): self.documents_not_yet_started_count = kwargs.get( "documents_not_yet_started_count", None ) - self.documents_cancelled_count = kwargs.get("documents_cancelled_count", None) + self.documents_canceled_count = kwargs.get("documents_canceled_count", None) self.total_characters_charged = kwargs.get("total_characters_charged", None) @classmethod def _from_generated(cls, batch_status_details): if not batch_status_details: return cls() + return cls( id=batch_status_details.id, created_on=batch_status_details.created_date_time_utc, last_updated_on=batch_status_details.last_action_date_time_utc, - status=batch_status_details.status, + status=convert_status(batch_status_details.status), error=DocumentTranslationError._from_generated( # pylint: disable=protected-access batch_status_details.error ) @@ -311,7 +326,7 @@ def _from_generated(cls, batch_status_details): documents_succeeded_count=batch_status_details.summary.success, documents_in_progress_count=batch_status_details.summary.in_progress, documents_not_yet_started_count=batch_status_details.summary.not_yet_started, - documents_cancelled_count=batch_status_details.summary.cancelled, + documents_canceled_count=batch_status_details.summary.cancelled, total_characters_charged=batch_status_details.summary.total_character_charged, ) @@ -321,7 +336,7 @@ def __repr__(self): "last_updated_on={}, status={}, error={}, documents_total_count={}, " "documents_failed_count={}, documents_succeeded_count={}, " "documents_in_progress_count={}, documents_not_yet_started_count={}, " - "documents_cancelled_count={}, total_characters_charged={})".format( + "documents_canceled_count={}, total_characters_charged={})".format( self.id, self.created_on, self.last_updated_on, @@ -332,7 +347,7 @@ def __repr__(self): self.documents_succeeded_count, self.documents_in_progress_count, self.documents_not_yet_started_count, - self.documents_cancelled_count, + self.documents_canceled_count, self.total_characters_charged, )[:1024] ) @@ -357,8 +372,8 @@ class DocumentStatus( * `Running` - translation is in progress for document * `Succeeded` - translation succeeded for the document * `Failed` - the document failed to translate. Check the error property. - * `Cancelled` - the operation was cancelled, the document was not translated. - * `Cancelling` - the operation is cancelling, the document will not be translated. + * `Canceled` - the operation was canceled, the document was not translated. + * `Canceling` - the operation is canceling, the document will not be translated. :ivar str translated_to: The language code of the language the document was translated to, if successful. :ivar error: Returned if there is an error with the particular document. @@ -390,7 +405,7 @@ def _from_generated(cls, doc_status): translated_document_url=doc_status.path, created_on=doc_status.created_date_time_utc, last_updated_on=doc_status.last_action_date_time_utc, - status=doc_status.status, + status=convert_status(doc_status.status), translated_to=doc_status.to, error=DocumentTranslationError._from_generated( # pylint: disable=protected-access doc_status.error @@ -462,7 +477,7 @@ def __repr__(self): )[:1024] -class FileFormat(object): # pylint: disable=useless-object-inheritance, R0903 +class DocumentTranslationFileFormat(object): # pylint: disable=useless-object-inheritance, R0903 """Possible file formats supported by the Document Translation service. :ivar file_format: Name of the format. @@ -498,13 +513,13 @@ def _from_generated(cls, file_format): @staticmethod def _from_generated_list(file_formats): return [ - FileFormat._from_generated(file_formats) for file_formats in file_formats + DocumentTranslationFileFormat._from_generated(file_formats) for file_formats in file_formats ] def __repr__(self): # pylint: disable=line-too-long return ( - "FileFormat(file_format={}, file_extensions={}, " + "DocumentTranslationFileFormat(file_format={}, file_extensions={}, " "content_types={}, format_versions={}, default_format_version={}".format( self.file_format, self.file_extensions, diff --git a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py index 1ae6622521ac..02ff2d23e53a 100644 --- a/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py +++ b/sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py @@ -16,8 +16,9 @@ from .._models import ( TranslationStatus, DocumentTranslationInput, - FileFormat, + DocumentTranslationFileFormat, DocumentStatus, + convert_status ) from .._helpers import ( get_http_logging_policy, @@ -183,7 +184,7 @@ def deserialization_callback( raw_response, _, headers ): # pylint: disable=unused-argument translation_status = json.loads(raw_response.http_response.text()) - return self.list_all_document_statuses(translation_status["id"]) + return self.list_document_statuses(translation_status["id"]) polling_interval = kwargs.pop( "polling_interval", @@ -238,9 +239,9 @@ async def cancel_translation(self, translation_id, **kwargs): # type: (str, **Any) -> None """Cancel a currently processing or queued translation operation. - A translation will not be cancelled if it is already completed, failed, or cancelling. - All documents that have completed translation will not be cancelled and will be charged. - If possible, all pending documents will be cancelled. + A translation will not be canceled if it is already completed, failed, or canceling. + All documents that have completed translation will not be canceled and will be charged. + If possible, all pending documents will be canceled. :param str translation_id: The translation operation ID. :return: None @@ -253,7 +254,7 @@ async def cancel_translation(self, translation_id, **kwargs): ) @distributed_trace - def list_all_translation_statuses(self, **kwargs): + def list_translation_statuses(self, **kwargs): # type: (**Any) -> AsyncItemPaged[TranslationStatus] """List all the submitted translation operations under the Document Translation resource. @@ -263,7 +264,7 @@ def list_all_translation_statuses(self, **kwargs): :keyword int results_per_page: is the number of operations returned per page. :keyword list[str] translation_ids: translation operations ids to filter by. :keyword list[str] statuses: translation operation statuses to filter by. Options include - 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling', + 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling', and 'ValidationFailed'. :keyword created_after: get operations created after certain datetime. :paramtype created_after: Union[str, datetime.datetime] @@ -279,14 +280,17 @@ def list_all_translation_statuses(self, **kwargs): .. admonition:: Example: - .. literalinclude:: ../samples/async_samples/sample_list_all_translations_async.py - :start-after: [START list_all_translations_async] - :end-before: [END list_all_translations_async] + .. literalinclude:: ../samples/async_samples/sample_list_translations_async.py + :start-after: [START list_translations_async] + :end-before: [END list_translations_async] :language: python :dedent: 4 :caption: List all submitted translations under the resource. """ + statuses = kwargs.pop("statuses", None) + if statuses: + statuses = [convert_status(status, ll=True) for status in statuses] order_by = convert_order_by(kwargs.pop("order_by", None)) created_after = kwargs.pop("created_after", None) created_before = kwargs.pop("created_before", None) @@ -313,11 +317,12 @@ def _convert_from_generated_model(generated_model): created_date_time_utc_end=created_before, ids=translation_ids, order_by=order_by, + statuses=statuses, **kwargs ) @distributed_trace - def list_all_document_statuses(self, translation_id, **kwargs): + def list_document_statuses(self, translation_id, **kwargs): # type: (str, **Any) -> AsyncItemPaged[DocumentStatus] """List all the document statuses for a given translation operation. @@ -328,7 +333,7 @@ def list_all_document_statuses(self, translation_id, **kwargs): :keyword int results_per_page: is the number of documents returned per page. :keyword list[str] document_ids: document IDs to filter by. :keyword list[str] statuses: document statuses to filter by. Options include - 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling', + 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling', and 'ValidationFailed'. :keyword created_after: get document created after certain datetime. :paramtype created_after: Union[str, datetime.datetime] @@ -345,13 +350,16 @@ def list_all_document_statuses(self, translation_id, **kwargs): .. admonition:: Example: .. literalinclude:: ../samples/async_samples/sample_check_document_statuses_async.py - :start-after: [START list_all_document_statuses_async] - :end-before: [END list_all_document_statuses_async] + :start-after: [START list_document_statuses_async] + :end-before: [END list_document_statuses_async] :language: python :dedent: 4 :caption: List all the document statuses as they are being translated. """ + statuses = kwargs.pop("statuses", None) + if statuses: + statuses = [convert_status(status, ll=True) for status in statuses] order_by = convert_order_by(kwargs.pop("order_by", None)) created_after = kwargs.pop("created_after", None) created_before = kwargs.pop("created_before", None) @@ -383,6 +391,7 @@ def _convert_from_generated_model(generated_model): created_date_time_utc_end=created_before, ids=document_ids, order_by=order_by, + statuses=statuses, **kwargs ) @@ -405,11 +414,11 @@ async def get_document_status(self, translation_id, document_id, **kwargs): @distributed_trace_async async def get_supported_glossary_formats(self, **kwargs): - # type: (**Any) -> List[FileFormat] + # type: (**Any) -> List[DocumentTranslationFileFormat] """Get the list of the glossary formats supported by the Document Translation service. :return: A list of supported glossary formats. - :rtype: List[FileFormat] + :rtype: List[DocumentTranslationFileFormat] :raises ~azure.core.exceptions.HttpResponseError: """ glossary_formats = ( @@ -418,15 +427,15 @@ async def get_supported_glossary_formats(self, **kwargs): ) ) # pylint: disable=protected-access - return FileFormat._from_generated_list(glossary_formats.value) + return DocumentTranslationFileFormat._from_generated_list(glossary_formats.value) @distributed_trace_async async def get_supported_document_formats(self, **kwargs): - # type: (**Any) -> List[FileFormat] + # type: (**Any) -> List[DocumentTranslationFileFormat] """Get the list of the document formats supported by the Document Translation service. :return: A list of supported document formats for translation. - :rtype: List[FileFormat] + :rtype: List[DocumentTranslationFileFormat] :raises ~azure.core.exceptions.HttpResponseError: """ document_formats = ( @@ -435,4 +444,4 @@ async def get_supported_document_formats(self, **kwargs): ) ) # pylint: disable=protected-access - return FileFormat._from_generated_list(document_formats.value) + return DocumentTranslationFileFormat._from_generated_list(document_formats.value) diff --git a/sdk/translation/azure-ai-translation-document/samples/README.md b/sdk/translation/azure-ai-translation-document/samples/README.md index 1592b7a08413..5b4901b15e9e 100644 --- a/sdk/translation/azure-ai-translation-document/samples/README.md +++ b/sdk/translation/azure-ai-translation-document/samples/README.md @@ -25,7 +25,7 @@ These sample programs show common scenarios for the Document Translation client' |[sample_translate_multiple_inputs.py][sample_translate_multiple_inputs] and [sample_translate_multiple_inputs_async.py][sample_translate_multiple_inputs_async]|Translate multiple source containers with documents to multiple target containers in different languages| |[sample_translation_with_glossaries.py][begin_translation_with_glossaries] and [sample_translation_with_glossaries_async.py][begin_translation_with_glossaries_async]|Translate your documents using custom glossaries| |[sample_check_document_statuses.py][check_document_statuses] and [sample_check_document_statuses_async.py][check_document_statuses_async]|Check status of submitted documents| -|[sample_list_all_translations.py][list_all_translations] and [sample_list_all_translations_async.py][list_all_translations_async]|Check status of all submitted translation operations| +|[sample_list_translations.py][list_translations] and [sample_list_translations_async.py][list_translations_async]|Check status of all submitted translation operations| ## Prerequisites @@ -75,8 +75,8 @@ what you can do with the Azure Document Translation client library. [begin_translation_with_glossaries_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_glossaries_async.py [check_document_statuses]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py [check_document_statuses_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py -[list_all_translations]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/sample_list_all_translations.py -[list_all_translations_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_all_translations_async.py +[list_translations]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py +[list_translations_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_async.py [pip]: https://pypi.org/project/pip/ [azure_subscription]: https://azure.microsoft.com/free/ [azure_document_translation_account]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=python diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py index c8e709a30f8a..c431a32a66db 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_check_document_statuses_async.py @@ -30,7 +30,7 @@ async def sample_document_status_checks_async(): - # [START list_all_document_statuses_async] + # [START list_document_statuses_async] import os from azure.core.credentials import AzureKeyCredential from azure.ai.translation.document.aio import DocumentTranslationClient @@ -49,7 +49,7 @@ async def sample_document_status_checks_async(): while poller.status() in ["Running", "NotStarted"]: await asyncio.sleep(30) - doc_statuses = client.list_all_document_statuses(poller.id) + doc_statuses = client.list_document_statuses(poller.id) async for document in doc_statuses: if document.id not in completed_docs: if document.status == "Succeeded": @@ -68,7 +68,7 @@ async def sample_document_status_checks_async(): )) print("\nTranslation completed.") - # [END list_all_document_statuses_async] + # [END list_document_statuses_async] async def main(): diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_document_statuses_with_filters_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_document_statuses_with_filters_async.py index 52ffbeee5b98..5c11e92987e6 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_document_statuses_with_filters_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_document_statuses_with_filters_async.py @@ -50,13 +50,13 @@ async def sample_list_document_statuses_with_filters_async(): ''' start = datetime(2021, 4, 12) end = datetime(2021, 4, 14) - statuses = ["Cancelled", "Failed"] + statuses = ["Canceled", "Failed"] order_by = ["created_on desc"] results_per_page = 2 skip = 3 async with client: - filtered_docs = client.list_all_document_statuses( + filtered_docs = client.list_document_statuses( translation_id, # filters statuses=statuses, diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_all_translations_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_async.py similarity index 81% rename from sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_all_translations_async.py rename to sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_async.py index e00d34c61771..c74863e5a1e3 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_all_translations_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_async.py @@ -5,7 +5,7 @@ # ------------------------------------ """ -FILE: list_all_translations_async.py +FILE: list_translations_async.py DESCRIPTION: This sample demonstrates how to list all the submitted translation operations for the resource. @@ -14,7 +14,7 @@ with the appropriate permissions, see the README. USAGE: - python list_all_translations_async.py + python list_translations_async.py Set the environment variables with your own values before running the sample: 1) AZURE_DOCUMENT_TRANSLATION_ENDPOINT - the endpoint to your Document Translation resource. @@ -24,9 +24,9 @@ import asyncio -async def sample_list_all_translations_async(): +async def sample_list_translations_async(): import os - # [START list_all_translations_async] + # [START list_translations_async] from azure.core.credentials import AzureKeyCredential from azure.ai.translation.document.aio import DocumentTranslationClient @@ -35,7 +35,7 @@ async def sample_list_all_translations_async(): client = DocumentTranslationClient(endpoint, AzureKeyCredential(key)) async with client: - operations = client.list_all_translation_statuses() # type: AsyncItemPaged[TranslationStatus] + operations = client.list_translation_statuses() # type: AsyncItemPaged[TranslationStatus] async for operation in operations: print("ID: {}".format(operation.id)) @@ -48,12 +48,12 @@ async def sample_list_all_translations_async(): print("\nOf total documents...") print("{} failed".format(operation.documents_failed_count)) print("{} succeeded".format(operation.documents_succeeded_count)) - print("{} cancelled\n".format(operation.documents_cancelled_count)) - # [END list_all_translations_async] + print("{} canceled\n".format(operation.documents_canceled_count)) + # [END list_translations_async] async def main(): - await sample_list_all_translations_async() + await sample_list_translations_async() if __name__ == '__main__': loop = asyncio.get_event_loop() diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_with_filters_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_with_filters_async.py index 5f5f731ee14c..670db7b2f26a 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_with_filters_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_list_translations_with_filters_async.py @@ -47,13 +47,13 @@ async def sample_list_translations_with_filters_async(): ''' start = datetime(2021, 4, 12) end = datetime(2021, 4, 14) - statuses = ["Cancelled", "Failed"] + statuses = ["Canceled", "Failed"] order_by = ["created_on desc"] results_per_page = 2 skip = 3 # list translation operations - submitted_translations = client.list_all_translation_statuses( + submitted_translations = client.list_translation_statuses( # filters statuses=statuses, created_after=start, @@ -81,7 +81,7 @@ def display_translation_info(translation): print("\nOf total documents...") print("{} failed".format(translation.documents_failed_count)) print("{} succeeded".format(translation.documents_succeeded_count)) - print("{} cancelled\n".format(translation.documents_cancelled_count)) + print("{} canceled\n".format(translation.documents_canceled_count)) async def main(): diff --git a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_custom_model_async.py b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_custom_model_async.py index 7456aaff0e72..ff5709380e48 100644 --- a/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_custom_model_async.py +++ b/sdk/translation/azure-ai-translation-document/samples/async_samples/sample_translation_with_custom_model_async.py @@ -62,7 +62,7 @@ async def sample_translation_with_custom_model_async(): print("{} failed".format(result.documents_failed_count)) print("{} succeeded".format(result.documents_succeeded_count)) - doc_results = client.list_all_document_statuses(result.id) + doc_results = client.list_document_statuses(result.id) async for document in doc_results: print("Document ID: {}".format(document.id)) print("Document status: {}".format(document.status)) diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py b/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py index 13b3a0c5ead1..2622d48c81ab 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_check_document_statuses.py @@ -28,7 +28,7 @@ def sample_document_status_checks(): - # [START list_all_document_statuses] + # [START list_document_statuses] import os import time from azure.core.credentials import AzureKeyCredential @@ -47,7 +47,7 @@ def sample_document_status_checks(): while not poller.done(): time.sleep(30) - doc_statuses = client.list_all_document_statuses(poller.id) + doc_statuses = client.list_document_statuses(poller.id) for document in doc_statuses: if document.id not in completed_docs: if document.status == "Succeeded": @@ -66,7 +66,7 @@ def sample_document_status_checks(): )) print("\nTranslation completed.") - # [END list_all_document_statuses] + # [END list_document_statuses] if __name__ == '__main__': diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_list_document_statuses_with_filters.py b/sdk/translation/azure-ai-translation-document/samples/sample_list_document_statuses_with_filters.py index fd110f43cacd..286594854f0b 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_list_document_statuses_with_filters.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_list_document_statuses_with_filters.py @@ -48,12 +48,12 @@ def sample_list_document_statuses_with_filters(): ''' start = datetime(2021, 4, 12) end = datetime(2021, 4, 14) - statuses = ["Cancelled", "Failed"] + statuses = ["Canceled", "Failed"] order_by = ["created_on desc"] results_per_page = 2 skip = 3 - filtered_docs = client.list_all_document_statuses( + filtered_docs = client.list_document_statuses( translation_id, # filters statuses=statuses, diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_list_all_translations.py b/sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py similarity index 82% rename from sdk/translation/azure-ai-translation-document/samples/sample_list_all_translations.py rename to sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py index ac96fa6be557..9271adfdc051 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_list_all_translations.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py @@ -5,7 +5,7 @@ # ------------------------------------ """ -FILE: list_all_translations.py +FILE: list_translations.py DESCRIPTION: This sample demonstrates how to list all the submitted translation operations for the resource. @@ -14,7 +14,7 @@ with the appropriate permissions, see the README. USAGE: - python list_all_translations.py + python list_translations.py Set the environment variables with your own values before running the sample: 1) AZURE_DOCUMENT_TRANSLATION_ENDPOINT - the endpoint to your Document Translation resource. @@ -22,9 +22,9 @@ """ -def sample_list_all_translations(): +def sample_list_translations(): import os - # [START list_all_translations] + # [START list_translations] from azure.core.credentials import AzureKeyCredential from azure.ai.translation.document import DocumentTranslationClient @@ -33,7 +33,7 @@ def sample_list_all_translations(): key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"] client = DocumentTranslationClient(endpoint, AzureKeyCredential(key)) - operations = client.list_all_translation_statuses() # type: ItemPaged[TranslationStatus] + operations = client.list_translation_statuses() # type: ItemPaged[TranslationStatus] for operation in operations: print("ID: {}".format(operation.id)) @@ -46,10 +46,10 @@ def sample_list_all_translations(): print("\nOf total documents...") print("{} failed".format(operation.documents_failed_count)) print("{} succeeded".format(operation.documents_succeeded_count)) - print("{} cancelled\n".format(operation.documents_cancelled_count)) + print("{} canceled\n".format(operation.documents_canceled_count)) - # [END list_all_translations] + # [END list_translations] if __name__ == '__main__': - sample_list_all_translations() + sample_list_translations() diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_list_translations_with_filters.py b/sdk/translation/azure-ai-translation-document/samples/sample_list_translations_with_filters.py index 98703ccdef98..d821c6673a8a 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_list_translations_with_filters.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_list_translations_with_filters.py @@ -48,13 +48,13 @@ def sample_list_translations_with_filters(): ''' start = datetime(2021, 4, 12) end = datetime(2021, 4, 14) - statuses = ["Cancelled", "Failed"] + statuses = ["Canceled", "Failed"] order_by = ["created_on desc"] results_per_page = 2 skip = 3 # list translation operations - submitted_translations = client.list_all_translation_statuses( + submitted_translations = client.list_translation_statuses( # filters statuses=statuses, created_after=start, @@ -82,7 +82,7 @@ def display_translation_info(translation): print("\nOf total documents...") print("{} failed".format(translation.documents_failed_count)) print("{} succeeded".format(translation.documents_succeeded_count)) - print("{} cancelled\n".format(translation.documents_cancelled_count)) + print("{} canceled\n".format(translation.documents_canceled_count)) if __name__ == '__main__': diff --git a/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_custom_model.py b/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_custom_model.py index cf73444961b2..011f687fbadc 100644 --- a/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_custom_model.py +++ b/sdk/translation/azure-ai-translation-document/samples/sample_translation_with_custom_model.py @@ -59,7 +59,7 @@ def sample_translation_with_custom_model(): print("{} failed".format(result.documents_failed_count)) print("{} succeeded".format(result.documents_succeeded_count)) - doc_results = client.list_all_document_statuses(result.id) + doc_results = client.list_document_statuses(result.id) for document in doc_results: print("Document ID: {}".format(document.id)) print("Document status: {}".format(document.status)) diff --git a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py index 10e68940aa8b..6d96ca0d8302 100644 --- a/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py +++ b/sdk/translation/azure-ai-translation-document/tests/perfstress_tests/perf_translation.py @@ -108,7 +108,7 @@ async def close(self): def run_sync(self): """The synchronous perf test.""" - statuses = self.service_client.list_all_document_statuses( + statuses = self.service_client.list_document_statuses( self.translation_id ) for doc in statuses: @@ -116,7 +116,7 @@ def run_sync(self): async def run_async(self): """The asynchronous perf test.""" - statuses = self.async_service_client.list_all_document_statuses( + statuses = self.async_service_client.list_document_statuses( self.translation_id ) async for doc in statuses: diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_filter_by_ids.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_filter_by_ids.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_filter_by_ids.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_filter_by_ids.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_filter_by_status.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_filter_by_status.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_filter_by_status.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_filter_by_status.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_mixed_filters.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_mixed_filters.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_mixed_filters.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_mixed_filters.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_order_by_creation_time_asc.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_order_by_creation_time_desc.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_with_pagination.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_with_pagination.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_with_pagination.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_with_pagination.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_with_skip.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_with_skip.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses.test_list_document_statuses_with_skip.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses.test_list_document_statuses_with_skip.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_filter_by_ids.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_filter_by_status.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_filter_by_status.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_filter_by_status.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_filter_by_status.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_mixed_filters.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_mixed_filters.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_mixed_filters.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_mixed_filters.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_asc.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_order_by_creation_time_desc.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_with_pagination.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_with_pagination.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_with_pagination.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_with_pagination.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_with_skip.yaml b/sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_with_skip.yaml similarity index 100% rename from sdk/translation/azure-ai-translation-document/tests/recordings/test_all_document_statuses_async.test_list_document_statuses_with_skip.yaml rename to sdk/translation/azure-ai-translation-document/tests/recordings/test_list_document_statuses_async.test_list_document_statuses_with_skip.yaml diff --git a/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation.py b/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation.py index 544e4c09237d..d0f61e10c0c8 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation.py @@ -34,12 +34,12 @@ def test_cancel_translation(self, client): client.cancel_translation(poller.id) # wait for propagation - wait_time = 15 # for 'cancelled' status to propagate, if test failed, increase this value! + wait_time = 15 # for 'canceled' status to propagate, if test failed, increase this value! self.wait(duration=wait_time) # check translation status translation_details = client.get_translation_status(poller.id) - self._validate_translations(translation_details, status="Cancelled", total=docs_count) + self._validate_translations(translation_details, status="Canceled", total=docs_count) try: poller.wait() except HttpResponseError: diff --git a/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation_async.py b/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation_async.py index f3a159592baf..9e4c82b091ba 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation_async.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_cancel_translation_async.py @@ -35,12 +35,12 @@ async def test_cancel_translation(self, client): await client.cancel_translation(poller.id) # wait for propagation - wait_time = 15 # for 'cancelled' status to propagate, if test failed, increase this value! + wait_time = 15 # for 'canceled' status to propagate, if test failed, increase this value! self.wait(duration=wait_time) # check translation status translation_details = await client.get_translation_status(poller.id) - self._validate_translations(translation_details, status="Cancelled", total=docs_count) + self._validate_translations(translation_details, status="Canceled", total=docs_count) try: await poller.wait() except HttpResponseError: diff --git a/sdk/translation/azure-ai-translation-document/tests/test_document_status.py b/sdk/translation/azure-ai-translation-document/tests/test_document_status.py index b09147110908..921f7975863d 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_document_status.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_document_status.py @@ -39,7 +39,7 @@ def test_list_statuses(self, client): translation_id = self._begin_and_validate_translation(client, translation_inputs, len(blob_data), target_language) # get doc statuses - doc_statuses = client.list_all_document_statuses(translation_id) + doc_statuses = client.list_document_statuses(translation_id) self.assertIsNotNone(doc_statuses) # get first doc diff --git a/sdk/translation/azure-ai-translation-document/tests/test_document_status_async.py b/sdk/translation/azure-ai-translation-document/tests/test_document_status_async.py index 3054be8330e9..0d6d8b1ac3c6 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_document_status_async.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_document_status_async.py @@ -41,7 +41,7 @@ async def test_list_statuses(self, client): translation_id = await self._begin_and_validate_translation_async(client, translation_inputs, len(blob_data), target_language) # get doc statuses - doc_statuses = client.list_all_document_statuses(translation_id) + doc_statuses = client.list_document_statuses(translation_id) self.assertIsNotNone(doc_statuses) # get first doc diff --git a/sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses.py b/sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses.py similarity index 84% rename from sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses.py rename to sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses.py index 57e1a2f437a4..fa33f2a98cca 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses.py @@ -27,7 +27,7 @@ def test_list_document_statuses(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # list docs statuses - doc_statuses = list(client.list_all_document_statuses(poller.id)) # convert from generic iterator to list + doc_statuses = list(client.list_document_statuses(poller.id)) # convert from generic iterator to list self.assertEqual(len(doc_statuses), docs_count) for document in doc_statuses: @@ -45,7 +45,7 @@ def test_list_document_statuses_with_pagination(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses_pages = list(client.list_all_document_statuses(translation_id=poller.id, results_per_page=results_per_page).by_page()) + doc_statuses_pages = list(client.list_document_statuses(translation_id=poller.id, results_per_page=results_per_page).by_page()) self.assertEqual(len(doc_statuses_pages), no_of_pages) # iterate by page @@ -67,7 +67,7 @@ def test_list_document_statuses_with_skip(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = list(client.list_all_document_statuses(translation_id=poller.id, skip=skip)) + doc_statuses = list(client.list_document_statuses(translation_id=poller.id, skip=skip)) self.assertEqual(len(doc_statuses), docs_count - skip) # iterate over docs @@ -86,15 +86,15 @@ def test_list_document_statuses_filter_by_status(self, client): # list operations statuses = ["NotStarted"] - doc_statuses = list(client.list_all_document_statuses(poller.id, statuses=statuses)) + doc_statuses = list(client.list_document_statuses(poller.id, statuses=statuses)) assert(len(doc_statuses) == 0) statuses = ["Succeeded"] - doc_statuses = list(client.list_all_document_statuses(poller.id, statuses=statuses)) + doc_statuses = list(client.list_document_statuses(poller.id, statuses=statuses)) assert(len(doc_statuses) == docs_count) statuses = ["Failed"] - doc_statuses = list(client.list_all_document_statuses(poller.id, statuses=statuses)) + doc_statuses = list(client.list_document_statuses(poller.id, statuses=statuses)) assert(len(doc_statuses) == 0) @@ -108,13 +108,13 @@ def test_list_document_statuses_filter_by_ids(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # filter ids - doc_statuses = list(client.list_all_document_statuses(poller.id)) # convert from generic iterator to list + doc_statuses = list(client.list_document_statuses(poller.id)) # convert from generic iterator to list self.assertEqual(len(doc_statuses), docs_count) ids = [doc.id for doc in doc_statuses] ids = ids[:docs_count//2] # do the testing - doc_statuses = list(client.list_all_document_statuses(poller.id, document_ids=ids)) + doc_statuses = list(client.list_document_statuses(poller.id, document_ids=ids)) self.assertEqual(len(doc_statuses), len(ids)) for document in doc_statuses: self._validate_doc_status(document, target_language, ids=ids) @@ -130,7 +130,7 @@ def test_list_document_statuses_order_by_creation_time_asc(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = list(client.list_all_document_statuses(poller.id, order_by=["created_on asc"])) # convert from generic iterator to list + doc_statuses = list(client.list_document_statuses(poller.id, order_by=["created_on asc"])) # convert from generic iterator to list self.assertEqual(len(doc_statuses), docs_count) curr = datetime.min @@ -149,7 +149,7 @@ def test_list_document_statuses_order_by_creation_time_desc(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = list(client.list_all_document_statuses(poller.id, order_by=["created_on desc"])) # convert from generic iterator to list + doc_statuses = list(client.list_document_statuses(poller.id, order_by=["created_on desc"])) # convert from generic iterator to list self.assertEqual(len(doc_statuses), docs_count) curr = datetime.max @@ -170,12 +170,12 @@ def test_list_document_statuses_mixed_filters(self, client): poller = self._begin_and_validate_translation_with_multiple_docs(client, docs_count, language_code=target_language, wait=True) # get ids - doc_statuses = list(client.list_all_document_statuses(poller.id)) # convert from generic iterator to list + doc_statuses = list(client.list_document_statuses(poller.id)) # convert from generic iterator to list self.assertEqual(len(doc_statuses), docs_count) ids = [doc.id for doc in doc_statuses] ids = ids[:docs_count//2] - filtered_docs = client.list_all_document_statuses( + filtered_docs = client.list_document_statuses( poller.id, # filters document_ids=ids, diff --git a/sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses_async.py b/sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses_async.py similarity index 88% rename from sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses_async.py rename to sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses_async.py index 9ef908c1dd57..5d19e120601e 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_all_document_statuses_async.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_list_document_statuses_async.py @@ -27,7 +27,7 @@ async def test_list_document_statuses(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = client.list_all_document_statuses(poller.id) + doc_statuses = client.list_document_statuses(poller.id) doc_statuses_list = [] async for document in doc_statuses: @@ -49,7 +49,7 @@ async def test_list_document_statuses_with_pagination(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses_pages = client.list_all_document_statuses(translation_id=poller.id, results_per_page=results_per_page).by_page() + doc_statuses_pages = client.list_document_statuses(translation_id=poller.id, results_per_page=results_per_page).by_page() pages_list = [] # iterate by page @@ -75,7 +75,7 @@ async def test_list_document_statuses_with_skip(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = client.list_all_document_statuses(translation_id=poller.id, skip=skip) + doc_statuses = client.list_document_statuses(translation_id=poller.id, skip=skip) doc_statuses_list = [] # iterate over docs @@ -97,21 +97,21 @@ async def test_list_document_statuses_filter_by_status(self, client): # list operations statuses = ["NotStarted"] - doc_statuses = client.list_all_document_statuses(poller.id, statuses=statuses) + doc_statuses = client.list_document_statuses(poller.id, statuses=statuses) counter = 0 async for doc in doc_statuses: counter += 1 assert(counter == 0) statuses = ["Succeeded"] - doc_statuses = client.list_all_document_statuses(poller.id, statuses=statuses) + doc_statuses = client.list_document_statuses(poller.id, statuses=statuses) counter = 0 async for doc in doc_statuses: counter += 1 assert(counter == docs_count) statuses = ["Failed"] - doc_statuses = client.list_all_document_statuses(poller.id, statuses=statuses) + doc_statuses = client.list_document_statuses(poller.id, statuses=statuses) counter = 0 async for doc in doc_statuses: counter += 1 @@ -128,13 +128,13 @@ async def test_list_document_statuses_filter_by_ids(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # filter ids - doc_statuses = client.list_all_document_statuses(poller.id) + doc_statuses = client.list_document_statuses(poller.id) ids = [document.id async for document in doc_statuses] self.assertEqual(len(ids), docs_count) ids = ids[:docs_count//2] # do the testing - doc_statuses = client.list_all_document_statuses(poller.id, document_ids=ids) + doc_statuses = client.list_document_statuses(poller.id, document_ids=ids) counter = 0 async for document in doc_statuses: counter += 1 @@ -153,7 +153,7 @@ async def test_list_document_statuses_order_by_creation_time_asc(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = client.list_all_document_statuses(poller.id, order_by=["created_on asc"]) + doc_statuses = client.list_document_statuses(poller.id, order_by=["created_on asc"]) curr = datetime.min docs = [] @@ -175,7 +175,7 @@ async def test_list_document_statuses_order_by_creation_time_desc(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # check doc statuses - doc_statuses = client.list_all_document_statuses(poller.id, order_by=["created_on desc"]) + doc_statuses = client.list_document_statuses(poller.id, order_by=["created_on desc"]) curr = datetime.max docs = [] @@ -199,12 +199,12 @@ async def test_list_document_statuses_mixed_filters(self, client): poller = await self._begin_and_validate_translation_with_multiple_docs_async(client, docs_count, language_code=target_language, wait=True) # get ids - doc_statuses = client.list_all_document_statuses(poller.id) + doc_statuses = client.list_document_statuses(poller.id) ids = [document.id async for document in doc_statuses] self.assertEqual(len(ids), docs_count) ids = ids[:docs_count//2] - filtered_docs = client.list_all_document_statuses( + filtered_docs = client.list_document_statuses( poller.id, # filters document_ids=ids, diff --git a/sdk/translation/azure-ai-translation-document/tests/test_list_translations.py b/sdk/translation/azure-ai-translation-document/tests/test_list_translations.py index 39469bf86630..43749d329685 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_list_translations.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_list_translations.py @@ -26,7 +26,7 @@ def test_list_translations(self, client): self._begin_multiple_translations(client, operations_count, docs_per_operation=docs_per_operation, wait=False) # list translations - submitted_translations = list(client.list_all_translation_statuses()) + submitted_translations = list(client.list_translation_statuses()) self.assertIsNotNone(submitted_translations) # check statuses @@ -46,7 +46,7 @@ def test_list_translations_with_pagination(self, client): self._begin_multiple_translations(client, operations_count, docs_per_operation=docs_per_operation, wait=False) # list translations - submitted_translations_pages = client.list_all_translation_statuses(results_per_page=results_per_page).by_page() + submitted_translations_pages = client.list_translation_statuses(results_per_page=results_per_page).by_page() self.assertIsNotNone(submitted_translations_pages) # iterate by page @@ -69,8 +69,8 @@ def test_list_translations_with_skip(self, client): self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # assert - all_translations = list(client.list_all_translation_statuses()) - translations_with_skip = list(client.list_all_translation_statuses(skip=skip)) + all_translations = list(client.list_translation_statuses()) + translations_with_skip = list(client.list_translation_statuses(skip=skip)) assert len(all_translations) - len(translations_with_skip) == skip @@ -83,15 +83,15 @@ def test_list_translations_filter_by_status(self, client): # create some translations with the status 'Succeeded' completed_translation_ids = self._begin_multiple_translations(client, operations_count, wait=True, docs_per_operation=docs_per_operation) - # create some translations with the status 'Cancelled' + # create some translations with the status 'Canceled' translation_ids = self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) for id in translation_ids: client.cancel_translation(id) - self.wait(10) # wait for cancelled to propagate + self.wait(10) # wait for canceled to propagate # list translations with status filter - statuses = ["Cancelled"] - submitted_translations = list(client.list_all_translation_statuses(statuses=statuses)) + statuses = ["Canceled"] + submitted_translations = list(client.list_translation_statuses(statuses=statuses)) # check statuses for translation in submitted_translations: @@ -109,7 +109,7 @@ def test_list_translations_filter_by_ids(self, client): translation_ids = self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = list(client.list_all_translation_statuses(translation_ids=translation_ids)) + submitted_translations = list(client.list_translation_statuses(translation_ids=translation_ids)) self.assertIsNotNone(submitted_translations) # check statuses @@ -130,7 +130,7 @@ def test_list_translations_filter_by_created_after(self, client): translation_ids = self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = list(client.list_all_translation_statuses(created_after=start)) + submitted_translations = list(client.list_translation_statuses(created_after=start)) self.assertIsNotNone(submitted_translations) # check statuses @@ -156,7 +156,7 @@ def test_list_translations_filter_by_created_before(self, client): translation_ids = self._begin_multiple_translations(client, operations_count, wait=True, docs_per_operation=docs_per_operation) # list translations - submitted_translations = list(client.list_all_translation_statuses(created_before=end)) + submitted_translations = list(client.list_translation_statuses(created_before=end)) self.assertIsNotNone(submitted_translations) # check statuses @@ -175,7 +175,7 @@ def test_list_translations_order_by_creation_time_asc(self, client): self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = list(client.list_all_translation_statuses(order_by=["created_on asc"])) + submitted_translations = list(client.list_translation_statuses(order_by=["created_on asc"])) self.assertIsNotNone(submitted_translations) # check statuses @@ -195,7 +195,7 @@ def test_list_translations_order_by_creation_time_desc(self, client): self._begin_multiple_translations(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = list(client.list_all_translation_statuses(order_by=["created_on desc"])) + submitted_translations = list(client.list_translation_statuses(order_by=["created_on desc"])) self.assertIsNotNone(submitted_translations) # check statuses @@ -221,7 +221,7 @@ def test_list_translations_mixed_filters(self, client): end = datetime.utcnow().replace(tzinfo=pytz.utc) # list translations - submitted_translations = client.list_all_translation_statuses( + submitted_translations = client.list_translation_statuses( # filters statuses=statuses, created_after=start, diff --git a/sdk/translation/azure-ai-translation-document/tests/test_list_translations_async.py b/sdk/translation/azure-ai-translation-document/tests/test_list_translations_async.py index 9c925cebd46b..593492eff725 100644 --- a/sdk/translation/azure-ai-translation-document/tests/test_list_translations_async.py +++ b/sdk/translation/azure-ai-translation-document/tests/test_list_translations_async.py @@ -28,7 +28,7 @@ async def test_list_translations(self, client): await self._begin_multiple_translations_async(client, operations_count, docs_per_operation=docs_per_operation, wait=False) # list translations - submitted_translations = client.list_all_translation_statuses() + submitted_translations = client.list_translation_statuses() self.assertIsNotNone(submitted_translations) # check statuses @@ -48,7 +48,7 @@ async def test_list_translations_with_pagination(self, client): await self._begin_multiple_translations_async(client, operations_count, docs_per_operation=docs_per_operation, wait=False) # list translations - submitted_translations_pages = client.list_all_translation_statuses(results_per_page=results_per_page).by_page() + submitted_translations_pages = client.list_translation_statuses(results_per_page=results_per_page).by_page() self.assertIsNotNone(submitted_translations_pages) # iterate by page @@ -73,12 +73,12 @@ async def test_list_translations_with_skip(self, client): await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - unable to assert skip!! - all_translations = client.list_all_translation_statuses() + all_translations = client.list_translation_statuses() all_operations_count = 0 async for translation in all_translations: all_operations_count += 1 - translations_with_skip = client.list_all_translation_statuses(skip=skip) + translations_with_skip = client.list_translation_statuses(skip=skip) translations_with_skip_count = 0 async for translation in translations_with_skip: translations_with_skip_count += 1 @@ -95,15 +95,15 @@ async def test_list_translations_filter_by_status(self, client): # create some translations with the status 'Succeeded' completed_translation_ids = await self._begin_multiple_translations_async(client, operations_count, wait=True, docs_per_operation=docs_per_operation) - # create some translations with the status 'Cancelled' + # create some translations with the status 'Canceled' translation_ids = await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) for id in translation_ids: await client.cancel_translation(id) - self.wait(10) # wait for 'cancelled' to propagate + self.wait(10) # wait for 'canceled' to propagate # list translations with status filter - statuses = ["Cancelled"] - submitted_translations = client.list_all_translation_statuses(statuses=statuses) + statuses = ["Canceled"] + submitted_translations = client.list_translation_statuses(statuses=statuses) # check statuses async for translation in submitted_translations: @@ -121,7 +121,7 @@ async def test_list_translations_filter_by_ids(self, client): translation_ids = await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = client.list_all_translation_statuses(translation_ids=translation_ids) + submitted_translations = client.list_translation_statuses(translation_ids=translation_ids) self.assertIsNotNone(submitted_translations) # check statuses @@ -142,7 +142,7 @@ async def test_list_translations_filter_by_created_after(self, client): translation_ids = await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = client.list_all_translation_statuses(created_after=start) + submitted_translations = client.list_translation_statuses(created_after=start) self.assertIsNotNone(submitted_translations) # check statuses @@ -168,7 +168,7 @@ async def test_list_translations_filter_by_created_before(self, client): translation_ids = await self._begin_multiple_translations_async(client, operations_count, wait=True, docs_per_operation=docs_per_operation) # list translations - submitted_translations = client.list_all_translation_statuses(created_before=end) + submitted_translations = client.list_translation_statuses(created_before=end) self.assertIsNotNone(submitted_translations) # check statuses @@ -187,7 +187,7 @@ async def test_list_translations_order_by_creation_time_asc(self, client): await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = client.list_all_translation_statuses(order_by=["created_on asc"]) + submitted_translations = client.list_translation_statuses(order_by=["created_on asc"]) self.assertIsNotNone(submitted_translations) # check statuses @@ -207,7 +207,7 @@ async def test_list_translations_order_by_creation_time_desc(self, client): await self._begin_multiple_translations_async(client, operations_count, wait=False, docs_per_operation=docs_per_operation) # list translations - submitted_translations = client.list_all_translation_statuses(order_by=["created_on desc"]) + submitted_translations = client.list_translation_statuses(order_by=["created_on desc"]) self.assertIsNotNone(submitted_translations) # check statuses @@ -233,7 +233,7 @@ async def test_list_translations_mixed_filters(self, client): end = datetime.utcnow().replace(tzinfo=pytz.utc) # list translations - submitted_translations = client.list_all_translation_statuses( + submitted_translations = client.list_translation_statuses( # filters statuses=statuses, created_after=start, diff --git a/sdk/translation/azure-ai-translation-document/tests/testcase.py b/sdk/translation/azure-ai-translation-document/tests/testcase.py index 1c16c23a2db2..4176df7f74b6 100644 --- a/sdk/translation/azure-ai-translation-document/tests/testcase.py +++ b/sdk/translation/azure-ai-translation-document/tests/testcase.py @@ -172,7 +172,7 @@ def _validate_translation_metadata(self, poller, **kwargs): succeeded = kwargs.pop('succeeded', None) inprogress = kwargs.pop('inprogress', None) notstarted = kwargs.pop('notstarted', None) - cancelled = kwargs.pop('cancelled', None) + canceled = kwargs.pop('canceled', None) # status p = poller.status() @@ -185,7 +185,7 @@ def _validate_translation_metadata(self, poller, **kwargs): self.assertEqual(poller.details.documents_succeeded_count, succeeded) if succeeded else self.assertIsNotNone(poller.details.documents_succeeded_count) self.assertEqual(poller.details.documents_in_progress_count, inprogress) if inprogress else self.assertIsNotNone(poller.details.documents_in_progress_count) self.assertEqual(poller.details.documents_not_yet_started_count, notstarted) if notstarted else self.assertIsNotNone(poller.details.documents_not_yet_started_count) - self.assertEqual(poller.details.documents_cancelled_count, cancelled) if cancelled else self.assertIsNotNone(poller.details.documents_cancelled_count) + self.assertEqual(poller.details.documents_canceled_count, canceled) if canceled else self.assertIsNotNone(poller.details.documents_canceled_count) # generic assertions self.assertIsNotNone(poller.details.id) self.assertIsNotNone(poller.details.created_on) @@ -199,7 +199,7 @@ def _validate_translations(self, job_details, **kwargs): succeeded = kwargs.pop('succeeded', None) inprogress = kwargs.pop('inprogress', None) notstarted = kwargs.pop('notstarted', None) - cancelled = kwargs.pop('cancelled', None) + canceled = kwargs.pop('canceled', None) # status self.assertEqual(job_details.status, status) if status else self.assertIsNotNone(job_details.status) @@ -217,8 +217,8 @@ def _validate_translations(self, job_details, **kwargs): self.assertEqual(job_details.documents_not_yet_started_count, notstarted) if notstarted else self.assertIsNotNone( job_details.documents_not_yet_started_count) - self.assertEqual(job_details.documents_cancelled_count, - cancelled) if cancelled else self.assertIsNotNone(job_details.documents_cancelled_count) + self.assertEqual(job_details.documents_canceled_count, + canceled) if canceled else self.assertIsNotNone(job_details.documents_canceled_count) # generic assertions self.assertIsNotNone(job_details.id) self.assertIsNotNone(job_details.created_on)