Skip to content

Commit

Permalink
[translation] naming alignment (#20406)
Browse files Browse the repository at this point in the history
* list_all_translation_statuses -> list_translation_statuses

* list_all_document_statuses -> list_document_statuses

* cancelled -> canceled, cancelling -> canceling

* FileFormat -> DocumentTranslationFileFormat

* update changelog
  • Loading branch information
kristapratico authored Aug 25, 2021
1 parent 37cb22c commit 56475b0
Show file tree
Hide file tree
Showing 43 changed files with 202 additions and 168 deletions.
9 changes: 5 additions & 4 deletions sdk/translation/azure-ai-translation-document/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions sdk/translation/azure-ai-translation-document/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ credential = AzureKeyCredential("<api_key>")

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))
Expand All @@ -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
Expand Down Expand Up @@ -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]

Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
DocumentTranslationError,
TranslationGlossary,
DocumentTranslationInput,
FileFormat,
DocumentTranslationFileFormat,
)

__VERSION__ = VERSION
Expand All @@ -30,7 +30,7 @@
"DocumentTranslationInput",
"TranslationGlossary",
"StorageInputType",
"FileFormat",
"DocumentTranslationFileFormat",
"TranslationTarget",
"TranslationStatus",
"DocumentStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
TranslationStatus,
DocumentStatus,
DocumentTranslationInput,
FileFormat,
DocumentTranslationFileFormat,
convert_status
)
from ._user_agent import USER_AGENT
from ._polling import TranslationPolling, DocumentTranslationLROPollingMethod
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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
)

Expand All @@ -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
)
Loading

0 comments on commit 56475b0

Please sign in to comment.