Skip to content

Commit 56475b0

Browse files
[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
1 parent 37cb22c commit 56475b0

File tree

43 files changed

+202
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+202
-168
lines changed

sdk/translation/azure-ai-translation-document/CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
## 1.0.0b5 (Unreleased)
44

5-
### Features Added
6-
75
### Breaking Changes
6+
- Changed: `list_all_translation_statuses` has been renamed to `list_translation_statuses`
7+
- Changed: `list_all_document_statuses` has been renamed to `list_document_statuses`
8+
- Changed: `TranslationStatus` property `documents_cancelled_count` has been renamed to `documents_canceled_count`
9+
- Changed: `FileFormat` has been renamed to `DocumentTranslationFileFormat`
10+
- Changed: Operation statuses `Cancelled` and `Cancelling` have been renamed to `Canceled` and `Canceling`, respectively.
811

912
### Bugs Fixed
1013
- The operation `id` under `details` of the poller object now populates correctly.
1114

12-
### Other Changes
13-
1415
## 1.0.0b4 (2021-08-10)
1516

1617
### Features Added

sdk/translation/azure-ai-translation-document/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ credential = AzureKeyCredential("<api_key>")
303303

304304
document_translation_client = DocumentTranslationClient(endpoint, credential)
305305

306-
operations = document_translation_client.list_all_translation_statuses() # type: ItemPaged[TranslationStatus]
306+
operations = document_translation_client.list_translation_statuses() # type: ItemPaged[TranslationStatus]
307307

308308
for operation in operations:
309309
print("\nID: {}".format(operation.id))
@@ -316,7 +316,7 @@ for operation in operations:
316316
print("Of total documents...")
317317
print("{} failed".format(operation.documents_failed_count))
318318
print("{} succeeded".format(operation.documents_succeeded_count))
319-
print("{} cancelled".format(operation.documents_cancelled_count))
319+
print("{} canceled".format(operation.documents_canceled_count))
320320
```
321321

322322
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
391391
* Begin translating documents: [sample_begin_translation.py][sample_begin_translation]
392392
* Translate with multiple inputs: [sample_translate_multiple_inputs.py][sample_translate_multiple_inputs]
393393
* Check the status of documents: [sample_check_document_statuses.py][sample_check_document_statuses]
394-
* List all submitted translation operations: [sample_list_all_translations.py][sample_list_all_translations]
394+
* List all submitted translation operations: [sample_list_translations.py][sample_list_translations]
395395
* Apply a custom glossary to translation: [sample_translation_with_glossaries.py][sample_translation_with_glossaries]
396396
* Use Azure Blob Storage to set up translation resources: [sample_translation_with_azure_blob.py][sample_translation_with_azure_blob]
397397

@@ -405,7 +405,7 @@ are found under the `azure.ai.translation.document.aio` namespace.
405405
* Begin translating documents: [sample_begin_translation_async.py][sample_begin_translation_async]
406406
* Translate with multiple inputs: [sample_translate_multiple_inputs_async.py][sample_translate_multiple_inputs_async]
407407
* Check the status of documents: [sample_check_document_statuses_async.py][sample_check_document_statuses_async]
408-
* List all submitted translation operations: [sample_list_all_translations_async.py][sample_list_all_translations_async]
408+
* List all submitted translation operations: [sample_list_translations_async.py][sample_list_translations_async]
409409
* Apply a custom glossary to translation: [sample_translation_with_glossaries_async.py][sample_translation_with_glossaries_async]
410410
* Use Azure Blob Storage to set up translation resources: [sample_translation_with_azure_blob_async.py][sample_translation_with_azure_blob_async]
411411

@@ -464,8 +464,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
464464
[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
465465
[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
466466
[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
467-
[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
468-
[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
467+
[sample_list_translations]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/translation/azure-ai-translation-document/samples/sample_list_translations.py
468+
[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
469469
[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
470470
[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
471471
[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

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
DocumentTranslationError,
1919
TranslationGlossary,
2020
DocumentTranslationInput,
21-
FileFormat,
21+
DocumentTranslationFileFormat,
2222
)
2323

2424
__VERSION__ = VERSION
@@ -30,7 +30,7 @@
3030
"DocumentTranslationInput",
3131
"TranslationGlossary",
3232
"StorageInputType",
33-
"FileFormat",
33+
"DocumentTranslationFileFormat",
3434
"TranslationTarget",
3535
"TranslationStatus",
3636
"DocumentStatus",

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_client.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
TranslationStatus,
1515
DocumentStatus,
1616
DocumentTranslationInput,
17-
FileFormat,
17+
DocumentTranslationFileFormat,
18+
convert_status
1819
)
1920
from ._user_agent import USER_AGENT
2021
from ._polling import TranslationPolling, DocumentTranslationLROPollingMethod
@@ -174,7 +175,7 @@ def deserialization_callback(
174175
raw_response, _, headers
175176
): # pylint: disable=unused-argument
176177
translation_status = json.loads(raw_response.http_response.text())
177-
return self.list_all_document_statuses(translation_status["id"])
178+
return self.list_document_statuses(translation_status["id"])
178179

179180
polling_interval = kwargs.pop(
180181
"polling_interval",
@@ -228,9 +229,9 @@ def cancel_translation(self, translation_id, **kwargs):
228229
# type: (str, **Any) -> None
229230
"""Cancel a currently processing or queued translation operation.
230231
231-
A translation will not be cancelled if it is already completed, failed, or cancelling.
232-
All documents that have completed translation will not be cancelled and will be charged.
233-
If possible, all pending documents will be cancelled.
232+
A translation will not be canceled if it is already completed, failed, or canceling.
233+
All documents that have completed translation will not be canceled and will be charged.
234+
If possible, all pending documents will be canceled.
234235
235236
:param str translation_id: The translation operation ID.
236237
:return: None
@@ -241,7 +242,7 @@ def cancel_translation(self, translation_id, **kwargs):
241242
self._client.document_translation.cancel_translation(translation_id, **kwargs)
242243

243244
@distributed_trace
244-
def list_all_translation_statuses(self, **kwargs):
245+
def list_translation_statuses(self, **kwargs):
245246
# type: (**Any) -> ItemPaged[TranslationStatus]
246247
"""List all the submitted translation operations under the Document Translation resource.
247248
@@ -251,7 +252,7 @@ def list_all_translation_statuses(self, **kwargs):
251252
:keyword int results_per_page: is the number of operations returned per page.
252253
:keyword list[str] translation_ids: translation operations ids to filter by.
253254
:keyword list[str] statuses: translation operation statuses to filter by. Options include
254-
'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling',
255+
'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling',
255256
and 'ValidationFailed'.
256257
:keyword created_after: get operations created after certain datetime.
257258
:paramtype created_after: Union[str, datetime.datetime]
@@ -267,14 +268,17 @@ def list_all_translation_statuses(self, **kwargs):
267268
268269
.. admonition:: Example:
269270
270-
.. literalinclude:: ../samples/sample_list_all_translations.py
271-
:start-after: [START list_all_translations]
272-
:end-before: [END list_all_translations]
271+
.. literalinclude:: ../samples/sample_list_translations.py
272+
:start-after: [START list_translations]
273+
:end-before: [END list_translations]
273274
:language: python
274275
:dedent: 4
275276
:caption: List all submitted translations under the resource.
276277
"""
277278

279+
statuses = kwargs.pop("statuses", None)
280+
if statuses:
281+
statuses = [convert_status(status, ll=True) for status in statuses]
278282
order_by = convert_order_by(kwargs.pop("order_by", None))
279283
created_after = kwargs.pop("created_after", None)
280284
created_before = kwargs.pop("created_before", None)
@@ -304,11 +308,12 @@ def _convert_from_generated_model(
304308
created_date_time_utc_end=created_before,
305309
ids=translation_ids,
306310
order_by=order_by,
311+
statuses=statuses,
307312
**kwargs
308313
)
309314

310315
@distributed_trace
311-
def list_all_document_statuses(self, translation_id, **kwargs):
316+
def list_document_statuses(self, translation_id, **kwargs):
312317
# type: (str, **Any) -> ItemPaged[DocumentStatus]
313318
"""List all the document statuses for a given translation operation.
314319
@@ -319,7 +324,7 @@ def list_all_document_statuses(self, translation_id, **kwargs):
319324
:keyword int results_per_page: is the number of documents returned per page.
320325
:keyword list[str] document_ids: document IDs to filter by.
321326
:keyword list[str] statuses: document statuses to filter by. Options include
322-
'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling',
327+
'NotStarted', 'Running', 'Succeeded', 'Failed', 'Canceled', 'Canceling',
323328
and 'ValidationFailed'.
324329
:keyword created_after: get document created after certain datetime.
325330
:paramtype created_after: Union[str, datetime.datetime]
@@ -336,13 +341,16 @@ def list_all_document_statuses(self, translation_id, **kwargs):
336341
.. admonition:: Example:
337342
338343
.. literalinclude:: ../samples/sample_check_document_statuses.py
339-
:start-after: [START list_all_document_statuses]
340-
:end-before: [END list_all_document_statuses]
344+
:start-after: [START list_document_statuses]
345+
:end-before: [END list_document_statuses]
341346
:language: python
342347
:dedent: 4
343348
:caption: List all the document statuses as they are being translated.
344349
"""
345350

351+
statuses = kwargs.pop("statuses", None)
352+
if statuses:
353+
statuses = [convert_status(status, ll=True) for status in statuses]
346354
order_by = convert_order_by(kwargs.pop("order_by", None))
347355
created_after = kwargs.pop("created_after", None)
348356
created_before = kwargs.pop("created_before", None)
@@ -375,6 +383,7 @@ def _convert_from_generated_model(generated_model):
375383
created_date_time_utc_end=created_before,
376384
ids=document_ids,
377385
order_by=order_by,
386+
statuses=statuses,
378387
**kwargs
379388
)
380389

@@ -399,34 +408,34 @@ def get_document_status(self, translation_id, document_id, **kwargs):
399408

400409
@distributed_trace
401410
def get_supported_glossary_formats(self, **kwargs):
402-
# type: (**Any) -> List[FileFormat]
411+
# type: (**Any) -> List[DocumentTranslationFileFormat]
403412
"""Get the list of the glossary formats supported by the Document Translation service.
404413
405414
:return: A list of supported glossary formats.
406-
:rtype: List[FileFormat]
415+
:rtype: List[DocumentTranslationFileFormat]
407416
:raises ~azure.core.exceptions.HttpResponseError:
408417
"""
409418

410419
glossary_formats = (
411420
self._client.document_translation.get_supported_glossary_formats(**kwargs)
412421
)
413-
return FileFormat._from_generated_list( # pylint: disable=protected-access
422+
return DocumentTranslationFileFormat._from_generated_list( # pylint: disable=protected-access
414423
glossary_formats.value
415424
)
416425

417426
@distributed_trace
418427
def get_supported_document_formats(self, **kwargs):
419-
# type: (**Any) -> List[FileFormat]
428+
# type: (**Any) -> List[DocumentTranslationFileFormat]
420429
"""Get the list of the document formats supported by the Document Translation service.
421430
422431
:return: A list of supported document formats for translation.
423-
:rtype: List[FileFormat]
432+
:rtype: List[DocumentTranslationFileFormat]
424433
:raises ~azure.core.exceptions.HttpResponseError:
425434
"""
426435

427436
document_formats = (
428437
self._client.document_translation.get_supported_document_formats(**kwargs)
429438
)
430-
return FileFormat._from_generated_list( # pylint: disable=protected-access
439+
return DocumentTranslationFileFormat._from_generated_list( # pylint: disable=protected-access
431440
document_formats.value
432441
)

0 commit comments

Comments
 (0)