Skip to content

Commit

Permalink
[translation] renames (Azure#19285)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kristapratico authored Jun 17, 2021
1 parent c4fd8e7 commit 7849a11
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 87 deletions.
6 changes: 6 additions & 0 deletions sdk/translation/azure-ai-translation-document/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 1.0.0b3 (Unreleased)

**Breaking changes**

- `TranslationStatusResult` was renamed to `TranslationStatus`.
- `DocumentStatusResult` was renamed to `DocumentStatus`.
- `get_document_formats` was renamed to `get_supported_document_formats`.
- `get_glossary_formats` was renamed to `get_supported_glossary_formats`.

## 1.0.0b2 (2021-06-08)

Expand Down
2 changes: 1 addition & 1 deletion 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[TranslationStatusResult]
operations = document_translation_client.list_all_translation_statuses() # type: ItemPaged[TranslationStatus]

for operation in operations:
print("\nID: {}".format(operation.id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ._polling import DocumentTranslationLROPoller
from ._models import (
TranslationTarget,
TranslationStatusResult,
DocumentStatusResult,
TranslationStatus,
DocumentStatus,
DocumentTranslationError,
TranslationGlossary,
DocumentTranslationInput,
Expand All @@ -32,8 +32,8 @@
"StorageInputType",
"FileFormat",
"TranslationTarget",
"TranslationStatusResult",
"DocumentStatusResult",
"TranslationStatus",
"DocumentStatus",
"DocumentTranslationError",
"DocumentTranslationLROPoller",
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
BatchDocumentTranslationClient as _BatchDocumentTranslationClient,
)
from ._models import (
TranslationStatusResult,
DocumentStatusResult,
TranslationStatus,
DocumentStatus,
DocumentTranslationInput,
FileFormat,
)
Expand Down Expand Up @@ -100,12 +100,12 @@ def close(self):

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

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

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

@distributed_trace
def get_translation_status(self, translation_id, **kwargs):
# type: (str, **Any) -> TranslationStatusResult
# type: (str, **Any) -> TranslationStatus
"""Gets the status of the translation operation.
Includes the overall status, as well as a summary of
the documents that are being translated as part of that translation operation.
:param str translation_id: The translation operation ID.
:return: A TranslationStatusResult with information on the status of the translation operation.
:rtype: ~azure.ai.translation.document.TranslationStatusResult
:return: A TranslationStatus with information on the status of the translation operation.
:rtype: ~azure.ai.translation.document.TranslationStatus
:raises ~azure.core.exceptions.HttpResponseError or ~azure.core.exceptions.ResourceNotFoundError:
"""

translation_status = self._client.document_translation.get_translation_status(
translation_id, **kwargs
)
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
return TranslationStatus._from_generated( # pylint: disable=protected-access
translation_status
)

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

@distributed_trace
def list_all_translation_statuses(self, **kwargs):
# type: (**Any) -> ItemPaged[TranslationStatusResult]
# type: (**Any) -> ItemPaged[TranslationStatus]
"""List all the submitted translation operations under the Document Translation resource.
:keyword int top: the total number of operations to return (across all pages) from all submitted translations.
Expand All @@ -239,8 +239,8 @@ def list_all_translation_statuses(self, **kwargs):
:keyword list[str] order_by: the sorting query for the operations returned.
format: ["parm1 asc/desc", "parm2 asc/desc", ...]
(ex: 'createdDateTimeUtc asc', 'createdDateTimeUtc desc').
:return: A pageable of TranslationStatusResult.
:rtype: ~azure.core.paging.ItemPaged[TranslationStatusResult]
:return: A pageable of TranslationStatus.
:rtype: ~azure.core.paging.ItemPaged[TranslationStatus]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -262,7 +262,7 @@ def list_all_translation_statuses(self, **kwargs):
def _convert_from_generated_model(
generated_model,
): # pylint: disable=protected-access
return TranslationStatusResult._from_generated(
return TranslationStatus._from_generated(
generated_model
) # pylint: disable=protected-access

Expand All @@ -284,7 +284,7 @@ def _convert_from_generated_model(

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

def _convert_from_generated_model(generated_model):
return DocumentStatusResult._from_generated( # pylint: disable=protected-access
return DocumentStatus._from_generated( # pylint: disable=protected-access
generated_model
)

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

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

document_status = self._client.document_translation.get_document_status(
translation_id, document_id, **kwargs
)
return DocumentStatusResult._from_generated( # pylint: disable=protected-access
return DocumentStatus._from_generated( # pylint: disable=protected-access
document_status
)

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

@distributed_trace
def get_document_formats(self, **kwargs):
def get_supported_document_formats(self, **kwargs):
# type: (**Any) -> List[FileFormat]
"""Get the list of the document formats supported by the Document Translation service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ class TranslationGlossary(object): # pylint: disable=useless-object-inheritance
the glossary file in the storage blob container. If the translation language pair is
not present in the glossary, it will not be applied.
:param str file_format: Required. Format of the glossary file. To see supported formats,
call the :func:`~DocumentTranslationClient.get_glossary_formats()` client method.
call the :func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
:keyword str format_version: File format version. If not specified, the service will
use the default_version for the file format returned from the
:func:`~DocumentTranslationClient.get_glossary_formats()` client method.
:func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
:keyword str storage_source: Storage Source. Default value: "AzureBlob".
Currently only "AzureBlob" is supported.
:ivar str glossary_url: Required. Location of the glossary file. This should be a SAS URL to
the glossary file in the storage blob container. If the translation language pair is
not present in the glossary, it will not be applied.
:ivar str file_format: Required. Format of the glossary file. To see supported formats,
call the :func:`~DocumentTranslationClient.get_glossary_formats()` client method.
call the :func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
:ivar str format_version: File format version. If not specified, the service will
use the default_version for the file format returned from the
:func:`~DocumentTranslationClient.get_glossary_formats()` client method.
:func:`~DocumentTranslationClient.get_supported_glossary_formats()` client method.
:ivar str storage_source: Storage Source. Default value: "AzureBlob".
Currently only "AzureBlob" is supported.
"""
Expand Down Expand Up @@ -231,7 +231,7 @@ def __repr__(self):
)


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

def __repr__(self):
return (
"TranslationStatusResult(id={}, created_on={}, "
"TranslationStatus(id={}, created_on={}, "
"last_updated_on={}, status={}, error={}, documents_total_count={}, "
"documents_failed_count={}, documents_succeeded_count={}, "
"documents_in_progress_count={}, documents_not_yet_started_count={}, "
Expand All @@ -328,7 +328,7 @@ def __repr__(self):
)


class DocumentStatusResult(
class DocumentStatus(
object
): # pylint: disable=useless-object-inheritance, R0903, R0902
"""Status information about a particular document within a translation operation.
Expand Down Expand Up @@ -393,7 +393,7 @@ def _from_generated(cls, doc_status):
def __repr__(self):
# pylint: disable=line-too-long
return (
"DocumentStatusResult(id={}, source_document_url={}, "
"DocumentStatus(id={}, source_document_url={}, "
"translated_document_url={}, created_on={}, last_updated_on={}, "
"status={}, translated_to={}, error={}, translation_progress={}, "
"characters_charged={})".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
)

from azure.core.exceptions import HttpResponseError, ODataV4Format
from ._generated.models import TranslationStatus
from ._models import TranslationStatusResult
from ._generated.models import TranslationStatus as _TranslationStatus
from ._models import TranslationStatus


if TYPE_CHECKING:
Expand All @@ -39,7 +39,7 @@

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

@property
def id(self):
Expand All @@ -58,12 +58,12 @@ def id(self):

@property
def details(self):
# type: () -> TranslationStatusResult
# type: () -> TranslationStatus
"""The details for the translation operation
:rtype: ~azure.ai.translation.document.TranslationStatusResult
:rtype: ~azure.ai.translation.document.TranslationStatus
"""
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
return TranslationStatus._from_generated( # pylint: disable=protected-access
self._polling_method._current_body # pylint: disable=protected-access
)

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

@property
def _current_body(self):
# type: () -> TranslationStatus
return TranslationStatus.deserialize(self._pipeline_response)
# type: () -> _TranslationStatus
return _TranslationStatus.deserialize(self._pipeline_response)

def _get_id_from_headers(self):
# type: () -> str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
_raise_if_bad_http_status_and_method,
)
from azure.core.polling.async_base_polling import AsyncLROBasePolling
from .._generated.models import TranslationStatus
from .._models import TranslationStatusResult
from .._generated.models import TranslationStatus as _TranslationStatus
from .._models import TranslationStatus

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

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

@property
def id(self) -> str:
Expand All @@ -38,12 +38,12 @@ def id(self) -> str:
)

@property
def details(self) -> TranslationStatusResult:
def details(self) -> TranslationStatus:
"""The details for the translation operation
:rtype: ~azure.ai.translation.document.TranslationStatusResult
:rtype: ~azure.ai.translation.document.TranslationStatus
"""
return TranslationStatusResult._from_generated( # pylint: disable=protected-access
return TranslationStatus._from_generated( # pylint: disable=protected-access
self._polling_method._current_body # pylint: disable=protected-access
)

Expand Down Expand Up @@ -72,8 +72,8 @@ def __init__(self, *args, **kwargs):
super(AsyncDocumentTranslationLROPollingMethod, self).__init__(*args, **kwargs)

@property
def _current_body(self) -> TranslationStatus:
return TranslationStatus.deserialize(self._pipeline_response)
def _current_body(self) -> _TranslationStatus:
return _TranslationStatus.deserialize(self._pipeline_response)

def _get_id_from_headers(self) -> str:
return self._pipeline_response.http_response.headers[
Expand Down
Loading

0 comments on commit 7849a11

Please sign in to comment.