Skip to content

Commit 7849a11

Browse files
[translation] renames (Azure#19285)
* DocumentStatusResult -> DocumentStatus * TranslationStatusResult -> TranslationStatus * get_document_formats -> get_supported_document_formats * get_glossary_formats -> get_supported_glossary_formats * update changelog * fix naming clash with generated type
1 parent c4fd8e7 commit 7849a11

File tree

14 files changed

+93
-87
lines changed

14 files changed

+93
-87
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## 1.0.0b3 (Unreleased)
44

5+
**Breaking changes**
6+
7+
- `TranslationStatusResult` was renamed to `TranslationStatus`.
8+
- `DocumentStatusResult` was renamed to `DocumentStatus`.
9+
- `get_document_formats` was renamed to `get_supported_document_formats`.
10+
- `get_glossary_formats` was renamed to `get_supported_glossary_formats`.
511

612
## 1.0.0b2 (2021-06-08)
713

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

Lines changed: 1 addition & 1 deletion
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[TranslationStatusResult]
306+
operations = document_translation_client.list_all_translation_statuses() # type: ItemPaged[TranslationStatus]
307307

308308
for operation in operations:
309309
print("\nID: {}".format(operation.id))

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from ._polling import DocumentTranslationLROPoller
1414
from ._models import (
1515
TranslationTarget,
16-
TranslationStatusResult,
17-
DocumentStatusResult,
16+
TranslationStatus,
17+
DocumentStatus,
1818
DocumentTranslationError,
1919
TranslationGlossary,
2020
DocumentTranslationInput,
@@ -32,8 +32,8 @@
3232
"StorageInputType",
3333
"FileFormat",
3434
"TranslationTarget",
35-
"TranslationStatusResult",
36-
"DocumentStatusResult",
35+
"TranslationStatus",
36+
"DocumentStatus",
3737
"DocumentTranslationError",
3838
"DocumentTranslationLROPoller",
3939
]

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
BatchDocumentTranslationClient as _BatchDocumentTranslationClient,
1212
)
1313
from ._models import (
14-
TranslationStatusResult,
15-
DocumentStatusResult,
14+
TranslationStatus,
15+
DocumentStatus,
1616
DocumentTranslationInput,
1717
FileFormat,
1818
)
@@ -100,12 +100,12 @@ def close(self):
100100

101101
@overload
102102
def begin_translation(self, source_url, target_url, target_language_code, **kwargs):
103-
# type: (str, str, str, **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatusResult]]
103+
# type: (str, str, str, **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatus]]
104104
pass
105105

106106
@overload
107107
def begin_translation(self, inputs, **kwargs):
108-
# type: (List[DocumentTranslationInput], **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatusResult]]
108+
# type: (List[DocumentTranslationInput], **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatus]]
109109
pass
110110

111111
def begin_translation(
@@ -132,9 +132,9 @@ def begin_translation(
132132
for the destination to write translated documents.
133133
:type inputs: List[~azure.ai.translation.document.DocumentTranslationInput]
134134
:return: An instance of a DocumentTranslationLROPoller. Call `result()` on the poller
135-
object to return a pageable of DocumentStatusResult. A DocumentStatusResult will be
135+
object to return a pageable of DocumentStatus. A DocumentStatus will be
136136
returned for each translation on a document.
137-
:rtype: DocumentTranslationLROPoller[ItemPaged[~azure.ai.translation.document.DocumentStatusResult]]
137+
:rtype: DocumentTranslationLROPoller[ItemPaged[~azure.ai.translation.document.DocumentStatus]]
138138
:raises ~azure.core.exceptions.HttpResponseError:
139139
140140
.. admonition:: Example:
@@ -185,22 +185,22 @@ def deserialization_callback(
185185

186186
@distributed_trace
187187
def get_translation_status(self, translation_id, **kwargs):
188-
# type: (str, **Any) -> TranslationStatusResult
188+
# type: (str, **Any) -> TranslationStatus
189189
"""Gets the status of the translation operation.
190190
191191
Includes the overall status, as well as a summary of
192192
the documents that are being translated as part of that translation operation.
193193
194194
:param str translation_id: The translation operation ID.
195-
:return: A TranslationStatusResult with information on the status of the translation operation.
196-
:rtype: ~azure.ai.translation.document.TranslationStatusResult
195+
:return: A TranslationStatus with information on the status of the translation operation.
196+
:rtype: ~azure.ai.translation.document.TranslationStatus
197197
:raises ~azure.core.exceptions.HttpResponseError or ~azure.core.exceptions.ResourceNotFoundError:
198198
"""
199199

200200
translation_status = self._client.document_translation.get_translation_status(
201201
translation_id, **kwargs
202202
)
203-
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
203+
return TranslationStatus._from_generated( # pylint: disable=protected-access
204204
translation_status
205205
)
206206

@@ -223,7 +223,7 @@ def cancel_translation(self, translation_id, **kwargs):
223223

224224
@distributed_trace
225225
def list_all_translation_statuses(self, **kwargs):
226-
# type: (**Any) -> ItemPaged[TranslationStatusResult]
226+
# type: (**Any) -> ItemPaged[TranslationStatus]
227227
"""List all the submitted translation operations under the Document Translation resource.
228228
229229
:keyword int top: the total number of operations to return (across all pages) from all submitted translations.
@@ -239,8 +239,8 @@ def list_all_translation_statuses(self, **kwargs):
239239
:keyword list[str] order_by: the sorting query for the operations returned.
240240
format: ["parm1 asc/desc", "parm2 asc/desc", ...]
241241
(ex: 'createdDateTimeUtc asc', 'createdDateTimeUtc desc').
242-
:return: A pageable of TranslationStatusResult.
243-
:rtype: ~azure.core.paging.ItemPaged[TranslationStatusResult]
242+
:return: A pageable of TranslationStatus.
243+
:rtype: ~azure.core.paging.ItemPaged[TranslationStatus]
244244
:raises ~azure.core.exceptions.HttpResponseError:
245245
246246
.. admonition:: Example:
@@ -262,7 +262,7 @@ def list_all_translation_statuses(self, **kwargs):
262262
def _convert_from_generated_model(
263263
generated_model,
264264
): # pylint: disable=protected-access
265-
return TranslationStatusResult._from_generated(
265+
return TranslationStatus._from_generated(
266266
generated_model
267267
) # pylint: disable=protected-access
268268

@@ -284,7 +284,7 @@ def _convert_from_generated_model(
284284

285285
@distributed_trace
286286
def list_all_document_statuses(self, translation_id, **kwargs):
287-
# type: (str, **Any) -> ItemPaged[DocumentStatusResult]
287+
# type: (str, **Any) -> ItemPaged[DocumentStatus]
288288
"""List all the document statuses for a given translation operation.
289289
290290
:param str translation_id: ID of translation operation to list documents for.
@@ -301,8 +301,8 @@ def list_all_document_statuses(self, translation_id, **kwargs):
301301
:keyword list[str] order_by: the sorting query for the documents.
302302
format: ["parm1 asc/desc", "parm2 asc/desc", ...]
303303
(ex: 'createdDateTimeUtc asc', 'createdDateTimeUtc desc').
304-
:return: A pageable of DocumentStatusResult.
305-
:rtype: ~azure.core.paging.ItemPaged[DocumentStatusResult]
304+
:return: A pageable of DocumentStatus.
305+
:rtype: ~azure.core.paging.ItemPaged[DocumentStatus]
306306
:raises ~azure.core.exceptions.HttpResponseError:
307307
308308
.. admonition:: Example:
@@ -326,7 +326,7 @@ def list_all_document_statuses(self, translation_id, **kwargs):
326326
document_ids = kwargs.pop("document_ids", None)
327327

328328
def _convert_from_generated_model(generated_model):
329-
return DocumentStatusResult._from_generated( # pylint: disable=protected-access
329+
return DocumentStatus._from_generated( # pylint: disable=protected-access
330330
generated_model
331331
)
332332

@@ -349,25 +349,25 @@ def _convert_from_generated_model(generated_model):
349349

350350
@distributed_trace
351351
def get_document_status(self, translation_id, document_id, **kwargs):
352-
# type: (str, str, **Any) -> DocumentStatusResult
352+
# type: (str, str, **Any) -> DocumentStatus
353353
"""Get the status of an individual document within a translation operation.
354354
355355
:param str translation_id: The translation operation ID.
356356
:param str document_id: The ID for the document.
357-
:return: A DocumentStatusResult with information on the status of the document.
358-
:rtype: ~azure.ai.translation.document.DocumentStatusResult
357+
:return: A DocumentStatus with information on the status of the document.
358+
:rtype: ~azure.ai.translation.document.DocumentStatus
359359
:raises ~azure.core.exceptions.HttpResponseError or ~azure.core.exceptions.ResourceNotFoundError:
360360
"""
361361

362362
document_status = self._client.document_translation.get_document_status(
363363
translation_id, document_id, **kwargs
364364
)
365-
return DocumentStatusResult._from_generated( # pylint: disable=protected-access
365+
return DocumentStatus._from_generated( # pylint: disable=protected-access
366366
document_status
367367
)
368368

369369
@distributed_trace
370-
def get_glossary_formats(self, **kwargs):
370+
def get_supported_glossary_formats(self, **kwargs):
371371
# type: (**Any) -> List[FileFormat]
372372
"""Get the list of the glossary formats supported by the Document Translation service.
373373
@@ -384,7 +384,7 @@ def get_glossary_formats(self, **kwargs):
384384
)
385385

386386
@distributed_trace
387-
def get_document_formats(self, **kwargs):
387+
def get_supported_document_formats(self, **kwargs):
388388
# type: (**Any) -> List[FileFormat]
389389
"""Get the list of the document formats supported by the Document Translation service.
390390

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ class TranslationGlossary(object): # pylint: disable=useless-object-inheritance
2222
the glossary file in the storage blob container. If the translation language pair is
2323
not present in the glossary, it will not be applied.
2424
:param str file_format: Required. Format of the glossary file. To see supported formats,
25-
call the :func:`~DocumentTranslationClient.get_glossary_formats()` client method.
25+
call the :func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
2626
:keyword str format_version: File format version. If not specified, the service will
2727
use the default_version for the file format returned from the
28-
:func:`~DocumentTranslationClient.get_glossary_formats()` client method.
28+
:func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
2929
:keyword str storage_source: Storage Source. Default value: "AzureBlob".
3030
Currently only "AzureBlob" is supported.
3131
3232
:ivar str glossary_url: Required. Location of the glossary file. This should be a SAS URL to
3333
the glossary file in the storage blob container. If the translation language pair is
3434
not present in the glossary, it will not be applied.
3535
:ivar str file_format: Required. Format of the glossary file. To see supported formats,
36-
call the :func:`~DocumentTranslationClient.get_glossary_formats()` client method.
36+
call the :func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
3737
:ivar str format_version: File format version. If not specified, the service will
3838
use the default_version for the file format returned from the
39-
:func:`~DocumentTranslationClient.get_glossary_formats()` client method.
39+
:func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
4040
:ivar str storage_source: Storage Source. Default value: "AzureBlob".
4141
Currently only "AzureBlob" is supported.
4242
"""
@@ -231,7 +231,7 @@ def __repr__(self):
231231
)
232232

233233

234-
class TranslationStatusResult(
234+
class TranslationStatus(
235235
object
236236
): # pylint: disable=useless-object-inheritance, too-many-instance-attributes
237237
"""Status information about the translation operation.
@@ -307,7 +307,7 @@ def _from_generated(cls, batch_status_details):
307307

308308
def __repr__(self):
309309
return (
310-
"TranslationStatusResult(id={}, created_on={}, "
310+
"TranslationStatus(id={}, created_on={}, "
311311
"last_updated_on={}, status={}, error={}, documents_total_count={}, "
312312
"documents_failed_count={}, documents_succeeded_count={}, "
313313
"documents_in_progress_count={}, documents_not_yet_started_count={}, "
@@ -328,7 +328,7 @@ def __repr__(self):
328328
)
329329

330330

331-
class DocumentStatusResult(
331+
class DocumentStatus(
332332
object
333333
): # pylint: disable=useless-object-inheritance, R0903, R0902
334334
"""Status information about a particular document within a translation operation.
@@ -393,7 +393,7 @@ def _from_generated(cls, doc_status):
393393
def __repr__(self):
394394
# pylint: disable=line-too-long
395395
return (
396-
"DocumentStatusResult(id={}, source_document_url={}, "
396+
"DocumentStatus(id={}, source_document_url={}, "
397397
"translated_document_url={}, created_on={}, last_updated_on={}, "
398398
"status={}, translated_to={}, error={}, translation_progress={}, "
399399
"characters_charged={})".format(

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
)
1818

1919
from azure.core.exceptions import HttpResponseError, ODataV4Format
20-
from ._generated.models import TranslationStatus
21-
from ._models import TranslationStatusResult
20+
from ._generated.models import TranslationStatus as _TranslationStatus
21+
from ._models import TranslationStatus
2222

2323

2424
if TYPE_CHECKING:
@@ -39,7 +39,7 @@
3939

4040
class DocumentTranslationLROPoller(LROPoller):
4141
"""A custom poller implementation for Document Translation. Call `result()` on the poller to return
42-
a pageable of :class:`~azure.ai.translation.document.DocumentStatusResult`."""
42+
a pageable of :class:`~azure.ai.translation.document.DocumentStatus`."""
4343

4444
@property
4545
def id(self):
@@ -58,12 +58,12 @@ def id(self):
5858

5959
@property
6060
def details(self):
61-
# type: () -> TranslationStatusResult
61+
# type: () -> TranslationStatus
6262
"""The details for the translation operation
6363
64-
:rtype: ~azure.ai.translation.document.TranslationStatusResult
64+
:rtype: ~azure.ai.translation.document.TranslationStatus
6565
"""
66-
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
66+
return TranslationStatus._from_generated( # pylint: disable=protected-access
6767
self._polling_method._current_body # pylint: disable=protected-access
6868
)
6969

@@ -89,8 +89,8 @@ def __init__(self, *args, **kwargs):
8989

9090
@property
9191
def _current_body(self):
92-
# type: () -> TranslationStatus
93-
return TranslationStatus.deserialize(self._pipeline_response)
92+
# type: () -> _TranslationStatus
93+
return _TranslationStatus.deserialize(self._pipeline_response)
9494

9595
def _get_id_from_headers(self):
9696
# type: () -> str

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
_raise_if_bad_http_status_and_method,
1212
)
1313
from azure.core.polling.async_base_polling import AsyncLROBasePolling
14-
from .._generated.models import TranslationStatus
15-
from .._models import TranslationStatusResult
14+
from .._generated.models import TranslationStatus as _TranslationStatus
15+
from .._models import TranslationStatus
1616

1717
PollingReturnType = TypeVar("PollingReturnType")
1818
_FINISHED = frozenset(["succeeded", "cancelled", "cancelling", "failed"])
@@ -21,7 +21,7 @@
2121

2222
class AsyncDocumentTranslationLROPoller(AsyncLROPoller[PollingReturnType]):
2323
"""An async custom poller implementation for Document Translation. Call `result()` on the poller to return
24-
a pageable of :class:`~azure.ai.translation.document.DocumentStatusResult`."""
24+
a pageable of :class:`~azure.ai.translation.document.DocumentStatus`."""
2525

2626
@property
2727
def id(self) -> str:
@@ -38,12 +38,12 @@ def id(self) -> str:
3838
)
3939

4040
@property
41-
def details(self) -> TranslationStatusResult:
41+
def details(self) -> TranslationStatus:
4242
"""The details for the translation operation
4343
44-
:rtype: ~azure.ai.translation.document.TranslationStatusResult
44+
:rtype: ~azure.ai.translation.document.TranslationStatus
4545
"""
46-
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
46+
return TranslationStatus._from_generated( # pylint: disable=protected-access
4747
self._polling_method._current_body # pylint: disable=protected-access
4848
)
4949

@@ -72,8 +72,8 @@ def __init__(self, *args, **kwargs):
7272
super(AsyncDocumentTranslationLROPollingMethod, self).__init__(*args, **kwargs)
7373

7474
@property
75-
def _current_body(self) -> TranslationStatus:
76-
return TranslationStatus.deserialize(self._pipeline_response)
75+
def _current_body(self) -> _TranslationStatus:
76+
return _TranslationStatus.deserialize(self._pipeline_response)
7777

7878
def _get_id_from_headers(self) -> str:
7979
return self._pipeline_response.http_response.headers[

0 commit comments

Comments
 (0)