Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/translation/azure-ai-translation-document/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 0.0.0b1 (2025-03-26)

change log generation failed!!!

## 1.1.1 (Unreleased)

### Features Added
Expand Down
1 change: 0 additions & 1 deletion sdk/translation/azure-ai-translation-document/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
include azure/ai/translation/__init__.py
recursive-include doc *.rst
6 changes: 6 additions & 0 deletions sdk/translation/azure-ai-translation-document/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commit": "133c3722d1cc506fd1ed19a4d96b5a1e5a5cb919",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/translation/Azure.AI.DocumentTranslation",
"@azure-tools/typespec-python": "0.41.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"CrossLanguagePackageId": "DocumentTranslation",
"CrossLanguageDefinitionId": {
"azure.ai.translation.document.models.BatchOptions": "DocumentTranslation.BatchOptions",
"azure.ai.translation.document.models.DocumentBatch": "DocumentTranslation.BatchRequest",
"azure.ai.translation.document.models.DocumentFilter": "DocumentTranslation.DocumentFilter",
"azure.ai.translation.document.models.DocumentStatus": "DocumentTranslation.DocumentStatus",
"azure.ai.translation.document.models.DocumentTranslateContent": "DocumentTranslation.DocumentTranslateContent",
"azure.ai.translation.document.models.DocumentTranslationError": "DocumentTranslation.TranslationError",
"azure.ai.translation.document.models.DocumentTranslationFileFormat": "DocumentTranslation.FileFormat",
"azure.ai.translation.document.models.InnerTranslationError": "DocumentTranslation.InnerTranslationError",
"azure.ai.translation.document.models.SourceInput": "DocumentTranslation.SourceInput",
"azure.ai.translation.document.models.StartTranslationDetails": "DocumentTranslation.StartTranslationDetails",
"azure.ai.translation.document.models.TranslationErrorResponse": "DocumentTranslation.TranslationErrorResponse",
"azure.ai.translation.document.models.TranslationGlossary": "DocumentTranslation.Glossary",
"azure.ai.translation.document.models.TranslationStatus": "DocumentTranslation.TranslationStatus",
"azure.ai.translation.document.models.TranslationStatusSummary": "DocumentTranslation.StatusSummary",
"azure.ai.translation.document.models.TranslationTarget": "DocumentTranslation.TargetInput",
"azure.ai.translation.document.models.Status": "DocumentTranslation.Status",
"azure.ai.translation.document.models.TranslationErrorCode": "DocumentTranslation.TranslationErrorCode",
"azure.ai.translation.document.models.TranslationStorageSource": "DocumentTranslation.StorageSource",
"azure.ai.translation.document.models.StorageInputType": "DocumentTranslation.StorageInputType",
"azure.ai.translation.document.models.FileFormatType": "DocumentTranslation.FileFormatType",
"azure.ai.translation.document.DocumentTranslationClient.begin_translation": "ClientCustomizations.DocumentTranslationClient.startTranslation",
"azure.ai.translation.document.DocumentTranslationClient.list_translation_statuses": "ClientCustomizations.DocumentTranslationClient.getTranslationsStatus",
"azure.ai.translation.document.DocumentTranslationClient.get_document_status": "ClientCustomizations.DocumentTranslationClient.getDocumentStatus",
"azure.ai.translation.document.DocumentTranslationClient.get_translation_status": "ClientCustomizations.DocumentTranslationClient.getTranslationStatus",
"azure.ai.translation.document.DocumentTranslationClient.cancel_translation": "ClientCustomizations.DocumentTranslationClient.cancelTranslation",
"azure.ai.translation.document.DocumentTranslationClient.list_document_statuses": "ClientCustomizations.DocumentTranslationClient.getDocumentsStatus",
"azure.ai.translation.document.SingleDocumentTranslationClient.translate": "ClientCustomizations.SingleDocumentTranslationClient.documentTranslate"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,30 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._patch import DocumentTranslationClient
from ._client import SingleDocumentTranslationClient
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._client import DocumentTranslationClient # type: ignore
from ._client import SingleDocumentTranslationClient # type: ignore
from ._version import VERSION

__version__ = VERSION


from ._patch import DocumentTranslationApiVersion
from ._patch import DocumentTranslationLROPoller
from ._patch import TranslationGlossary
from ._patch import TranslationTarget
from ._patch import DocumentTranslationInput
from ._patch import TranslationStatus
from ._patch import DocumentStatus
from ._patch import DocumentTranslationError
from ._patch import DocumentTranslationFileFormat
from ._patch import StorageInputType
try:
from ._patch import __all__ as _patch_all
from ._patch import *
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"DocumentTranslationApiVersion",
"DocumentTranslationLROPoller",
"TranslationGlossary",
"TranslationTarget",
"DocumentTranslationInput",
"TranslationStatus",
"DocumentStatus",
"DocumentTranslationError",
"DocumentTranslationFileFormat",
"StorageInputType",
"DocumentTranslationClient",
"SingleDocumentTranslationClient",
]

__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ class DocumentTranslationClient(DocumentTranslationClientOperationsMixin):
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
Note that overriding this default value may result in unsupported behavior.
:keyword api_version: The API version to use for this operation. Default value is
"2024-11-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand Down Expand Up @@ -109,12 +110,13 @@ class SingleDocumentTranslationClient(SingleDocumentTranslationClientOperationsM
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
Note that overriding this default value may result in unsupported behavior.
:keyword api_version: The API version to use for this operation. Default value is
"2024-11-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ class DocumentTranslationClientConfiguration: # pylint: disable=too-many-instan
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
Note that overriding this default value may result in unsupported behavior.
:keyword api_version: The API version to use for this operation. Default value is
"2024-11-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-05-01")
api_version: str = kwargs.pop("api_version", "2024-11-01-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -81,17 +82,18 @@ class SingleDocumentTranslationClientConfiguration: # pylint: disable=too-many-
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
:type endpoint: str
:param credential: Credential used to authenticate requests to the service. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
Note that overriding this default value may result in unsupported behavior.
:keyword api_version: The API version to use for this operation. Default value is
"2024-11-01-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-05-01")
api_version: str = kwargs.pop("api_version", "2024-11-01-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool:
return not self.__eq__(other)

def keys(self) -> typing.KeysView[str]:
"""
:returns: a set-like object providing a view on D's keys
:rtype: ~typing.KeysView
"""
return self._data.keys()

def values(self) -> typing.ValuesView[typing.Any]:
"""
:returns: an object providing a view on D's values
:rtype: ~typing.ValuesView
"""
return self._data.values()

def items(self) -> typing.ItemsView[str, typing.Any]:
"""
:returns: set-like object providing a view on D's items
:rtype: ~typing.ItemsView
"""
return self._data.items()

def get(self, key: str, default: typing.Any = None) -> typing.Any:
"""
Get the value for key if key is in the dictionary, else default.
:param str key: The key to look up.
:param any default: The value to return if key is not in the dictionary. Defaults to None
:returns: D[k] if k in D, else d.
:rtype: any
"""
try:
return self[key]
except KeyError:
Expand All @@ -397,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ...
def pop(self, key: str, default: typing.Any) -> typing.Any: ...

def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
"""
Removes specified key and return the corresponding value.
:param str key: The key to pop.
:param any default: The value to return if key is not in the dictionary
:returns: The value corresponding to the key.
:rtype: any
:raises KeyError: If key is not found and default is not given.
"""
if default is _UNSET:
return self._data.pop(key)
return self._data.pop(key, default)

def popitem(self) -> typing.Tuple[str, typing.Any]:
"""
Removes and returns some (key, value) pair
:returns: The (key, value) pair.
:rtype: tuple
:raises KeyError: if D is empty.
"""
return self._data.popitem()

def clear(self) -> None:
"""
Remove all items from D.
"""
self._data.clear()

def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
"""
Updates D from mapping/iterable E and F.
:param any args: Either a mapping object or an iterable of key-value pairs.
"""
self._data.update(*args, **kwargs)

@typing.overload
Expand All @@ -417,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...

def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
"""
Same as calling D.get(k, d), and setting D[k]=d if k not found
:param str key: The key to look up.
:param any default: The value to set if key is not in the dictionary
:returns: D[k] if k in D, else d.
:rtype: any
"""
if default is _UNSET:
return self._data.setdefault(key)
return self._data.setdefault(key, default)
Expand Down Expand Up @@ -754,7 +801,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
except AttributeError:
model_name = annotation
if module is not None:
annotation = _get_model(module, model_name)
annotation = _get_model(module, model_name) # type: ignore

try:
if module and _is_model(annotation):
Expand Down Expand Up @@ -894,6 +941,35 @@ def _deserialize(
return _deserialize_with_callable(deserializer, value)


def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None


def _failsafe_deserialize_xml(
deserializer: typing.Any,
value: typing.Any,
) -> typing.Any:
try:
return _deserialize_xml(deserializer, value)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None


class _RestField:
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._patch import DocumentTranslationClientOperationsMixin
from ._patch import SingleDocumentTranslationClientOperationsMixin
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._operations import DocumentTranslationClientOperationsMixin # type: ignore
from ._operations import SingleDocumentTranslationClientOperationsMixin # type: ignore

from ._patch import __all__ as _patch_all
from ._patch import *
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"DocumentTranslationClientOperationsMixin",
"SingleDocumentTranslationClientOperationsMixin",
]

__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
_patch_sdk()
Loading