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
3 changes: 1 addition & 2 deletions sdk/translation/azure-ai-translation-document/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
include azure/ai/translation/__init__.py
recursive-include doc *.rst
include azure/ai/translation/__init__.py
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": "4c6a2da5b444995bfdce5caec88633e0c2c70475",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/translation/Azure.AI.DocumentTranslation",
"@azure-tools/typespec-python": "0.36.1"
}
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 @@ -33,8 +33,9 @@ class DocumentTranslationClient(DocumentTranslationClientOperationsMixin):
AzureKeyCredential type or a TokenCredential 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-15-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 @@ -113,8 +114,9 @@ class SingleDocumentTranslationClient(SingleDocumentTranslationClientOperationsM
AzureKeyCredential type or a TokenCredential 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-15-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 @@ -30,13 +30,14 @@ class DocumentTranslationClientConfiguration: # pylint: disable=too-many-instan
AzureKeyCredential type or a TokenCredential 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-15-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-15-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -85,13 +86,14 @@ class SingleDocumentTranslationClientConfiguration: # pylint: disable=too-many-
AzureKeyCredential type or a TokenCredential 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-15-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-15-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 @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .. import _model_base, models as _models
from .._model_base import SdkJSONEncoder, _deserialize
from .._serialization import Serializer
from .._validation import api_version_validation
from .._vendor import (
DocumentTranslationClientMixinABC,
SingleDocumentTranslationClientMixinABC,
Expand All @@ -59,7 +60,7 @@ def build_document_translation__begin_translation_request( # pylint: disable=na
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -91,7 +92,7 @@ def build_document_translation_list_translation_statuses_request( # pylint: dis
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -132,7 +133,7 @@ def build_document_translation_get_document_status_request( # pylint: disable=n
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -159,7 +160,7 @@ def build_document_translation_get_translation_status_request( # pylint: disabl
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -185,7 +186,7 @@ def build_document_translation_cancel_translation_request( # pylint: disable=na
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -221,7 +222,7 @@ def build_document_translation_list_document_statuses_request( # pylint: disabl
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -267,7 +268,7 @@ def build_document_translation_get_supported_formats_request( # pylint: disable
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -290,12 +291,13 @@ def build_single_document_translation_translate_request( # pylint: disable=name
source_language: Optional[str] = None,
category: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any,
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-15-preview"))
accept = _headers.pop("Accept", "application/octet-stream")

# Construct URL
Expand All @@ -310,6 +312,10 @@ def build_single_document_translation_translate_request( # pylint: disable=name
_params["category"] = _SERIALIZER.query("category", category, "str")
if allow_fallback is not None:
_params["allowFallback"] = _SERIALIZER.query("allow_fallback", allow_fallback, "bool")
if translate_text_within_image is not None:
_params["translateTextWithinImage"] = _SERIALIZER.query(
"translate_text_within_image", translate_text_within_image, "bool"
)

# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
Expand Down Expand Up @@ -1243,6 +1249,7 @@ def translate(
source_language: Optional[str] = None,
category: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any,
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand Down Expand Up @@ -1273,6 +1280,9 @@ def translate(
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -1287,6 +1297,7 @@ def translate(
source_language: Optional[str] = None,
category: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any,
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand Down Expand Up @@ -1317,12 +1328,18 @@ def translate(
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace
@api_version_validation(
params_added_on={"2024-11-15-preview": ["translate_text_within_image"]},
)
def translate(
self,
body: Union[_models.DocumentTranslateContent, JSON],
Expand All @@ -1331,6 +1348,7 @@ def translate(
source_language: Optional[str] = None,
category: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any,
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand Down Expand Up @@ -1362,6 +1380,9 @@ def translate(
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -1389,6 +1410,7 @@ def translate(
source_language=source_language,
category=category,
allow_fallback=allow_fallback,
translate_text_within_image=translate_text_within_image,
api_version=self._config.api_version,
files=_files,
data=_data,
Expand Down Expand Up @@ -1417,6 +1439,13 @@ def translate(
raise HttpResponseError(response=response)

response_headers = {}
response_headers["x-metered-usage"] = self._deserialize("int", response.headers.get("x-metered-usage"))
response_headers["x-metered-usage-image-scan-count-pass"] = self._deserialize(
"int", response.headers.get("x-metered-usage-image-scan-count-pass")
)
response_headers["x-metered-usage-image-scan-count-fail"] = self._deserialize(
"int", response.headers.get("x-metered-usage-image-scan-count-fail")
)
response_headers["x-ms-client-request-id"] = self._deserialize(
"str", response.headers.get("x-ms-client-request-id")
)
Expand Down
Loading