Skip to content

Commit 360f6bd

Browse files
author
SDKAuto
committed
CodeGen from PR 33495 in Azure/azure-rest-api-specs
Merge 762e359637e295fa533f11bfa0836b60f95a9c84 into d18ba009da04dd6afc04402c39f87e032051fe9b
1 parent e37eeb2 commit 360f6bd

29 files changed

+690
-3041
lines changed

sdk/translation/azure-ai-translation-document/MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ recursive-include samples *.py *.md
66
include azure/__init__.py
77
include azure/ai/__init__.py
88
include azure/ai/translation/__init__.py
9-
recursive-include doc *.rst
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "21ac2e62a27a5f2bb82172a7f6a5b1c8a1037b78",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/translation/Azure.AI.DocumentTranslation",
5+
"@azure-tools/typespec-python": "0.42.2"
6+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"CrossLanguagePackageId": "DocumentTranslation",
3+
"CrossLanguageDefinitionId": {
4+
"azure.ai.translation.document.models.BatchOptions": "DocumentTranslation.BatchOptions",
5+
"azure.ai.translation.document.models.DocumentBatch": "DocumentTranslation.BatchRequest",
6+
"azure.ai.translation.document.models.DocumentFilter": "DocumentTranslation.DocumentFilter",
7+
"azure.ai.translation.document.models.DocumentStatus": "DocumentTranslation.DocumentStatus",
8+
"azure.ai.translation.document.models.DocumentTranslateContent": "DocumentTranslation.DocumentTranslateContent",
9+
"azure.ai.translation.document.models.DocumentTranslationError": "DocumentTranslation.TranslationError",
10+
"azure.ai.translation.document.models.DocumentTranslationFileFormat": "DocumentTranslation.FileFormat",
11+
"azure.ai.translation.document.models.InnerTranslationError": "DocumentTranslation.InnerTranslationError",
12+
"azure.ai.translation.document.models.SourceInput": "DocumentTranslation.SourceInput",
13+
"azure.ai.translation.document.models.StartTranslationDetails": "DocumentTranslation.StartTranslationDetails",
14+
"azure.ai.translation.document.models.TranslationGlossary": "DocumentTranslation.Glossary",
15+
"azure.ai.translation.document.models.TranslationStatus": "DocumentTranslation.TranslationStatus",
16+
"azure.ai.translation.document.models.TranslationStatusSummary": "DocumentTranslation.StatusSummary",
17+
"azure.ai.translation.document.models.TranslationTarget": "DocumentTranslation.TargetInput",
18+
"azure.ai.translation.document.models.Status": "DocumentTranslation.Status",
19+
"azure.ai.translation.document.models.TranslationErrorCode": "DocumentTranslation.TranslationErrorCode",
20+
"azure.ai.translation.document.models.TranslationStorageSource": "DocumentTranslation.StorageSource",
21+
"azure.ai.translation.document.models.StorageInputType": "DocumentTranslation.StorageInputType",
22+
"azure.ai.translation.document.models.FileFormatType": "DocumentTranslation.FileFormatType",
23+
"azure.ai.translation.document.DocumentTranslationClient.begin_translation": "ClientCustomizations.DocumentTranslationClient.startTranslation",
24+
"azure.ai.translation.document.DocumentTranslationClient.list_translation_statuses": "ClientCustomizations.DocumentTranslationClient.getTranslationsStatus",
25+
"azure.ai.translation.document.DocumentTranslationClient.get_document_status": "ClientCustomizations.DocumentTranslationClient.getDocumentStatus",
26+
"azure.ai.translation.document.DocumentTranslationClient.get_translation_status": "ClientCustomizations.DocumentTranslationClient.getTranslationStatus",
27+
"azure.ai.translation.document.DocumentTranslationClient.cancel_translation": "ClientCustomizations.DocumentTranslationClient.cancelTranslation",
28+
"azure.ai.translation.document.DocumentTranslationClient.list_document_statuses": "ClientCustomizations.DocumentTranslationClient.getDocumentsStatus",
29+
"azure.ai.translation.document.SingleDocumentTranslationClient.translate": "ClientCustomizations.SingleDocumentTranslationClient.documentTranslate"
30+
}
31+
}

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

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,30 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._patch import DocumentTranslationClient
10-
from ._client import SingleDocumentTranslationClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import DocumentTranslationClient # type: ignore
16+
from ._client import SingleDocumentTranslationClient # type: ignore
1117
from ._version import VERSION
1218

1319
__version__ = VERSION
1420

15-
16-
from ._patch import DocumentTranslationApiVersion
17-
from ._patch import DocumentTranslationLROPoller
18-
from ._patch import TranslationGlossary
19-
from ._patch import TranslationTarget
20-
from ._patch import DocumentTranslationInput
21-
from ._patch import TranslationStatus
22-
from ._patch import DocumentStatus
23-
from ._patch import DocumentTranslationError
24-
from ._patch import DocumentTranslationFileFormat
25-
from ._patch import StorageInputType
21+
try:
22+
from ._patch import __all__ as _patch_all
23+
from ._patch import *
24+
except ImportError:
25+
_patch_all = []
2626
from ._patch import patch_sdk as _patch_sdk
2727

2828
__all__ = [
29-
"DocumentTranslationApiVersion",
30-
"DocumentTranslationLROPoller",
31-
"TranslationGlossary",
32-
"TranslationTarget",
33-
"DocumentTranslationInput",
34-
"TranslationStatus",
35-
"DocumentStatus",
36-
"DocumentTranslationError",
37-
"DocumentTranslationFileFormat",
38-
"StorageInputType",
3929
"DocumentTranslationClient",
4030
"SingleDocumentTranslationClient",
4131
]
42-
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
4333

4434
_patch_sdk()

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ class DocumentTranslationClient(DocumentTranslationClientOperationsMixin):
2929
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
3030
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
3131
:type endpoint: str
32-
:param credential: Credential used to authenticate requests to the service. Is either a
33-
AzureKeyCredential type or a TokenCredential type. Required.
32+
:param credential: Credential used to authenticate requests to the service. Is either a key
33+
credential type or a token credential type. Required.
3434
:type credential: ~azure.core.credentials.AzureKeyCredential or
3535
~azure.core.credentials.TokenCredential
36-
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
37-
Note that overriding this default value may result in unsupported behavior.
36+
:keyword api_version: The API version to use for this operation. Default value is
37+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
38+
behavior.
3839
:paramtype api_version: str
3940
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
4041
Retry-After header is present.
@@ -109,12 +110,13 @@ class SingleDocumentTranslationClient(SingleDocumentTranslationClientOperationsM
109110
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
110111
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
111112
:type endpoint: str
112-
:param credential: Credential used to authenticate requests to the service. Is either a
113-
AzureKeyCredential type or a TokenCredential type. Required.
113+
:param credential: Credential used to authenticate requests to the service. Is either a key
114+
credential type or a token credential type. Required.
114115
:type credential: ~azure.core.credentials.AzureKeyCredential or
115116
~azure.core.credentials.TokenCredential
116-
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
117-
Note that overriding this default value may result in unsupported behavior.
117+
:keyword api_version: The API version to use for this operation. Default value is
118+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
119+
behavior.
118120
:paramtype api_version: str
119121
"""
120122

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ class DocumentTranslationClientConfiguration: # pylint: disable=too-many-instan
2626
:param endpoint: Supported document Translation endpoint, protocol and hostname, for example:
2727
https://{TranslatorResourceName}.cognitiveservices.azure.com/translator. Required.
2828
:type endpoint: str
29-
:param credential: Credential used to authenticate requests to the service. Is either a
30-
AzureKeyCredential type or a TokenCredential type. Required.
29+
:param credential: Credential used to authenticate requests to the service. Is either a key
30+
credential type or a token credential type. Required.
3131
:type credential: ~azure.core.credentials.AzureKeyCredential or
3232
~azure.core.credentials.TokenCredential
33-
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
34-
Note that overriding this default value may result in unsupported behavior.
33+
:keyword api_version: The API version to use for this operation. Default value is
34+
"2024-11-01-preview". Note that overriding this default value may result in unsupported
35+
behavior.
3536
:paramtype api_version: str
3637
"""
3738

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

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

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

9698
if endpoint is None:
9799
raise ValueError("Parameter 'endpoint' must not be None.")

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

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
# Licensed under the MIT License. See License.txt in the project root for
6-
# license information.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# Code generated by Microsoft (R) Python Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
78
# --------------------------------------------------------------------------
89
# pylint: disable=protected-access, broad-except
910

@@ -373,15 +374,34 @@ def __ne__(self, other: typing.Any) -> bool:
373374
return not self.__eq__(other)
374375

375376
def keys(self) -> typing.KeysView[str]:
377+
"""
378+
:returns: a set-like object providing a view on D's keys
379+
:rtype: ~typing.KeysView
380+
"""
376381
return self._data.keys()
377382

378383
def values(self) -> typing.ValuesView[typing.Any]:
384+
"""
385+
:returns: an object providing a view on D's values
386+
:rtype: ~typing.ValuesView
387+
"""
379388
return self._data.values()
380389

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

384397
def get(self, key: str, default: typing.Any = None) -> typing.Any:
398+
"""
399+
Get the value for key if key is in the dictionary, else default.
400+
:param str key: The key to look up.
401+
:param any default: The value to return if key is not in the dictionary. Defaults to None
402+
:returns: D[k] if k in D, else d.
403+
:rtype: any
404+
"""
385405
try:
386406
return self[key]
387407
except KeyError:
@@ -397,17 +417,38 @@ def pop(self, key: str, default: _T) -> _T: ...
397417
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
398418

399419
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
420+
"""
421+
Removes specified key and return the corresponding value.
422+
:param str key: The key to pop.
423+
:param any default: The value to return if key is not in the dictionary
424+
:returns: The value corresponding to the key.
425+
:rtype: any
426+
:raises KeyError: If key is not found and default is not given.
427+
"""
400428
if default is _UNSET:
401429
return self._data.pop(key)
402430
return self._data.pop(key, default)
403431

404432
def popitem(self) -> typing.Tuple[str, typing.Any]:
433+
"""
434+
Removes and returns some (key, value) pair
435+
:returns: The (key, value) pair.
436+
:rtype: tuple
437+
:raises KeyError: if D is empty.
438+
"""
405439
return self._data.popitem()
406440

407441
def clear(self) -> None:
442+
"""
443+
Remove all items from D.
444+
"""
408445
self._data.clear()
409446

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

413454
@typing.overload
@@ -417,6 +458,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
417458
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
418459

419460
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
461+
"""
462+
Same as calling D.get(k, d), and setting D[k]=d if k not found
463+
:param str key: The key to look up.
464+
:param any default: The value to set if key is not in the dictionary
465+
:returns: D[k] if k in D, else d.
466+
:rtype: any
467+
"""
420468
if default is _UNSET:
421469
return self._data.setdefault(key)
422470
return self._data.setdefault(key, default)
@@ -754,7 +802,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
754802
except AttributeError:
755803
model_name = annotation
756804
if module is not None:
757-
annotation = _get_model(module, model_name)
805+
annotation = _get_model(module, model_name) # type: ignore
758806

759807
try:
760808
if module and _is_model(annotation):
@@ -894,6 +942,35 @@ def _deserialize(
894942
return _deserialize_with_callable(deserializer, value)
895943

896944

945+
def _failsafe_deserialize(
946+
deserializer: typing.Any,
947+
value: typing.Any,
948+
module: typing.Optional[str] = None,
949+
rf: typing.Optional["_RestField"] = None,
950+
format: typing.Optional[str] = None,
951+
) -> typing.Any:
952+
try:
953+
return _deserialize(deserializer, value, module, rf, format)
954+
except DeserializationError:
955+
_LOGGER.warning(
956+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
957+
)
958+
return None
959+
960+
961+
def _failsafe_deserialize_xml(
962+
deserializer: typing.Any,
963+
value: typing.Any,
964+
) -> typing.Any:
965+
try:
966+
return _deserialize_xml(deserializer, value)
967+
except DeserializationError:
968+
_LOGGER.warning(
969+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
970+
)
971+
return None
972+
973+
897974
class _RestField:
898975
def __init__(
899976
self,

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._patch import DocumentTranslationClientOperationsMixin
10-
from ._patch import SingleDocumentTranslationClientOperationsMixin
10+
from typing import TYPE_CHECKING
1111

12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
1214

15+
from ._operations import DocumentTranslationClientOperationsMixin # type: ignore
16+
from ._operations import SingleDocumentTranslationClientOperationsMixin # type: ignore
17+
18+
from ._patch import __all__ as _patch_all
19+
from ._patch import *
1320
from ._patch import patch_sdk as _patch_sdk
1421

1522
__all__ = [
1623
"DocumentTranslationClientOperationsMixin",
1724
"SingleDocumentTranslationClientOperationsMixin",
1825
]
19-
26+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2027
_patch_sdk()

0 commit comments

Comments
 (0)