diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/_meta.json b/sdk/documentintelligence/azure-ai-documentintelligence/_meta.json new file mode 100644 index 0000000000000..1c6d16b51ff53 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/_meta.json @@ -0,0 +1,6 @@ +{ + "commit": "dd0459d5a8d99b8a15dcbc33fd5b7befe5494897", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/ai/DocumentIntelligence", + "@azure-tools/typespec-python": "0.37.0" +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/__init__.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/__init__.py index 5d62b4bb7381e..c474f6a4267ef 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/__init__.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/__init__.py @@ -5,21 +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 DocumentIntelligenceClient -from ._patch import DocumentIntelligenceAdministrationClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import DocumentIntelligenceClient # type: ignore +from ._client import DocumentIntelligenceAdministrationClient # type: ignore from ._version import VERSION __version__ = VERSION - -from ._patch import AnalyzeDocumentLROPoller +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AnalyzeDocumentLROPoller", "DocumentIntelligenceClient", "DocumentIntelligenceAdministrationClient", ] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_client.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_client.py index a90c19d86ac25..a0fc5dce5b250 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_client.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_client.py @@ -38,9 +38,8 @@ class DocumentIntelligenceClient(DocumentIntelligenceClientOperationsMixin): 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-07-31-preview". 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-30". + 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. @@ -118,9 +117,8 @@ class DocumentIntelligenceAdministrationClient(DocumentIntelligenceAdministratio 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-07-31-preview". 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-30". + 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. diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_configuration.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_configuration.py index 2a0cd7b020894..791799f9cf288 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_configuration.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_configuration.py @@ -29,14 +29,13 @@ class DocumentIntelligenceClientConfiguration: # pylint: disable=too-many-insta 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-07-31-preview". 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-30". + 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-07-31-preview") + api_version: str = kwargs.pop("api_version", "2024-11-30") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -84,14 +83,13 @@ class DocumentIntelligenceAdministrationClientConfiguration: # pylint: disable= 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-07-31-preview". 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-30". + 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-07-31-preview") + api_version: str = kwargs.pop("api_version", "2024-11-30") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_model_base.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_model_base.py index 9d401b0cf0120..7f73b97b23efa 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_model_base.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_model_base.py @@ -5,7 +5,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines +# pylint: disable=protected-access, broad-except import copy import calendar @@ -574,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' @@ -585,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di annotations = { k: v for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() } for attr, rf in attr_to_rest_field.items(): rf._module = cls.__module__ @@ -601,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: - if hasattr(base, "__mapping__"): # pylint: disable=no-member - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: @@ -613,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField @classmethod def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + if not hasattr(cls, "__mapping__"): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) if discriminator is None: @@ -633,7 +633,7 @@ def _deserialize(cls, data, exist_discriminators): discriminator_value = data.find(xml_name).text # pyright: ignore else: discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore return mapped_cls._deserialize(data, exist_discriminators) def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: @@ -754,7 +754,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): @@ -894,6 +894,22 @@ 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 + + class _RestField: def __init__( self, diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/__init__.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/__init__.py index 98b551bb5d272..63b6bbb81ed80 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/__init__.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/__init__.py @@ -5,15 +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 DocumentIntelligenceClientOperationsMixin -from ._patch import DocumentIntelligenceAdministrationClientOperationsMixin +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import DocumentIntelligenceClientOperationsMixin # type: ignore +from ._operations import DocumentIntelligenceAdministrationClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "DocumentIntelligenceClientOperationsMixin", "DocumentIntelligenceAdministrationClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_operations.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_operations.py index 4e00f61ddfd27..fa4b890381eb6 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_operations.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_operations.py @@ -31,7 +31,7 @@ from azure.core.utils import case_insensitive_dict from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize +from .._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._serialization import Serializer from .._vendor import DocumentIntelligenceAdministrationClientMixinABC, DocumentIntelligenceClientMixinABC @@ -55,7 +55,7 @@ def build_document_intelligence_analyze_document_request( # pylint: disable=nam string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> HttpRequest: @@ -63,7 +63,7 @@ def build_document_intelligence_analyze_document_request( # pylint: disable=nam _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,6 +99,88 @@ def build_document_intelligence_analyze_document_request( # pylint: disable=nam return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_document_intelligence_get_analyze_result_pdf_request( # pylint: disable=name-too-long + model_id: str, result_id: str, **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-11-30")) + accept = _headers.pop("Accept", "application/pdf") + + # Construct URL + _url = "/documentModels/{modelId}/analyzeResults/{resultId}/pdf" + path_format_arguments = { + "modelId": _SERIALIZER.url("model_id", model_id, "str"), + "resultId": _SERIALIZER.url("result_id", result_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_document_intelligence_get_analyze_result_figure_request( # pylint: disable=name-too-long + model_id: str, result_id: str, figure_id: str, **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-11-30")) + accept = _headers.pop("Accept", "image/png") + + # Construct URL + _url = "/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}" + path_format_arguments = { + "modelId": _SERIALIZER.url("model_id", model_id, "str"), + "resultId": _SERIALIZER.url("result_id", result_id, "str"), + "figureId": _SERIALIZER.url("figure_id", figure_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_document_intelligence_delete_analyze_result_request( # pylint: disable=name-too-long + model_id: str, result_id: str, **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-11-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/documentModels/{modelId}/analyzeResults/{resultId}" + path_format_arguments = { + "modelId": _SERIALIZER.url("model_id", model_id, "str"), + "resultId": _SERIALIZER.url("result_id", result_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + def build_document_intelligence_analyze_batch_documents_request( # pylint: disable=name-too-long model_id: str, *, @@ -107,7 +189,7 @@ def build_document_intelligence_analyze_batch_documents_request( # pylint: disa string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> HttpRequest: @@ -115,7 +197,7 @@ def build_document_intelligence_analyze_batch_documents_request( # pylint: disa _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -151,17 +233,43 @@ def build_document_intelligence_analyze_batch_documents_request( # pylint: disa return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_document_intelligence_get_analyze_result_pdf_request( # pylint: disable=name-too-long +def build_document_intelligence_list_analyze_batch_results_request( # pylint: disable=name-too-long + model_id: str, **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-11-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/documentModels/{modelId}/analyzeBatchResults" + path_format_arguments = { + "modelId": _SERIALIZER.url("model_id", model_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_document_intelligence_delete_analyze_batch_result_request( # pylint: disable=name-too-long model_id: str, result_id: str, **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-07-31-preview")) - accept = _headers.pop("Accept", "application/pdf") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/documentModels/{modelId}/analyzeResults/{resultId}/pdf" + _url = "/documentModels/{modelId}/analyzeBatchResults/{resultId}" path_format_arguments = { "modelId": _SERIALIZER.url("model_id", model_id, "str"), "resultId": _SERIALIZER.url("result_id", result_id, "str"), @@ -175,24 +283,23 @@ def build_document_intelligence_get_analyze_result_pdf_request( # pylint: disab # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_document_intelligence_get_analyze_result_figure_request( # pylint: disable=name-too-long - model_id: str, result_id: str, figure_id: str, **kwargs: Any +def build_document_intelligence_get_analyze_batch_result_request( # pylint: disable=name-too-long + model_id: str, result_id: str, **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-07-31-preview")) - accept = _headers.pop("Accept", "image/png") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}" + _url = "/documentModels/{modelId}/analyzeBatchResults/{resultId}" path_format_arguments = { "modelId": _SERIALIZER.url("model_id", model_id, "str"), "resultId": _SERIALIZER.url("result_id", result_id, "str"), - "figureId": _SERIALIZER.url("figure_id", figure_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -218,7 +325,7 @@ def build_document_intelligence_classify_document_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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,7 +360,7 @@ def build_document_intelligence_administration_build_document_model_request( # _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -277,7 +384,7 @@ def build_document_intelligence_administration_compose_model_request( # pylint: _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -301,7 +408,7 @@ def build_document_intelligence_administration_authorize_model_copy_request( # _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -325,7 +432,7 @@ def build_document_intelligence_administration_copy_model_to_request( # pylint: _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -353,7 +460,7 @@ def build_document_intelligence_administration_get_model_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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -379,7 +486,7 @@ def build_document_intelligence_administration_list_models_request( # pylint: d _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -400,7 +507,7 @@ def build_document_intelligence_administration_delete_model_request( # pylint: _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -420,13 +527,13 @@ def build_document_intelligence_administration_delete_model_request( # pylint: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_document_intelligence_administration_get_resource_info_request( # pylint: disable=name-too-long +def build_document_intelligence_administration_get_resource_details_request( # pylint: disable=name-too-long **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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -447,7 +554,7 @@ def build_document_intelligence_administration_get_operation_request( # pylint: _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -473,7 +580,7 @@ def build_document_intelligence_administration_list_operations_request( # pylin _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -495,7 +602,7 @@ def build_document_intelligence_administration_build_classifier_request( # pyli _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -519,7 +626,7 @@ def build_document_intelligence_administration_authorize_classifier_copy_request _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -543,7 +650,7 @@ def build_document_intelligence_administration_copy_classifier_to_request( # py _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -571,7 +678,7 @@ def build_document_intelligence_administration_get_classifier_request( # pylint _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -597,7 +704,7 @@ def build_document_intelligence_administration_list_classifiers_request( # pyli _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -618,7 +725,7 @@ def build_document_intelligence_administration_delete_classifier_request( # pyl _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-07-31-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-30")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -643,14 +750,14 @@ class DocumentIntelligenceClientOperationsMixin(DocumentIntelligenceClientMixinA def _analyze_document_initial( self, model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> Iterator[bytes]: @@ -670,13 +777,10 @@ def _analyze_document_initial( content_type = content_type or "application/json" _content = None - if isinstance(analyze_request, (IOBase, bytes)): - _content = analyze_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - if analyze_request is not None: - _content = json.dumps(analyze_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_analyze_document_request( model_id=model_id, @@ -711,7 +815,7 @@ def _analyze_document_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -729,14 +833,14 @@ def _analyze_document_initial( def begin_analyze_document( self, model_id: str, - analyze_request: Optional[_models.AnalyzeDocumentRequest] = None, + body: _models.AnalyzeDocumentRequest, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -745,10 +849,9 @@ def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -765,7 +868,8 @@ def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -781,14 +885,14 @@ def begin_analyze_document( def begin_analyze_document( self, model_id: str, - analyze_request: Optional[JSON] = None, + body: JSON, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -797,10 +901,9 @@ def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: JSON + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -817,7 +920,8 @@ def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -833,14 +937,14 @@ def begin_analyze_document( def begin_analyze_document( self, model_id: str, - analyze_request: Optional[IO[bytes]] = None, + body: IO[bytes], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -849,10 +953,9 @@ def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -869,7 +972,8 @@ def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -885,14 +989,14 @@ def begin_analyze_document( def begin_analyze_document( self, model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> LROPoller[_models.AnalyzeResult]: @@ -900,12 +1004,10 @@ def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Is one of the following types: - AnalyzeDocumentRequest, JSON, IO[bytes] Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or - IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Is one of the following types: AnalyzeDocumentRequest, + JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -922,7 +1024,8 @@ def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :return: An instance of LROPoller that returns AnalyzeResult. The AnalyzeResult is compatible @@ -941,7 +1044,7 @@ def begin_analyze_document( if cont_token is None: raw_result = self._analyze_document_initial( model_id=model_id, - analyze_request=analyze_request, + body=body, pages=pages, locale=locale, string_index_type=string_index_type, @@ -994,17 +1097,204 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace + def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) -> Iterator[bytes]: + """Gets the generated searchable PDF output from document analysis. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_document_intelligence_get_analyze_result_pdf_request( + model_id=model_id, + result_id=result_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_analyze_result_figure( + self, model_id: str, result_id: str, figure_id: str, **kwargs: Any + ) -> Iterator[bytes]: + """Gets the generated cropped image of specified figure from document analysis. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :param figure_id: Figure ID. Required. + :type figure_id: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_document_intelligence_get_analyze_result_figure_request( + model_id=model_id, + result_id=result_id, + figure_id=figure_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_analyze_result( # pylint: disable=inconsistent-return-statements + self, model_id: str, result_id: str, **kwargs: Any + ) -> None: + """Mark the result of document analysis for deletion. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_document_intelligence_delete_analyze_result_request( + model_id=model_id, + result_id=result_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + def _analyze_batch_documents_initial( self, model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> Iterator[bytes]: @@ -1024,13 +1314,10 @@ def _analyze_batch_documents_initial( content_type = content_type or "application/json" _content = None - if isinstance(analyze_batch_request, (IOBase, bytes)): - _content = analyze_batch_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - if analyze_batch_request is not None: - _content = json.dumps(analyze_batch_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_analyze_batch_documents_request( model_id=model_id, @@ -1065,7 +1352,7 @@ def _analyze_batch_documents_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1083,14 +1370,14 @@ def _analyze_batch_documents_initial( def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[_models.AnalyzeBatchDocumentsRequest] = None, + body: _models.AnalyzeBatchDocumentsRequest, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -1099,10 +1386,9 @@ def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -1119,7 +1405,8 @@ def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -1135,14 +1422,14 @@ def begin_analyze_batch_documents( def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[JSON] = None, + body: JSON, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -1151,10 +1438,9 @@ def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: JSON + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -1171,7 +1457,8 @@ def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -1187,14 +1474,14 @@ def begin_analyze_batch_documents( def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[IO[bytes]] = None, + body: IO[bytes], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any, @@ -1203,10 +1490,9 @@ def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -1223,7 +1509,8 @@ def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -1239,14 +1526,14 @@ def begin_analyze_batch_documents( def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, ) -> LROPoller[_models.AnalyzeBatchResult]: @@ -1254,12 +1541,11 @@ def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Is one of the following types: - AnalyzeBatchDocumentsRequest, JSON, IO[bytes] Default value is None. - :type analyze_batch_request: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest - or JSON or IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Is one of the following types: + AnalyzeBatchDocumentsRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest or JSON or + IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -1276,7 +1562,8 @@ def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :return: An instance of LROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult is @@ -1295,7 +1582,7 @@ def begin_analyze_batch_documents( if cont_token is None: raw_result = self._analyze_batch_documents_initial( model_id=model_id, - analyze_batch_request=analyze_batch_request, + body=body, pages=pages, locale=locale, string_index_type=string_index_type, @@ -1349,15 +1636,104 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) -> Iterator[bytes]: - """Gets the generated searchable PDF output from document analysis. + def list_analyze_batch_results(self, model_id: str, **kwargs: Any) -> Iterable["_models.AnalyzeBatchOperation"]: + """List batch document analysis results. :param model_id: Unique document model name. Required. :type model_id: str - :param result_id: Analyze operation result ID. Required. + :return: An iterator like instance of AnalyzeBatchOperation + :rtype: + ~azure.core.paging.ItemPaged[~azure.ai.documentintelligence.models.AnalyzeBatchOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AnalyzeBatchOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_document_intelligence_list_analyze_batch_results_request( + model_id=model_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AnalyzeBatchOperation], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def delete_analyze_batch_result( # pylint: disable=inconsistent-return-statements + self, model_id: str, result_id: str, **kwargs: Any + ) -> None: + """Mark the batch document analysis result for deletion. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze batch operation result ID. Required. :type result_id: str - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1371,9 +1747,9 @@ def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_document_intelligence_get_analyze_result_pdf_request( + _request = build_document_intelligence_delete_analyze_batch_result_request( model_id=model_id, result_id=result_id, api_version=self._config.api_version, @@ -1385,47 +1761,31 @@ def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) - } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get_analyze_result_figure( - self, model_id: str, result_id: str, figure_id: str, **kwargs: Any - ) -> Iterator[bytes]: - """Gets the generated cropped image of specified figure from document analysis. + def get_analyze_batch_result(self, model_id: str, result_id: str, **kwargs: Any) -> _models.AnalyzeBatchOperation: + """Gets the result of batch document analysis. :param model_id: Unique document model name. Required. :type model_id: str - :param result_id: Analyze operation result ID. Required. + :param result_id: Analyze batch operation result ID. Required. :type result_id: str - :param figure_id: Figure ID. Required. - :type figure_id: str - :return: Iterator[bytes] - :rtype: Iterator[bytes] + :return: AnalyzeBatchOperation. The AnalyzeBatchOperation is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.AnalyzeBatchOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1439,12 +1799,11 @@ def get_analyze_result_figure( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.AnalyzeBatchOperation] = kwargs.pop("cls", None) - _request = build_document_intelligence_get_analyze_result_figure_request( + _request = build_document_intelligence_get_analyze_batch_result_request( model_id=model_id, result_id=result_id, - figure_id=figure_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1454,7 +1813,7 @@ def get_analyze_result_figure( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1468,23 +1827,23 @@ def get_analyze_result_figure( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AnalyzeBatchOperation, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore def _classify_document_initial( self, classifier_id: str, - classify_request: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], + body: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1507,10 +1866,10 @@ def _classify_document_initial( content_type = content_type or "application/json" _content = None - if isinstance(classify_request, (IOBase, bytes)): - _content = classify_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(classify_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_classify_document_request( classifier_id=classifier_id, @@ -1541,7 +1900,7 @@ def _classify_document_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1559,7 +1918,7 @@ def _classify_document_initial( def begin_classify_document( self, classifier_id: str, - classify_request: _models.ClassifyDocumentRequest, + body: _models.ClassifyDocumentRequest, *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1571,16 +1930,15 @@ def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest + :param body: Classify request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -1595,7 +1953,7 @@ def begin_classify_document( def begin_classify_document( self, classifier_id: str, - classify_request: JSON, + body: JSON, *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1607,16 +1965,15 @@ def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: JSON + :param body: Classify request parameters. Required. + :type body: JSON :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -1631,7 +1988,7 @@ def begin_classify_document( def begin_classify_document( self, classifier_id: str, - classify_request: IO[bytes], + body: IO[bytes], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1643,16 +2000,15 @@ def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: IO[bytes] + :param body: Classify request parameters. Required. + :type body: IO[bytes] :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1667,7 +2023,7 @@ def begin_classify_document( def begin_classify_document( self, classifier_id: str, - classify_request: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], + body: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1678,18 +2034,16 @@ def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Is one of the following types: + :param body: Classify request parameters. Is one of the following types: ClassifyDocumentRequest, JSON, IO[bytes] Required. - :type classify_request: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest or JSON - or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest or JSON or IO[bytes] :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :return: An instance of LROPoller that returns AnalyzeResult. The AnalyzeResult is compatible with MutableMapping @@ -1707,7 +2061,7 @@ def begin_classify_document( if cont_token is None: raw_result = self._classify_document_initial( classifier_id=classifier_id, - classify_request=classify_request, + body=body, string_index_type=string_index_type, split=split, pages=pages, @@ -1762,7 +2116,7 @@ class DocumentIntelligenceAdministrationClientOperationsMixin( # pylint: disabl ): def _build_document_model_initial( - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1780,10 +2134,10 @@ def _build_document_model_initial( content_type = content_type or "application/json" _content = None - if isinstance(build_request, (IOBase, bytes)): - _content = build_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(build_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_build_document_model_request( content_type=content_type, @@ -1810,7 +2164,7 @@ def _build_document_model_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1826,12 +2180,12 @@ def _build_document_model_initial( @overload def begin_build_document_model( - self, build_request: _models.BuildDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any + self, body: _models.BuildDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest + :param body: Build request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1844,12 +2198,12 @@ def begin_build_document_model( @overload def begin_build_document_model( - self, build_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: JSON + :param body: Build request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1862,12 +2216,12 @@ def begin_build_document_model( @overload def begin_build_document_model( - self, build_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: IO[bytes] + :param body: Build request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1880,13 +2234,13 @@ def begin_build_document_model( @distributed_trace def begin_build_document_model( - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Is one of the following types: + :param body: Build request parameters. Is one of the following types: BuildDocumentModelRequest, JSON, IO[bytes] Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest or JSON or + :type body: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest or JSON or IO[bytes] :return: An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping @@ -1904,12 +2258,7 @@ def begin_build_document_model( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._build_document_model_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -1951,7 +2300,7 @@ def get_long_running_output(pipeline_response): ) def _compose_model_initial( - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1969,10 +2318,10 @@ def _compose_model_initial( content_type = content_type or "application/json" _content = None - if isinstance(compose_request, (IOBase, bytes)): - _content = compose_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(compose_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_compose_model_request( content_type=content_type, @@ -1999,7 +2348,7 @@ def _compose_model_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2015,16 +2364,12 @@ def _compose_model_initial( @overload def begin_compose_model( - self, - compose_request: _models.ComposeDocumentModelRequest, - *, - content_type: str = "application/json", - **kwargs: Any, + self, body: _models.ComposeDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest + :param body: Compose request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2037,12 +2382,12 @@ def begin_compose_model( @overload def begin_compose_model( - self, compose_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: JSON + :param body: Compose request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2055,12 +2400,12 @@ def begin_compose_model( @overload def begin_compose_model( - self, compose_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: IO[bytes] + :param body: Compose request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2073,14 +2418,14 @@ def begin_compose_model( @distributed_trace def begin_compose_model( - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Is one of the following types: + :param body: Compose request parameters. Is one of the following types: ComposeDocumentModelRequest, JSON, IO[bytes] Required. - :type compose_request: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest or JSON or + IO[bytes] :return: An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping :rtype: @@ -2097,12 +2442,7 @@ def begin_compose_model( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._compose_model_initial( - compose_request=compose_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -2145,72 +2485,67 @@ def get_long_running_output(pipeline_response): @overload def authorize_model_copy( - self, - authorize_copy_request: _models.AuthorizeCopyRequest, - *, - content_type: str = "application/json", - **kwargs: Any, - ) -> _models.CopyAuthorization: + self, body: _models.AuthorizeCopyRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest + :param body: Authorize copy request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @overload def authorize_model_copy( - self, authorize_copy_request: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: JSON + :param body: Authorize copy request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @overload def authorize_model_copy( - self, authorize_copy_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: IO[bytes] + :param body: Authorize copy request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def authorize_model_copy( - self, authorize_copy_request: Union[_models.AuthorizeCopyRequest, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: Union[_models.AuthorizeCopyRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Is one of the following - types: AuthorizeCopyRequest, JSON, IO[bytes] Required. - :type authorize_copy_request: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest or - JSON or IO[bytes] - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :param body: Authorize copy request parameters. Is one of the following types: + AuthorizeCopyRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest or JSON or IO[bytes] + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2225,14 +2560,14 @@ def authorize_model_copy( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CopyAuthorization] = kwargs.pop("cls", None) + cls: ClsType[_models.ModelCopyAuthorization] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(authorize_copy_request, (IOBase, bytes)): - _content = authorize_copy_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(authorize_copy_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_authorize_model_copy_request( content_type=content_type, @@ -2260,13 +2595,13 @@ def authorize_model_copy( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.CopyAuthorization, response.json()) + deserialized = _deserialize(_models.ModelCopyAuthorization, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2274,7 +2609,7 @@ def authorize_model_copy( return deserialized # type: ignore def _copy_model_to_initial( - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any + self, model_id: str, body: Union[_models.ModelCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2292,10 +2627,10 @@ def _copy_model_to_initial( content_type = content_type or "application/json" _content = None - if isinstance(copy_to_request, (IOBase, bytes)): - _content = copy_to_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(copy_to_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_copy_model_to_request( model_id=model_id, @@ -2323,7 +2658,7 @@ def _copy_model_to_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2341,7 +2676,7 @@ def _copy_model_to_initial( def begin_copy_model_to( self, model_id: str, - copy_to_request: _models.CopyAuthorization, + body: _models.ModelCopyAuthorization, *, content_type: str = "application/json", **kwargs: Any, @@ -2350,8 +2685,8 @@ def begin_copy_model_to( :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.CopyAuthorization + :param body: Copy to request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2364,14 +2699,14 @@ def begin_copy_model_to( @overload def begin_copy_model_to( - self, model_id: str, copy_to_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, model_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: JSON + :param body: Copy to request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2384,14 +2719,14 @@ def begin_copy_model_to( @overload def begin_copy_model_to( - self, model_id: str, copy_to_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, model_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: IO[bytes] + :param body: Copy to request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2404,16 +2739,15 @@ def begin_copy_model_to( @distributed_trace def begin_copy_model_to( - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any + self, model_id: str, body: Union[_models.ModelCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Is one of the following types: - CopyAuthorization, JSON, IO[bytes] Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.CopyAuthorization or JSON or - IO[bytes] + :param body: Copy to request parameters. Is one of the following types: ModelCopyAuthorization, + JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.ModelCopyAuthorization or JSON or IO[bytes] :return: An instance of LROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping :rtype: @@ -2431,7 +2765,7 @@ def begin_copy_model_to( if cont_token is None: raw_result = self._copy_model_to_initial( model_id=model_id, - copy_to_request=copy_to_request, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2525,7 +2859,7 @@ def get_model(self, model_id: str, **kwargs: Any) -> _models.DocumentModelDetail except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2620,7 +2954,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2670,7 +3004,7 @@ def delete_model(self, model_id: str, **kwargs: Any) -> None: # pylint: disable if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2682,11 +3016,12 @@ def delete_model(self, model_id: str, **kwargs: Any) -> None: # pylint: disable return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace - def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: + def get_resource_details(self, **kwargs: Any) -> _models.DocumentIntelligenceResourceDetails: """Return information about the current resource. - :return: ResourceDetails. The ResourceDetails is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.ResourceDetails + :return: DocumentIntelligenceResourceDetails. The DocumentIntelligenceResourceDetails is + compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.DocumentIntelligenceResourceDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2700,9 +3035,9 @@ def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ResourceDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.DocumentIntelligenceResourceDetails] = kwargs.pop("cls", None) - _request = build_document_intelligence_administration_get_resource_info_request( + _request = build_document_intelligence_administration_get_resource_details_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -2726,13 +3061,13 @@ def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.ResourceDetails, response.json()) + deserialized = _deserialize(_models.DocumentIntelligenceResourceDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2740,13 +3075,14 @@ def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: return deserialized # type: ignore @distributed_trace - def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDetails: + def get_operation(self, operation_id: str, **kwargs: Any) -> _models.DocumentIntelligenceOperationDetails: """Gets operation info. :param operation_id: Operation ID. Required. :type operation_id: str - :return: OperationDetails. The OperationDetails is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.OperationDetails + :return: DocumentIntelligenceOperationDetails. The DocumentIntelligenceOperationDetails is + compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2760,7 +3096,7 @@ def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDe _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.DocumentIntelligenceOperationDetails] = kwargs.pop("cls", None) _request = build_document_intelligence_administration_get_operation_request( operation_id=operation_id, @@ -2787,7 +3123,7 @@ def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDe except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2798,7 +3134,7 @@ def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDe if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.OperationDetails, response.json()) + deserialized = _deserialize(_models.DocumentIntelligenceOperationDetails, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2806,17 +3142,18 @@ def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDe return deserialized # type: ignore @distributed_trace - def list_operations(self, **kwargs: Any) -> Iterable["_models.OperationDetails"]: + def list_operations(self, **kwargs: Any) -> Iterable["_models.DocumentIntelligenceOperationDetails"]: """Lists all operations. - :return: An iterator like instance of OperationDetails - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.documentintelligence.models.OperationDetails] + :return: An iterator like instance of DocumentIntelligenceOperationDetails + :rtype: + ~azure.core.paging.ItemPaged[~azure.ai.documentintelligence.models.DocumentIntelligenceOperationDetails] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.OperationDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.DocumentIntelligenceOperationDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2865,7 +3202,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OperationDetails], deserialized["value"]) + list_of_elem = _deserialize(List[_models.DocumentIntelligenceOperationDetails], deserialized["value"]) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -2881,7 +3218,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2889,7 +3226,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) def _build_classifier_initial( - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2907,10 +3244,10 @@ def _build_classifier_initial( content_type = content_type or "application/json" _content = None - if isinstance(build_request, (IOBase, bytes)): - _content = build_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(build_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_build_classifier_request( content_type=content_type, @@ -2937,7 +3274,7 @@ def _build_classifier_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2953,16 +3290,12 @@ def _build_classifier_initial( @overload def begin_build_classifier( - self, - build_request: _models.BuildDocumentClassifierRequest, - *, - content_type: str = "application/json", - **kwargs: Any, + self, body: _models.BuildDocumentClassifierRequest, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest + :param body: Build request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2975,12 +3308,12 @@ def begin_build_classifier( @overload def begin_build_classifier( - self, build_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: JSON + :param body: Build request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2993,12 +3326,12 @@ def begin_build_classifier( @overload def begin_build_classifier( - self, build_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: IO[bytes] + :param body: Build request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -3011,14 +3344,14 @@ def begin_build_classifier( @distributed_trace def begin_build_classifier( - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Is one of the following types: + :param body: Build request parameters. Is one of the following types: BuildDocumentClassifierRequest, JSON, IO[bytes] Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest or JSON or + IO[bytes] :return: An instance of LROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping :rtype: @@ -3035,12 +3368,7 @@ def begin_build_classifier( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._build_classifier_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -3083,18 +3411,13 @@ def get_long_running_output(pipeline_response): @overload def authorize_classifier_copy( - self, - authorize_copy_request: _models.AuthorizeClassifierCopyRequest, - *, - content_type: str = "application/json", - **kwargs: Any, + self, body: _models.AuthorizeClassifierCopyRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: - ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest + :param body: Authorize copy request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3106,13 +3429,13 @@ def authorize_classifier_copy( @overload def authorize_classifier_copy( - self, authorize_copy_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: JSON + :param body: Authorize copy request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3124,13 +3447,13 @@ def authorize_classifier_copy( @overload def authorize_classifier_copy( - self, authorize_copy_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: IO[bytes] + :param body: Authorize copy request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -3142,15 +3465,15 @@ def authorize_classifier_copy( @distributed_trace def authorize_classifier_copy( - self, authorize_copy_request: Union[_models.AuthorizeClassifierCopyRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.AuthorizeClassifierCopyRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Is one of the following - types: AuthorizeClassifierCopyRequest, JSON, IO[bytes] Required. - :type authorize_copy_request: - ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest or JSON or IO[bytes] + :param body: Authorize copy request parameters. Is one of the following types: + AuthorizeClassifierCopyRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest or JSON or + IO[bytes] :return: ClassifierCopyAuthorization. The ClassifierCopyAuthorization is compatible with MutableMapping :rtype: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization @@ -3172,10 +3495,10 @@ def authorize_classifier_copy( content_type = content_type or "application/json" _content = None - if isinstance(authorize_copy_request, (IOBase, bytes)): - _content = authorize_copy_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(authorize_copy_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_authorize_classifier_copy_request( content_type=content_type, @@ -3203,7 +3526,7 @@ def authorize_classifier_copy( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: @@ -3217,10 +3540,7 @@ def authorize_classifier_copy( return deserialized # type: ignore def _copy_classifier_to_initial( - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any, + self, classifier_id: str, body: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3238,10 +3558,10 @@ def _copy_classifier_to_initial( content_type = content_type or "application/json" _content = None - if isinstance(copy_to_request, (IOBase, bytes)): - _content = copy_to_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(copy_to_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_copy_classifier_to_request( classifier_id=classifier_id, @@ -3269,7 +3589,7 @@ def _copy_classifier_to_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -3287,7 +3607,7 @@ def _copy_classifier_to_initial( def begin_copy_classifier_to( self, classifier_id: str, - copy_to_request: _models.ClassifierCopyAuthorization, + body: _models.ClassifierCopyAuthorization, *, content_type: str = "application/json", **kwargs: Any, @@ -3296,8 +3616,8 @@ def begin_copy_classifier_to( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization + :param body: Copy to request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3310,14 +3630,14 @@ def begin_copy_classifier_to( @overload def begin_copy_classifier_to( - self, classifier_id: str, copy_to_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, classifier_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: JSON + :param body: Copy to request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3330,14 +3650,14 @@ def begin_copy_classifier_to( @overload def begin_copy_classifier_to( - self, classifier_id: str, copy_to_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, classifier_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: IO[bytes] + :param body: Copy to request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -3350,19 +3670,16 @@ def begin_copy_classifier_to( @distributed_trace def begin_copy_classifier_to( - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any, + self, classifier_id: str, body: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Is one of the following types: + :param body: Copy to request parameters. Is one of the following types: ClassifierCopyAuthorization, JSON, IO[bytes] Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization or JSON or + IO[bytes] :return: An instance of LROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping :rtype: @@ -3380,7 +3697,7 @@ def begin_copy_classifier_to( if cont_token is None: raw_result = self._copy_classifier_to_initial( classifier_id=classifier_id, - copy_to_request=copy_to_request, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -3475,7 +3792,7 @@ def get_classifier(self, classifier_id: str, **kwargs: Any) -> _models.DocumentC except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -3570,7 +3887,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -3622,7 +3939,7 @@ def delete_classifier( # pylint: disable=inconsistent-return-statements if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_patch.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_patch.py index 1d019820174ec..f7dd32510333d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_patch.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_patch.py @@ -6,697 +6,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -import sys -import re -from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, Mapping, cast, overload +from typing import List -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from ._operations import ( - DocumentIntelligenceClientOperationsMixin as GeneratedDIClientOps, - DocumentIntelligenceAdministrationClientOperationsMixin as GeneratedDIAdminClientOps, -) -from .. import models as _models -from .._model_base import _deserialize - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -PollingReturnType_co = TypeVar("PollingReturnType_co", covariant=True) -_FINISHED = frozenset(["succeeded", "canceled", "failed", "completed"]) - - -def _parse_operation_id(operation_location_header): - regex = "[^:]+://[^/]+/documentintelligence/.+/([^?/]+)" - return re.match(regex, operation_location_header).group(1) - - -def _finished(status) -> bool: - if hasattr(status, "value"): - status = status.value - return str(status).lower() in _FINISHED - - -class AnalyzeDocumentLROPoller(LROPoller[PollingReturnType_co]): - @property - def details(self) -> Mapping[str, Any]: - """Returns metadata associated with the long-running operation. - - :return: Returns metadata associated with the long-running operation. - :rtype: Mapping[str, Any] - """ - return { - "operation_id": _parse_operation_id( - self.polling_method()._initial_response.http_response.headers["Operation-Location"] # type: ignore # pylint: disable=protected-access - ), - } - - @classmethod - def from_continuation_token( - cls, polling_method: PollingMethod[PollingReturnType_co], continuation_token: str, **kwargs: Any - ) -> "AnalyzeDocumentLROPoller": - ( - client, - initial_response, - deserialization_callback, - ) = polling_method.from_continuation_token(continuation_token, **kwargs) - - return cls(client, initial_response, deserialization_callback, polling_method) - - -class AnalyzeBatchDocumentsLROPollingMethod(LROBasePolling): - def finished(self) -> bool: - """Is this polling finished? - - :return: Whether polling is finished or not. - :rtype: bool - """ - return _finished(self.status()) - - -class DocumentIntelligenceAdministrationClientOperationsMixin( - GeneratedDIAdminClientOps -): # pylint: disable=name-too-long - @distributed_trace - def begin_build_classifier( - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DocumentClassifierDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._build_classifier_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentClassifierDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DocumentClassifierDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DocumentClassifierDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def begin_build_document_model( - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._build_document_model_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def begin_compose_model( - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._compose_model_initial( - compose_request=compose_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def begin_copy_model_to( - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._copy_model_to_initial( - model_id=model_id, - copy_to_request=copy_to_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def begin_copy_classifier_to( - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any, - ) -> LROPoller[_models.DocumentClassifierDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._copy_classifier_to_initial( - classifier_id=classifier_id, - copy_to_request=copy_to_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentClassifierDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DocumentClassifierDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DocumentClassifierDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DocumentIntelligenceClientOperationsMixin(GeneratedDIClientOps): # pylint: disable=name-too-long - @overload - def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[_models.AnalyzeDocumentRequest] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> AnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible - with MutableMapping - :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[JSON] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> AnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible - with MutableMapping - :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[IO[bytes]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any, - ) -> AnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible - with MutableMapping - :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - **kwargs: Any, - ) -> AnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Is one of the following types: - AnalyzeDocumentRequest, JSON, IO[bytes] Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or - IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :return: An instance of AnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible - with MutableMapping - :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[_models.AnalyzeResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._analyze_document_initial( - model_id=model_id, - analyze_request=analyze_request, - pages=pages, - locale=locale, - string_index_type=string_index_type, - features=features, - query_fields=query_fields, - output_content_format=output_content_format, - output=output, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs, - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.AnalyzeResult, response.json().get("analyzeResult")) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return AnalyzeDocumentLROPoller[_models.AnalyzeResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AnalyzeDocumentLROPoller[_models.AnalyzeResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def begin_analyze_batch_documents( - self, - model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - **kwargs: Any, - ) -> LROPoller[_models.AnalyzeBatchResult]: - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - return super().begin_analyze_batch_documents( - model_id=model_id, - analyze_batch_request=analyze_batch_request, - pages=pages, - locale=locale, - string_index_type=string_index_type, - features=features, - query_fields=query_fields, - output_content_format=output_content_format, - output=output, - polling=AnalyzeBatchDocumentsLROPollingMethod(timeout=lro_delay), - **kwargs, - ) - - -__all__: List[str] = [ - "DocumentIntelligenceClientOperationsMixin", - "DocumentIntelligenceAdministrationClientOperationsMixin", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_patch.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_patch.py index 7ec98325b6140..f7dd32510333d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_patch.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_patch.py @@ -6,86 +6,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, List, Union -from azure.core.credentials import AzureKeyCredential, TokenCredential -from ._client import ( - DocumentIntelligenceClient as DIClientGenerated, - DocumentIntelligenceAdministrationClient as DIAClientGenerated, -) -from ._operations._patch import AnalyzeDocumentLROPoller +from typing import List - -class DocumentIntelligenceClient(DIClientGenerated): - """DocumentIntelligenceClient. - - :param endpoint: The Document Intelligence service endpoint. Required. - :type endpoint: str - :param credential: Credential needed for the client to connect to Azure. Is either a - 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-07-31-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. - """ - - def __init__( - self, - endpoint: str, - credential: Union[AzureKeyCredential, TokenCredential], - **kwargs: Any, - ) -> None: - # Patch the default polling interval to be 1s. - polling_interval = kwargs.pop("polling_interval", 1) - super().__init__( - endpoint=endpoint, - credential=credential, - polling_interval=polling_interval, - **kwargs, - ) - - -class DocumentIntelligenceAdministrationClient(DIAClientGenerated): - """DocumentIntelligenceAdministrationClient. - - :param endpoint: The Document Intelligence service endpoint. Required. - :type endpoint: str - :param credential: Credential needed for the client to connect to Azure. Is either a - 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-07-31-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. - """ - - def __init__( - self, - endpoint: str, - credential: Union[AzureKeyCredential, TokenCredential], - **kwargs: Any, - ) -> None: - # Patch the default polling interval to be 1s. - polling_interval = kwargs.pop("polling_interval", 1) - super().__init__( - endpoint=endpoint, - credential=credential, - polling_interval=polling_interval, - **kwargs, - ) - - -__all__: List[str] = [ - "DocumentIntelligenceClient", - "DocumentIntelligenceAdministrationClient", - "AnalyzeDocumentLROPoller", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_serialization.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_serialization.py index 480e941d758f0..b24ab2885450d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_serialization.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -309,7 +310,7 @@ def _create_xml_node(tag, prefix=None, ns=None): return ET.Element(tag) -class Model(object): +class Model: """Mixin for all client request body/response body models to support serialization and deserialization. """ @@ -506,7 +507,6 @@ def _flatten_subtype(cls, key, objects): def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. :param dict response: The initial data :param dict objects: The class objects @@ -518,7 +518,7 @@ def _classify(cls, response, objects): if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -563,7 +563,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -1441,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1683,17 +1683,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_validation.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_validation.py deleted file mode 100644 index 752b2822f9d3e..0000000000000 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_validation.py +++ /dev/null @@ -1,50 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import functools - - -def api_version_validation(**kwargs): - params_added_on = kwargs.pop("params_added_on", {}) - method_added_on = kwargs.pop("method_added_on", "") - - def decorator(func): - @functools.wraps(func) - def wrapper(*args, **kwargs): - try: - # this assumes the client has an _api_version attribute - client = args[0] - client_api_version = client._config.api_version # pylint: disable=protected-access - except AttributeError: - return func(*args, **kwargs) - - if method_added_on > client_api_version: - raise ValueError( - f"'{func.__name__}' is not available in API version " - f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." - ) - - unsupported = { - parameter: api_version - for api_version, parameters in params_added_on.items() - for parameter in parameters - if parameter in kwargs and api_version > client_api_version - } - if unsupported: - raise ValueError( - "".join( - [ - f"'{param}' is not available in API version {client_api_version}. " - f"Use service API version {version} or newer.\n" - for param, version in unsupported.items() - ] - ) - ) - return func(*args, **kwargs) - - return wrapper - - return decorator diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_version.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_version.py index c7d155d924dde..0ec13ea52bbf5 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_version.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b5" +VERSION = "1.0.0" diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/__init__.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/__init__.py index d42be0aa8a751..02790b905f25f 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/__init__.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/__init__.py @@ -5,18 +5,27 @@ # 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 DocumentIntelligenceClient -from ._patch import DocumentIntelligenceAdministrationClient +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import AsyncAnalyzeDocumentLROPoller +from ._client import DocumentIntelligenceClient # type: ignore +from ._client import DocumentIntelligenceAdministrationClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AsyncAnalyzeDocumentLROPoller", "DocumentIntelligenceClient", "DocumentIntelligenceAdministrationClient", ] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_client.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_client.py index 9ecaaa07990bf..3fd4e8d233003 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_client.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_client.py @@ -38,9 +38,8 @@ class DocumentIntelligenceClient(DocumentIntelligenceClientOperationsMixin): AzureKeyCredential type or a TokenCredential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". 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-30". + 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. @@ -122,9 +121,8 @@ class DocumentIntelligenceAdministrationClient(DocumentIntelligenceAdministratio AzureKeyCredential type or a TokenCredential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". 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-30". + 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. diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_configuration.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_configuration.py index 9615be1e277ad..658a80cfa20c5 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_configuration.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_configuration.py @@ -29,16 +29,15 @@ class DocumentIntelligenceClientConfiguration: # pylint: disable=too-many-insta AzureKeyCredential type or a TokenCredential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". 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-30". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-07-31-preview") + api_version: str = kwargs.pop("api_version", "2024-11-30") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -86,16 +85,15 @@ class DocumentIntelligenceAdministrationClientConfiguration: # pylint: disable= AzureKeyCredential type or a TokenCredential type. Required. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". 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-30". + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-07-31-preview") + api_version: str = kwargs.pop("api_version", "2024-11-30") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/__init__.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/__init__.py index 98b551bb5d272..63b6bbb81ed80 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/__init__.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/__init__.py @@ -5,15 +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 DocumentIntelligenceClientOperationsMixin -from ._patch import DocumentIntelligenceAdministrationClientOperationsMixin +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import DocumentIntelligenceClientOperationsMixin # type: ignore +from ._operations import DocumentIntelligenceAdministrationClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "DocumentIntelligenceClientOperationsMixin", "DocumentIntelligenceAdministrationClientOperationsMixin", ] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_operations.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_operations.py index aa9dc521495f7..334e48906413e 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_operations.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_operations.py @@ -32,7 +32,7 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._operations._operations import ( build_document_intelligence_administration_authorize_classifier_copy_request, build_document_intelligence_administration_authorize_model_copy_request, @@ -46,15 +46,19 @@ build_document_intelligence_administration_get_classifier_request, build_document_intelligence_administration_get_model_request, build_document_intelligence_administration_get_operation_request, - build_document_intelligence_administration_get_resource_info_request, + build_document_intelligence_administration_get_resource_details_request, build_document_intelligence_administration_list_classifiers_request, build_document_intelligence_administration_list_models_request, build_document_intelligence_administration_list_operations_request, build_document_intelligence_analyze_batch_documents_request, build_document_intelligence_analyze_document_request, build_document_intelligence_classify_document_request, + build_document_intelligence_delete_analyze_batch_result_request, + build_document_intelligence_delete_analyze_result_request, + build_document_intelligence_get_analyze_batch_result_request, build_document_intelligence_get_analyze_result_figure_request, build_document_intelligence_get_analyze_result_pdf_request, + build_document_intelligence_list_analyze_batch_results_request, ) from .._vendor import DocumentIntelligenceAdministrationClientMixinABC, DocumentIntelligenceClientMixinABC @@ -72,14 +76,14 @@ class DocumentIntelligenceClientOperationsMixin(DocumentIntelligenceClientMixinA async def _analyze_document_initial( self, model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -99,13 +103,10 @@ async def _analyze_document_initial( content_type = content_type or "application/json" _content = None - if isinstance(analyze_request, (IOBase, bytes)): - _content = analyze_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - if analyze_request is not None: - _content = json.dumps(analyze_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_analyze_document_request( model_id=model_id, @@ -140,7 +141,7 @@ async def _analyze_document_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -158,14 +159,14 @@ async def _analyze_document_initial( async def begin_analyze_document( self, model_id: str, - analyze_request: Optional[_models.AnalyzeDocumentRequest] = None, + body: _models.AnalyzeDocumentRequest, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -174,10 +175,9 @@ async def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -194,7 +194,8 @@ async def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -210,14 +211,14 @@ async def begin_analyze_document( async def begin_analyze_document( self, model_id: str, - analyze_request: Optional[JSON] = None, + body: JSON, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -226,10 +227,9 @@ async def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: JSON + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -246,7 +246,8 @@ async def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -262,14 +263,14 @@ async def begin_analyze_document( async def begin_analyze_document( self, model_id: str, - analyze_request: Optional[IO[bytes]] = None, + body: IO[bytes], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -278,10 +279,9 @@ async def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Required. + :type body: IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -298,7 +298,8 @@ async def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -314,14 +315,14 @@ async def begin_analyze_document( async def begin_analyze_document( self, model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.AnalyzeResult]: @@ -329,12 +330,10 @@ async def begin_analyze_document( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_request: Analyze request parameters. Is one of the following types: - AnalyzeDocumentRequest, JSON, IO[bytes] Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or - IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze request parameters. Is one of the following types: AnalyzeDocumentRequest, + JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -351,7 +350,8 @@ async def begin_analyze_document( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :return: An instance of AsyncLROPoller that returns AnalyzeResult. The AnalyzeResult is @@ -370,7 +370,7 @@ async def begin_analyze_document( if cont_token is None: raw_result = await self._analyze_document_initial( model_id=model_id, - analyze_request=analyze_request, + body=body, pages=pages, locale=locale, string_index_type=string_index_type, @@ -424,17 +424,202 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace_async + async def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + """Gets the generated searchable PDF output from document analysis. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_document_intelligence_get_analyze_result_pdf_request( + model_id=model_id, + result_id=result_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_analyze_result_figure( + self, model_id: str, result_id: str, figure_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + """Gets the generated cropped image of specified figure from document analysis. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :param figure_id: Figure ID. Required. + :type figure_id: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_document_intelligence_get_analyze_result_figure_request( + model_id=model_id, + result_id=result_id, + figure_id=figure_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_analyze_result(self, model_id: str, result_id: str, **kwargs: Any) -> None: + """Mark the result of document analysis for deletion. + + :param model_id: Unique document model name. Required. + :type model_id: str + :param result_id: Analyze operation result ID. Required. + :type result_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_document_intelligence_delete_analyze_result_request( + model_id=model_id, + result_id=result_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + async def _analyze_batch_documents_initial( self, model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -454,13 +639,10 @@ async def _analyze_batch_documents_initial( content_type = content_type or "application/json" _content = None - if isinstance(analyze_batch_request, (IOBase, bytes)): - _content = analyze_batch_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - if analyze_batch_request is not None: - _content = json.dumps(analyze_batch_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_analyze_batch_documents_request( model_id=model_id, @@ -495,7 +677,7 @@ async def _analyze_batch_documents_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -513,14 +695,14 @@ async def _analyze_batch_documents_initial( async def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[_models.AnalyzeBatchDocumentsRequest] = None, + body: _models.AnalyzeBatchDocumentsRequest, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -529,10 +711,9 @@ async def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -549,7 +730,8 @@ async def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -566,14 +748,14 @@ async def begin_analyze_batch_documents( async def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[JSON] = None, + body: JSON, *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -582,10 +764,9 @@ async def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: JSON + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -602,7 +783,8 @@ async def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -619,14 +801,14 @@ async def begin_analyze_batch_documents( async def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[IO[bytes]] = None, + body: IO[bytes], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, content_type: str = "application/json", **kwargs: Any @@ -635,10 +817,9 @@ async def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Default value is None. - :type analyze_batch_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Required. + :type body: IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -655,7 +836,8 @@ async def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -672,14 +854,14 @@ async def begin_analyze_batch_documents( async def begin_analyze_batch_documents( self, model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, + body: Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]], *, pages: Optional[str] = None, locale: Optional[str] = None, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, + output_content_format: Optional[Union[str, _models.DocumentContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.AnalyzeBatchResult]: @@ -687,12 +869,11 @@ async def begin_analyze_batch_documents( :param model_id: Unique document model name. Required. :type model_id: str - :param analyze_batch_request: Analyze batch request parameters. Is one of the following types: - AnalyzeBatchDocumentsRequest, JSON, IO[bytes] Default value is None. - :type analyze_batch_request: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest - or JSON or IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :param body: Analyze batch request parameters. Is one of the following types: + AnalyzeBatchDocumentsRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AnalyzeBatchDocumentsRequest or JSON or + IO[bytes] + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword locale: Locale hint for text recognition and document analysis. Value may contain only @@ -709,7 +890,8 @@ async def begin_analyze_batch_documents( :paramtype query_fields: list[str] :keyword output_content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :paramtype output_content_format: str or + ~azure.ai.documentintelligence.models.DocumentContentFormat :keyword output: Additional outputs to generate during analysis. Default value is None. :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] :return: An instance of AsyncLROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult @@ -729,7 +911,7 @@ async def begin_analyze_batch_documents( if cont_token is None: raw_result = await self._analyze_batch_documents_initial( model_id=model_id, - analyze_batch_request=analyze_batch_request, + body=body, pages=pages, locale=locale, string_index_type=string_index_type, @@ -783,16 +965,105 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace + def list_analyze_batch_results( + self, model_id: str, **kwargs: Any + ) -> AsyncIterable["_models.AnalyzeBatchOperation"]: + """List batch document analysis results. + + :param model_id: Unique document model name. Required. + :type model_id: str + :return: An iterator like instance of AnalyzeBatchOperation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.documentintelligence.models.AnalyzeBatchOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AnalyzeBatchOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_document_intelligence_list_analyze_batch_results_request( + model_id=model_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.AnalyzeBatchOperation], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async - async def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: Any) -> AsyncIterator[bytes]: - """Gets the generated searchable PDF output from document analysis. + async def delete_analyze_batch_result(self, model_id: str, result_id: str, **kwargs: Any) -> None: + """Mark the batch document analysis result for deletion. :param model_id: Unique document model name. Required. :type model_id: str - :param result_id: Analyze operation result ID. Required. + :param result_id: Analyze batch operation result ID. Required. :type result_id: str - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -806,9 +1077,9 @@ async def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_document_intelligence_get_analyze_result_pdf_request( + _request = build_document_intelligence_delete_analyze_batch_result_request( model_id=model_id, result_id=result_id, api_version=self._config.api_version, @@ -820,47 +1091,33 @@ async def get_analyze_result_pdf(self, model_id: str, result_id: str, **kwargs: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get_analyze_result_figure( - self, model_id: str, result_id: str, figure_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - """Gets the generated cropped image of specified figure from document analysis. + async def get_analyze_batch_result( + self, model_id: str, result_id: str, **kwargs: Any + ) -> _models.AnalyzeBatchOperation: + """Gets the result of batch document analysis. :param model_id: Unique document model name. Required. :type model_id: str - :param result_id: Analyze operation result ID. Required. + :param result_id: Analyze batch operation result ID. Required. :type result_id: str - :param figure_id: Figure ID. Required. - :type figure_id: str - :return: AsyncIterator[bytes] - :rtype: AsyncIterator[bytes] + :return: AnalyzeBatchOperation. The AnalyzeBatchOperation is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.AnalyzeBatchOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -874,12 +1131,11 @@ async def get_analyze_result_figure( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.AnalyzeBatchOperation] = kwargs.pop("cls", None) - _request = build_document_intelligence_get_analyze_result_figure_request( + _request = build_document_intelligence_get_analyze_batch_result_request( model_id=model_id, result_id=result_id, - figure_id=figure_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -889,7 +1145,7 @@ async def get_analyze_result_figure( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -903,23 +1159,23 @@ async def get_analyze_result_figure( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) - - deserialized = response.iter_bytes() + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.AnalyzeBatchOperation, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore async def _classify_document_initial( self, classifier_id: str, - classify_request: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], + body: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -942,10 +1198,10 @@ async def _classify_document_initial( content_type = content_type or "application/json" _content = None - if isinstance(classify_request, (IOBase, bytes)): - _content = classify_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(classify_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_classify_document_request( classifier_id=classifier_id, @@ -976,7 +1232,7 @@ async def _classify_document_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -994,7 +1250,7 @@ async def _classify_document_initial( async def begin_classify_document( self, classifier_id: str, - classify_request: _models.ClassifyDocumentRequest, + body: _models.ClassifyDocumentRequest, *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1006,16 +1262,15 @@ async def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest + :param body: Classify request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -1030,7 +1285,7 @@ async def begin_classify_document( async def begin_classify_document( self, classifier_id: str, - classify_request: JSON, + body: JSON, *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1042,16 +1297,15 @@ async def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: JSON + :param body: Classify request parameters. Required. + :type body: JSON :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -1066,7 +1320,7 @@ async def begin_classify_document( async def begin_classify_document( self, classifier_id: str, - classify_request: IO[bytes], + body: IO[bytes], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1078,16 +1332,15 @@ async def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Required. - :type classify_request: IO[bytes] + :param body: Classify request parameters. Required. + :type body: IO[bytes] :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1102,7 +1355,7 @@ async def begin_classify_document( async def begin_classify_document( self, classifier_id: str, - classify_request: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], + body: Union[_models.ClassifyDocumentRequest, JSON, IO[bytes]], *, string_index_type: Optional[Union[str, _models.StringIndexType]] = None, split: Optional[Union[str, _models.SplitMode]] = None, @@ -1113,18 +1366,16 @@ async def begin_classify_document( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param classify_request: Classify request parameters. Is one of the following types: + :param body: Classify request parameters. Is one of the following types: ClassifyDocumentRequest, JSON, IO[bytes] Required. - :type classify_request: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest or JSON - or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ClassifyDocumentRequest or JSON or IO[bytes] :keyword string_index_type: Method used to compute string offset and length. Known values are: "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :keyword split: Document splitting mode. Known values are: "auto", "none", and "perPage". Default value is None. :paramtype split: str or ~azure.ai.documentintelligence.models.SplitMode - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. + :keyword pages: 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is None. :paramtype pages: str :return: An instance of AsyncLROPoller that returns AnalyzeResult. The AnalyzeResult is compatible with MutableMapping @@ -1142,7 +1393,7 @@ async def begin_classify_document( if cont_token is None: raw_result = await self._classify_document_initial( classifier_id=classifier_id, - classify_request=classify_request, + body=body, string_index_type=string_index_type, split=split, pages=pages, @@ -1198,7 +1449,7 @@ class DocumentIntelligenceAdministrationClientOperationsMixin( # pylint: disabl ): async def _build_document_model_initial( - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1216,10 +1467,10 @@ async def _build_document_model_initial( content_type = content_type or "application/json" _content = None - if isinstance(build_request, (IOBase, bytes)): - _content = build_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(build_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_build_document_model_request( content_type=content_type, @@ -1246,7 +1497,7 @@ async def _build_document_model_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1262,12 +1513,12 @@ async def _build_document_model_initial( @overload async def begin_build_document_model( - self, build_request: _models.BuildDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any + self, body: _models.BuildDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest + :param body: Build request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1280,12 +1531,12 @@ async def begin_build_document_model( @overload async def begin_build_document_model( - self, build_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: JSON + :param body: Build request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1298,12 +1549,12 @@ async def begin_build_document_model( @overload async def begin_build_document_model( - self, build_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Required. - :type build_request: IO[bytes] + :param body: Build request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1316,13 +1567,13 @@ async def begin_build_document_model( @distributed_trace_async async def begin_build_document_model( - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Builds a custom document analysis model. - :param build_request: Build request parameters. Is one of the following types: + :param body: Build request parameters. Is one of the following types: BuildDocumentModelRequest, JSON, IO[bytes] Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest or JSON or + :type body: ~azure.ai.documentintelligence.models.BuildDocumentModelRequest or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping @@ -1340,12 +1591,7 @@ async def begin_build_document_model( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._build_document_model_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -1388,7 +1634,7 @@ def get_long_running_output(pipeline_response): ) async def _compose_model_initial( - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1406,10 +1652,10 @@ async def _compose_model_initial( content_type = content_type or "application/json" _content = None - if isinstance(compose_request, (IOBase, bytes)): - _content = compose_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(compose_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_compose_model_request( content_type=content_type, @@ -1436,7 +1682,7 @@ async def _compose_model_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1452,16 +1698,12 @@ async def _compose_model_initial( @overload async def begin_compose_model( - self, - compose_request: _models.ComposeDocumentModelRequest, - *, - content_type: str = "application/json", - **kwargs: Any + self, body: _models.ComposeDocumentModelRequest, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest + :param body: Compose request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1474,12 +1716,12 @@ async def begin_compose_model( @overload async def begin_compose_model( - self, compose_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: JSON + :param body: Compose request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1492,12 +1734,12 @@ async def begin_compose_model( @overload async def begin_compose_model( - self, compose_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Required. - :type compose_request: IO[bytes] + :param body: Compose request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1510,14 +1752,14 @@ async def begin_compose_model( @distributed_trace_async async def begin_compose_model( - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Creates a new document model from document types of existing document models. - :param compose_request: Compose request parameters. Is one of the following types: + :param body: Compose request parameters. Is one of the following types: ComposeDocumentModelRequest, JSON, IO[bytes] Required. - :type compose_request: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ComposeDocumentModelRequest or JSON or + IO[bytes] :return: An instance of AsyncLROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping :rtype: @@ -1534,12 +1776,7 @@ async def begin_compose_model( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._compose_model_initial( - compose_request=compose_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -1583,72 +1820,67 @@ def get_long_running_output(pipeline_response): @overload async def authorize_model_copy( - self, - authorize_copy_request: _models.AuthorizeCopyRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: _models.AuthorizeCopyRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest + :param body: Authorize copy request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def authorize_model_copy( - self, authorize_copy_request: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: JSON + :param body: Authorize copy request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def authorize_model_copy( - self, authorize_copy_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: IO[bytes] + :param body: Authorize copy request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def authorize_model_copy( - self, authorize_copy_request: Union[_models.AuthorizeCopyRequest, JSON, IO[bytes]], **kwargs: Any - ) -> _models.CopyAuthorization: + self, body: Union[_models.AuthorizeCopyRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ModelCopyAuthorization: """Generates authorization to copy a document model to this location with specified modelId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Is one of the following - types: AuthorizeCopyRequest, JSON, IO[bytes] Required. - :type authorize_copy_request: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest or - JSON or IO[bytes] - :return: CopyAuthorization. The CopyAuthorization is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.CopyAuthorization + :param body: Authorize copy request parameters. Is one of the following types: + AuthorizeCopyRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeCopyRequest or JSON or IO[bytes] + :return: ModelCopyAuthorization. The ModelCopyAuthorization is compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1663,14 +1895,14 @@ async def authorize_model_copy( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CopyAuthorization] = kwargs.pop("cls", None) + cls: ClsType[_models.ModelCopyAuthorization] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(authorize_copy_request, (IOBase, bytes)): - _content = authorize_copy_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(authorize_copy_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_authorize_model_copy_request( content_type=content_type, @@ -1698,13 +1930,13 @@ async def authorize_model_copy( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.CopyAuthorization, response.json()) + deserialized = _deserialize(_models.ModelCopyAuthorization, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1712,7 +1944,7 @@ async def authorize_model_copy( return deserialized # type: ignore async def _copy_model_to_initial( - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any + self, model_id: str, body: Union[_models.ModelCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1730,10 +1962,10 @@ async def _copy_model_to_initial( content_type = content_type or "application/json" _content = None - if isinstance(copy_to_request, (IOBase, bytes)): - _content = copy_to_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(copy_to_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_copy_model_to_request( model_id=model_id, @@ -1761,7 +1993,7 @@ async def _copy_model_to_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1779,7 +2011,7 @@ async def _copy_model_to_initial( async def begin_copy_model_to( self, model_id: str, - copy_to_request: _models.CopyAuthorization, + body: _models.ModelCopyAuthorization, *, content_type: str = "application/json", **kwargs: Any @@ -1788,8 +2020,8 @@ async def begin_copy_model_to( :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.CopyAuthorization + :param body: Copy to request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ModelCopyAuthorization :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1802,14 +2034,14 @@ async def begin_copy_model_to( @overload async def begin_copy_model_to( - self, model_id: str, copy_to_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, model_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: JSON + :param body: Copy to request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1822,14 +2054,14 @@ async def begin_copy_model_to( @overload async def begin_copy_model_to( - self, model_id: str, copy_to_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, model_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: IO[bytes] + :param body: Copy to request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1842,16 +2074,15 @@ async def begin_copy_model_to( @distributed_trace_async async def begin_copy_model_to( - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any + self, model_id: str, body: Union[_models.ModelCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DocumentModelDetails]: """Copies document model to the target resource, region, and modelId. :param model_id: Unique document model name. Required. :type model_id: str - :param copy_to_request: Copy to request parameters. Is one of the following types: - CopyAuthorization, JSON, IO[bytes] Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.CopyAuthorization or JSON or - IO[bytes] + :param body: Copy to request parameters. Is one of the following types: ModelCopyAuthorization, + JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.ModelCopyAuthorization or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns DocumentModelDetails. The DocumentModelDetails is compatible with MutableMapping :rtype: @@ -1869,7 +2100,7 @@ async def begin_copy_model_to( if cont_token is None: raw_result = await self._copy_model_to_initial( model_id=model_id, - copy_to_request=copy_to_request, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -1964,7 +2195,7 @@ async def get_model(self, model_id: str, **kwargs: Any) -> _models.DocumentModel except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2059,7 +2290,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2109,7 +2340,7 @@ async def delete_model(self, model_id: str, **kwargs: Any) -> None: if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2121,11 +2352,12 @@ async def delete_model(self, model_id: str, **kwargs: Any) -> None: return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async - async def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: + async def get_resource_details(self, **kwargs: Any) -> _models.DocumentIntelligenceResourceDetails: """Return information about the current resource. - :return: ResourceDetails. The ResourceDetails is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.ResourceDetails + :return: DocumentIntelligenceResourceDetails. The DocumentIntelligenceResourceDetails is + compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.DocumentIntelligenceResourceDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2139,9 +2371,9 @@ async def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ResourceDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.DocumentIntelligenceResourceDetails] = kwargs.pop("cls", None) - _request = build_document_intelligence_administration_get_resource_info_request( + _request = build_document_intelligence_administration_get_resource_details_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -2165,13 +2397,13 @@ async def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.ResourceDetails, response.json()) + deserialized = _deserialize(_models.DocumentIntelligenceResourceDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2179,13 +2411,14 @@ async def get_resource_info(self, **kwargs: Any) -> _models.ResourceDetails: return deserialized # type: ignore @distributed_trace_async - async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.OperationDetails: + async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.DocumentIntelligenceOperationDetails: """Gets operation info. :param operation_id: Operation ID. Required. :type operation_id: str - :return: OperationDetails. The OperationDetails is compatible with MutableMapping - :rtype: ~azure.ai.documentintelligence.models.OperationDetails + :return: DocumentIntelligenceOperationDetails. The DocumentIntelligenceOperationDetails is + compatible with MutableMapping + :rtype: ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2199,7 +2432,7 @@ async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.Opera _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.DocumentIntelligenceOperationDetails] = kwargs.pop("cls", None) _request = build_document_intelligence_administration_get_operation_request( operation_id=operation_id, @@ -2226,7 +2459,7 @@ async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.Opera except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2237,7 +2470,7 @@ async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.Opera if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.OperationDetails, response.json()) + deserialized = _deserialize(_models.DocumentIntelligenceOperationDetails, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2245,18 +2478,19 @@ async def get_operation(self, operation_id: str, **kwargs: Any) -> _models.Opera return deserialized # type: ignore @distributed_trace - def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.OperationDetails"]: + def list_operations(self, **kwargs: Any) -> AsyncIterable["_models.DocumentIntelligenceOperationDetails"]: + # pylint: disable=line-too-long """Lists all operations. - :return: An iterator like instance of OperationDetails + :return: An iterator like instance of DocumentIntelligenceOperationDetails :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.ai.documentintelligence.models.OperationDetails] + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.documentintelligence.models.DocumentIntelligenceOperationDetails] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.OperationDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.DocumentIntelligenceOperationDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2305,7 +2539,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OperationDetails], deserialized["value"]) + list_of_elem = _deserialize(List[_models.DocumentIntelligenceOperationDetails], deserialized["value"]) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2321,7 +2555,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -2329,7 +2563,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) async def _build_classifier_initial( - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2347,10 +2581,10 @@ async def _build_classifier_initial( content_type = content_type or "application/json" _content = None - if isinstance(build_request, (IOBase, bytes)): - _content = build_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(build_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_build_classifier_request( content_type=content_type, @@ -2377,7 +2611,7 @@ async def _build_classifier_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2393,16 +2627,12 @@ async def _build_classifier_initial( @overload async def begin_build_classifier( - self, - build_request: _models.BuildDocumentClassifierRequest, - *, - content_type: str = "application/json", - **kwargs: Any + self, body: _models.BuildDocumentClassifierRequest, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest + :param body: Build request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2415,12 +2645,12 @@ async def begin_build_classifier( @overload async def begin_build_classifier( - self, build_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: JSON + :param body: Build request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2433,12 +2663,12 @@ async def begin_build_classifier( @overload async def begin_build_classifier( - self, build_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Required. - :type build_request: IO[bytes] + :param body: Build request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2451,14 +2681,14 @@ async def begin_build_classifier( @distributed_trace_async async def begin_build_classifier( - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Builds a custom document classifier. - :param build_request: Build request parameters. Is one of the following types: + :param body: Build request parameters. Is one of the following types: BuildDocumentClassifierRequest, JSON, IO[bytes] Required. - :type build_request: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.BuildDocumentClassifierRequest or JSON or + IO[bytes] :return: An instance of AsyncLROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping :rtype: @@ -2475,12 +2705,7 @@ async def begin_build_classifier( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._build_classifier_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) @@ -2524,18 +2749,13 @@ def get_long_running_output(pipeline_response): @overload async def authorize_classifier_copy( - self, - authorize_copy_request: _models.AuthorizeClassifierCopyRequest, - *, - content_type: str = "application/json", - **kwargs: Any + self, body: _models.AuthorizeClassifierCopyRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: - ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest + :param body: Authorize copy request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2547,13 +2767,13 @@ async def authorize_classifier_copy( @overload async def authorize_classifier_copy( - self, authorize_copy_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: JSON + :param body: Authorize copy request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2565,13 +2785,13 @@ async def authorize_classifier_copy( @overload async def authorize_classifier_copy( - self, authorize_copy_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Required. - :type authorize_copy_request: IO[bytes] + :param body: Authorize copy request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2583,15 +2803,15 @@ async def authorize_classifier_copy( @distributed_trace_async async def authorize_classifier_copy( - self, authorize_copy_request: Union[_models.AuthorizeClassifierCopyRequest, JSON, IO[bytes]], **kwargs: Any + self, body: Union[_models.AuthorizeClassifierCopyRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.ClassifierCopyAuthorization: """Generates authorization to copy a document classifier to this location with specified classifierId and optional description. - :param authorize_copy_request: Authorize copy request parameters. Is one of the following - types: AuthorizeClassifierCopyRequest, JSON, IO[bytes] Required. - :type authorize_copy_request: - ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest or JSON or IO[bytes] + :param body: Authorize copy request parameters. Is one of the following types: + AuthorizeClassifierCopyRequest, JSON, IO[bytes] Required. + :type body: ~azure.ai.documentintelligence.models.AuthorizeClassifierCopyRequest or JSON or + IO[bytes] :return: ClassifierCopyAuthorization. The ClassifierCopyAuthorization is compatible with MutableMapping :rtype: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization @@ -2613,10 +2833,10 @@ async def authorize_classifier_copy( content_type = content_type or "application/json" _content = None - if isinstance(authorize_copy_request, (IOBase, bytes)): - _content = authorize_copy_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(authorize_copy_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_authorize_classifier_copy_request( content_type=content_type, @@ -2644,7 +2864,7 @@ async def authorize_classifier_copy( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) if _stream: @@ -2658,10 +2878,7 @@ async def authorize_classifier_copy( return deserialized # type: ignore async def _copy_classifier_to_initial( - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any + self, classifier_id: str, body: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2679,10 +2896,10 @@ async def _copy_classifier_to_initial( content_type = content_type or "application/json" _content = None - if isinstance(copy_to_request, (IOBase, bytes)): - _content = copy_to_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(copy_to_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore _request = build_document_intelligence_administration_copy_classifier_to_request( classifier_id=classifier_id, @@ -2710,7 +2927,7 @@ async def _copy_classifier_to_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -2728,7 +2945,7 @@ async def _copy_classifier_to_initial( async def begin_copy_classifier_to( self, classifier_id: str, - copy_to_request: _models.ClassifierCopyAuthorization, + body: _models.ClassifierCopyAuthorization, *, content_type: str = "application/json", **kwargs: Any @@ -2737,8 +2954,8 @@ async def begin_copy_classifier_to( :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization + :param body: Copy to request parameters. Required. + :type body: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2751,14 +2968,14 @@ async def begin_copy_classifier_to( @overload async def begin_copy_classifier_to( - self, classifier_id: str, copy_to_request: JSON, *, content_type: str = "application/json", **kwargs: Any + self, classifier_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: JSON + :param body: Copy to request parameters. Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2771,14 +2988,14 @@ async def begin_copy_classifier_to( @overload async def begin_copy_classifier_to( - self, classifier_id: str, copy_to_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, classifier_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Required. - :type copy_to_request: IO[bytes] + :param body: Copy to request parameters. Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2791,19 +3008,16 @@ async def begin_copy_classifier_to( @distributed_trace_async async def begin_copy_classifier_to( - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any + self, classifier_id: str, body: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: """Copies document classifier to the target resource, region, and classifierId. :param classifier_id: Unique document classifier name. Required. :type classifier_id: str - :param copy_to_request: Copy to request parameters. Is one of the following types: + :param body: Copy to request parameters. Is one of the following types: ClassifierCopyAuthorization, JSON, IO[bytes] Required. - :type copy_to_request: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization or - JSON or IO[bytes] + :type body: ~azure.ai.documentintelligence.models.ClassifierCopyAuthorization or JSON or + IO[bytes] :return: An instance of AsyncLROPoller that returns DocumentClassifierDetails. The DocumentClassifierDetails is compatible with MutableMapping :rtype: @@ -2821,7 +3035,7 @@ async def begin_copy_classifier_to( if cont_token is None: raw_result = await self._copy_classifier_to_initial( classifier_id=classifier_id, - copy_to_request=copy_to_request, + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, @@ -2917,7 +3131,7 @@ async def get_classifier(self, classifier_id: str, **kwargs: Any) -> _models.Doc except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -3012,7 +3226,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) return pipeline_response @@ -3062,7 +3276,7 @@ async def delete_classifier(self, classifier_id: str, **kwargs: Any) -> None: if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.DocumentIntelligenceErrorResponse, response.json()) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_patch.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_patch.py index 3a4d0b5277e7b..f7dd32510333d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_patch.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_patch.py @@ -6,690 +6,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -import sys -from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, Mapping, cast, overload +from typing import List -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict - -from ._operations import ( - DocumentIntelligenceClientOperationsMixin as GeneratedDIClientOps, - DocumentIntelligenceAdministrationClientOperationsMixin as GeneratedDIAdminClientOps, -) -from ... import models as _models -from ..._model_base import _deserialize -from ..._operations._patch import PollingReturnType_co, _parse_operation_id, _finished - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AsyncAnalyzeDocumentLROPoller(AsyncLROPoller[PollingReturnType_co]): - @property - def details(self) -> Mapping[str, Any]: - """Returns metadata associated with the long-running operation. - - :return: Returns metadata associated with the long-running operation. - :rtype: Mapping[str, Any] - """ - return { - "operation_id": _parse_operation_id( - self.polling_method()._initial_response.http_response.headers["Operation-Location"] # type: ignore # pylint: disable=protected-access - ), - } - - @classmethod - def from_continuation_token( - cls, polling_method: AsyncPollingMethod[PollingReturnType_co], continuation_token: str, **kwargs: Any - ) -> "AsyncAnalyzeDocumentLROPoller": - ( - client, - initial_response, - deserialization_callback, - ) = polling_method.from_continuation_token(continuation_token, **kwargs) - - return cls(client, initial_response, deserialization_callback, polling_method) - - -class AsyncAnalyzeBatchDocumentsLROPollingMethod(AsyncLROBasePolling): # pylint: disable=name-too-long - def finished(self) -> bool: - """Is this polling finished? - - :return: Whether the polling finished or not. - :rtype: bool - """ - return _finished(self.status()) - - -class DocumentIntelligenceAdministrationClientOperationsMixin( - GeneratedDIAdminClientOps -): # pylint: disable=name-too-long - @distributed_trace_async - async def begin_build_classifier( # type: ignore[override] - self, build_request: Union[_models.BuildDocumentClassifierRequest, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._build_classifier_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentClassifierDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.DocumentClassifierDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DocumentClassifierDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def begin_build_document_model( # type: ignore[override] - self, build_request: Union[_models.BuildDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._build_document_model_initial( - build_request=build_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def begin_compose_model( # type: ignore[override] - self, compose_request: Union[_models.ComposeDocumentModelRequest, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._compose_model_initial( - compose_request=compose_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def begin_copy_model_to( # type: ignore[override] - self, model_id: str, copy_to_request: Union[_models.CopyAuthorization, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DocumentModelDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentModelDetails] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._copy_model_to_initial( - model_id=model_id, - copy_to_request=copy_to_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentModelDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.DocumentModelDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DocumentModelDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def begin_copy_classifier_to( # type: ignore[override] - self, - classifier_id: str, - copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DocumentClassifierDetails]: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._copy_classifier_to_initial( - classifier_id=classifier_id, - copy_to_request=copy_to_request, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.DocumentClassifierDetails, response.json()) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.DocumentClassifierDetails].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DocumentClassifierDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DocumentIntelligenceClientOperationsMixin(GeneratedDIClientOps): # pylint: disable=name-too-long - @overload - async def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[_models.AnalyzeDocumentRequest] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncAnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is - compatible with MutableMapping - :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[JSON] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: JSON - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncAnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is - compatible with MutableMapping - :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_analyze_document( - self, - model_id: str, - analyze_request: Optional[IO[bytes]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Default value is None. - :type analyze_request: IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncAnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is - compatible with MutableMapping - :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_analyze_document( # type: ignore[override] - self, - model_id: str, - analyze_request: Optional[Union[_models.AnalyzeDocumentRequest, JSON, IO[bytes]]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - **kwargs: Any - ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult]: - """Analyzes document with document model. - - :param model_id: Unique document model name. Required. - :type model_id: str - :param analyze_request: Analyze request parameters. Is one of the following types: - AnalyzeDocumentRequest, JSON, IO[bytes] Default value is None. - :type analyze_request: ~azure.ai.documentintelligence.models.AnalyzeDocumentRequest or JSON or - IO[bytes] - :keyword pages: Range of 1-based page numbers to analyze. Ex. "1-3,5,7-9". Default value is - None. - :paramtype pages: str - :keyword locale: Locale hint for text recognition and document analysis. Value may contain - only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). Default value is - None. - :paramtype locale: str - :keyword string_index_type: Method used to compute string offset and length. Known values are: - "textElements", "unicodeCodePoint", and "utf16CodeUnit". Default value is None. - :paramtype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType - :keyword features: List of optional analysis features. Default value is None. - :paramtype features: list[str or ~azure.ai.documentintelligence.models.DocumentAnalysisFeature] - :keyword query_fields: List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". - Default value is None. - :paramtype query_fields: list[str] - :keyword output_content_format: Format of the analyze result top-level content. Known values - are: "text" and "markdown". Default value is None. - :paramtype output_content_format: str or ~azure.ai.documentintelligence.models.ContentFormat - :keyword output: Additional outputs to generate during analysis. Default value is None. - :paramtype output: list[str or ~azure.ai.documentintelligence.models.AnalyzeOutputOption] - :return: An instance of AsyncAnalyzeDocumentLROPoller that returns AnalyzeResult. The AnalyzeResult is - compatible with MutableMapping - :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("content-type", None)) - cls: ClsType[_models.AnalyzeResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._analyze_document_initial( - model_id=model_id, - analyze_request=analyze_request, - pages=pages, - locale=locale, - string_index_type=string_index_type, - features=features, - query_fields=query_fields, - output_content_format=output_content_format, - output=output, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.AnalyzeResult, response.json().get("analyzeResult")) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncAnalyzeDocumentLROPoller[_models.AnalyzeBatchResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def begin_analyze_batch_documents( # type: ignore[override] - self, - model_id: str, - analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, - *, - pages: Optional[str] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, _models.StringIndexType]] = None, - features: Optional[List[Union[str, _models.DocumentAnalysisFeature]]] = None, - query_fields: Optional[List[str]] = None, - output_content_format: Optional[Union[str, _models.ContentFormat]] = None, - output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.AnalyzeBatchResult]: - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - return await super().begin_analyze_batch_documents( - model_id=model_id, - analyze_batch_request=analyze_batch_request, - pages=pages, - locale=locale, - string_index_type=string_index_type, - features=features, - query_fields=query_fields, - output_content_format=output_content_format, - output=output, - polling=AsyncAnalyzeBatchDocumentsLROPollingMethod(timeout=lro_delay), - **kwargs - ) - - -__all__: List[str] = [ - "DocumentIntelligenceClientOperationsMixin", - "DocumentIntelligenceAdministrationClientOperationsMixin", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_patch.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_patch.py index 821d56fb6891d..f7dd32510333d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_patch.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_patch.py @@ -6,85 +6,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Any, List, Union +from typing import List -from azure.core.credentials import AzureKeyCredential -from azure.core.credentials_async import AsyncTokenCredential - -from ._client import ( - DocumentIntelligenceClient as DIClientGenerated, - DocumentIntelligenceAdministrationClient as DIAClientGenerated, -) -from ..aio._operations._patch import AsyncAnalyzeDocumentLROPoller - - -class DocumentIntelligenceClient(DIClientGenerated): - """DocumentIntelligenceClient. - - :param endpoint: The Document Intelligence service endpoint. Required. - :type endpoint: str - :param credential: Credential needed for the client to connect to Azure. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". Note that overriding this default value may result in unsupported - behavior. - :paramtype api_version: str - """ - - def __init__( - self, - endpoint: str, - credential: Union[AzureKeyCredential, AsyncTokenCredential], - **kwargs: Any, - ) -> None: - # Patch the default polling interval to be 1s. - polling_interval = kwargs.pop("polling_interval", 1) - super().__init__( - endpoint=endpoint, - credential=credential, - polling_interval=polling_interval, - **kwargs, - ) - - -class DocumentIntelligenceAdministrationClient(DIAClientGenerated): - """DocumentIntelligenceAdministrationClient. - - :param endpoint: The Document Intelligence service endpoint. Required. - :type endpoint: str - :param credential: Credential needed for the client to connect to Azure. Is either a - AzureKeyCredential type or a TokenCredential type. Required. - :type credential: ~azure.core.credentials.AzureKeyCredential or - ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2024-07-31-preview". Note that overriding this default value may result in unsupported - behavior. - :paramtype api_version: str - """ - - def __init__( - self, - endpoint: str, - credential: Union[AzureKeyCredential, AsyncTokenCredential], - **kwargs: Any, - ) -> None: - # Patch the default polling interval to be 1s. - polling_interval = kwargs.pop("polling_interval", 1) - super().__init__( - endpoint=endpoint, - credential=credential, - polling_interval=polling_interval, - **kwargs, - ) - - -__all__: List[str] = [ - "DocumentIntelligenceClient", - "DocumentIntelligenceAdministrationClient", - "AsyncAnalyzeDocumentLROPoller", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/__init__.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/__init__.py index 2f7221ee110ab..b1942899448f2 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/__init__.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/__init__.py @@ -5,96 +5,107 @@ # 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 ._models import AddressValue -from ._models import AnalyzeBatchDocumentsRequest -from ._models import AnalyzeBatchOperationDetail -from ._models import AnalyzeBatchResult -from ._models import AnalyzeBatchResultOperation -from ._patch import AnalyzeDocumentRequest -from ._models import AnalyzeResult -from ._models import AnalyzeResultOperation -from ._models import AuthorizeClassifierCopyRequest -from ._models import AuthorizeCopyRequest -from ._models import AzureBlobContentSource -from ._models import AzureBlobFileListContentSource -from ._models import BoundingRegion -from ._models import BuildDocumentClassifierRequest -from ._models import BuildDocumentModelRequest -from ._models import ClassifierCopyAuthorization -from ._models import ClassifierDocumentTypeDetails -from ._patch import ClassifyDocumentRequest -from ._models import ComposeDocumentModelRequest -from ._models import CopyAuthorization -from ._models import CurrencyValue -from ._models import CustomDocumentModelsDetails -from ._models import Document -from ._models import DocumentBarcode -from ._models import DocumentCaption -from ._models import DocumentClassifierBuildOperationDetails -from ._models import DocumentClassifierCopyToOperationDetails -from ._models import DocumentClassifierDetails -from ._models import DocumentField -from ._models import DocumentFieldSchema -from ._models import DocumentFigure -from ._models import DocumentFootnote -from ._models import DocumentFormula -from ._models import DocumentKeyValueElement -from ._models import DocumentKeyValuePair -from ._models import DocumentLanguage -from ._models import DocumentLine -from ._models import DocumentModelBuildOperationDetails -from ._models import DocumentModelComposeOperationDetails -from ._models import DocumentModelCopyToOperationDetails -from ._models import DocumentModelDetails -from ._models import DocumentPage -from ._models import DocumentParagraph -from ._models import DocumentSection -from ._models import DocumentSelectionMark -from ._models import DocumentSpan -from ._models import DocumentStyle -from ._models import DocumentTable -from ._models import DocumentTableCell -from ._models import DocumentTypeDetails -from ._models import DocumentWord -from ._models import Error -from ._models import ErrorResponse -from ._models import InnerError -from ._models import OperationDetails -from ._models import ResourceDetails -from ._models import Warning +from typing import TYPE_CHECKING -from ._enums import AnalyzeOutputOption -from ._enums import ContentFormat -from ._enums import ContentSourceKind -from ._enums import DocumentAnalysisFeature -from ._enums import DocumentBarcodeKind -from ._enums import DocumentBuildMode -from ._enums import DocumentFieldType -from ._enums import DocumentFormulaKind -from ._enums import DocumentSelectionMarkState -from ._enums import DocumentSignatureType -from ._enums import DocumentTableCellKind -from ._enums import FontStyle -from ._enums import FontWeight -from ._enums import LengthUnit -from ._enums import OperationKind -from ._enums import OperationStatus -from ._enums import ParagraphRole -from ._enums import SplitMode -from ._enums import StringIndexType +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._models import ( # type: ignore + AddressValue, + AnalyzeBatchDocumentsRequest, + AnalyzeBatchOperation, + AnalyzeBatchOperationDetail, + AnalyzeBatchResult, + AnalyzeDocumentRequest, + AnalyzeResult, + AnalyzedDocument, + AuthorizeClassifierCopyRequest, + AuthorizeCopyRequest, + AzureBlobContentSource, + AzureBlobFileListContentSource, + BoundingRegion, + BuildDocumentClassifierRequest, + BuildDocumentModelRequest, + ClassifierCopyAuthorization, + ClassifierDocumentTypeDetails, + ClassifyDocumentRequest, + ComposeDocumentModelRequest, + CurrencyValue, + CustomDocumentModelsDetails, + DocumentBarcode, + DocumentCaption, + DocumentClassifierBuildOperationDetails, + DocumentClassifierCopyToOperationDetails, + DocumentClassifierDetails, + DocumentField, + DocumentFieldSchema, + DocumentFigure, + DocumentFootnote, + DocumentFormula, + DocumentIntelligenceError, + DocumentIntelligenceErrorResponse, + DocumentIntelligenceInnerError, + DocumentIntelligenceOperationDetails, + DocumentIntelligenceResourceDetails, + DocumentIntelligenceWarning, + DocumentKeyValueElement, + DocumentKeyValuePair, + DocumentLanguage, + DocumentLine, + DocumentModelBuildOperationDetails, + DocumentModelComposeOperationDetails, + DocumentModelCopyToOperationDetails, + DocumentModelDetails, + DocumentPage, + DocumentParagraph, + DocumentSection, + DocumentSelectionMark, + DocumentSpan, + DocumentStyle, + DocumentTable, + DocumentTableCell, + DocumentTypeDetails, + DocumentWord, + ModelCopyAuthorization, +) + +from ._enums import ( # type: ignore + AnalyzeOutputOption, + ContentSourceKind, + DocumentAnalysisFeature, + DocumentBarcodeKind, + DocumentBuildMode, + DocumentContentFormat, + DocumentFieldType, + DocumentFontStyle, + DocumentFontWeight, + DocumentFormulaKind, + DocumentIntelligenceOperationStatus, + DocumentSelectionMarkState, + DocumentSignatureType, + DocumentTableCellKind, + LengthUnit, + OperationKind, + ParagraphRole, + SplitMode, + StringIndexType, +) +from ._patch import __all__ as _patch_all +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "AddressValue", "AnalyzeBatchDocumentsRequest", + "AnalyzeBatchOperation", "AnalyzeBatchOperationDetail", "AnalyzeBatchResult", - "AnalyzeBatchResultOperation", "AnalyzeDocumentRequest", "AnalyzeResult", - "AnalyzeResultOperation", + "AnalyzedDocument", "AuthorizeClassifierCopyRequest", "AuthorizeCopyRequest", "AzureBlobContentSource", @@ -106,10 +117,8 @@ "ClassifierDocumentTypeDetails", "ClassifyDocumentRequest", "ComposeDocumentModelRequest", - "CopyAuthorization", "CurrencyValue", "CustomDocumentModelsDetails", - "Document", "DocumentBarcode", "DocumentCaption", "DocumentClassifierBuildOperationDetails", @@ -120,6 +129,12 @@ "DocumentFigure", "DocumentFootnote", "DocumentFormula", + "DocumentIntelligenceError", + "DocumentIntelligenceErrorResponse", + "DocumentIntelligenceInnerError", + "DocumentIntelligenceOperationDetails", + "DocumentIntelligenceResourceDetails", + "DocumentIntelligenceWarning", "DocumentKeyValueElement", "DocumentKeyValuePair", "DocumentLanguage", @@ -138,30 +153,26 @@ "DocumentTableCell", "DocumentTypeDetails", "DocumentWord", - "Error", - "ErrorResponse", - "InnerError", - "OperationDetails", - "ResourceDetails", - "Warning", + "ModelCopyAuthorization", "AnalyzeOutputOption", - "ContentFormat", "ContentSourceKind", "DocumentAnalysisFeature", "DocumentBarcodeKind", "DocumentBuildMode", + "DocumentContentFormat", "DocumentFieldType", + "DocumentFontStyle", + "DocumentFontWeight", "DocumentFormulaKind", + "DocumentIntelligenceOperationStatus", "DocumentSelectionMarkState", "DocumentSignatureType", "DocumentTableCellKind", - "FontStyle", - "FontWeight", "LengthUnit", "OperationKind", - "OperationStatus", "ParagraphRole", "SplitMode", "StringIndexType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_enums.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_enums.py index de21b9aa550e1..b9c14c8b13dcf 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_enums.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_enums.py @@ -19,16 +19,6 @@ class AnalyzeOutputOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Generate cropped images of detected figures.""" -class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Format of the content in analyzed result.""" - - TEXT = "text" - """Plain text representation of the document content without any formatting.""" - MARKDOWN = "markdown" - """Markdown representation of the document content with section headings, tables, - etc.""" - - class ContentSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of content source.""" @@ -107,8 +97,16 @@ class DocumentBuildMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Target documents with similar visual templates.""" NEURAL = "neural" """Support documents with diverse visual templates.""" - GENERATIVE = "generative" - """Enable documents of all types using generative AI techniques.""" + + +class DocumentContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Format of the content in analyzed result.""" + + TEXT = "text" + """Plain text representation of the document content without any formatting.""" + MARKDOWN = "markdown" + """Markdown representation of the document content with section headings, tables, + etc.""" class DocumentFieldType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -146,6 +144,24 @@ class DocumentFieldType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Array of selected string values.""" +class DocumentFontStyle(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Font style.""" + + NORMAL = "normal" + """Characters are represented normally.""" + ITALIC = "italic" + """Characters are visually slanted to the right.""" + + +class DocumentFontWeight(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Font weight.""" + + NORMAL = "normal" + """Characters are represented normally.""" + BOLD = "bold" + """Characters are represented with thicker strokes.""" + + class DocumentFormulaKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Formula kind.""" @@ -155,6 +171,23 @@ class DocumentFormulaKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A formula in display mode that takes up an entire line.""" +class DocumentIntelligenceOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operation status.""" + + NOT_STARTED = "notStarted" + """The operation has not started yet.""" + RUNNING = "running" + """The operation is in progress.""" + FAILED = "failed" + """The operation has failed.""" + SUCCEEDED = "succeeded" + """The operation has succeeded.""" + CANCELED = "canceled" + """The operation has been canceled.""" + SKIPPED = "skipped" + """The operation has been skipped.""" + + class DocumentSelectionMarkState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the selection mark.""" @@ -189,24 +222,6 @@ class DocumentTableCellKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the content in (parts of) the table.""" -class FontStyle(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Font style.""" - - NORMAL = "normal" - """Characters are represented normally.""" - ITALIC = "italic" - """Characters are visually slanted to the right.""" - - -class FontWeight(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Font weight.""" - - NORMAL = "normal" - """Characters are represented normally.""" - BOLD = "bold" - """Characters are represented with thicker strokes.""" - - class LengthUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit used by the width, height, and polygon properties. For images, the unit is "pixel". For PDF, the unit is "inch". @@ -235,23 +250,6 @@ class OperationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Build a new custom classifier model.""" -class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operation status.""" - - NOT_STARTED = "notStarted" - """The operation has not started yet.""" - RUNNING = "running" - """The operation is in progress.""" - FAILED = "failed" - """The operation has failed.""" - SUCCEEDED = "succeeded" - """The operation has succeeded.""" - COMPLETED = "completed" - """The operation has completed.""" - CANCELED = "canceled" - """The operation has been canceled.""" - - class ParagraphRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Semantic role of the paragraph.""" diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_models.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_models.py index 95af408671b00..b19eff689606b 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_models.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_models.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation import datetime from typing import Any, Dict, List, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload @@ -18,7 +19,7 @@ from .. import models as _models -class AddressValue(_model_base.Model): # pylint: disable=too-many-instance-attributes +class AddressValue(_model_base.Model): """Address field value. :ivar house_number: House or building number. @@ -111,7 +112,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -170,7 +171,69 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AnalyzeBatchOperation(_model_base.Model): + """Status and result of the analyze batch operation. + + + :ivar result_id: Analyze batch operation result ID. + :vartype result_id: str + :ivar status: Operation status. notStarted, running, succeeded, or failed. Required. Known + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus + :ivar created_date_time: Date and time (UTC) when the operation was submitted. Required. + :vartype created_date_time: ~datetime.datetime + :ivar last_updated_date_time: Date and time (UTC) when the status was last updated. Required. + :vartype last_updated_date_time: ~datetime.datetime + :ivar percent_completed: Operation progress (0-100). + :vartype percent_completed: int + :ivar error: Encountered error during batch document analysis. + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError + :ivar result: Batch document analysis result. + :vartype result: ~azure.ai.documentintelligence.models.AnalyzeBatchResult + """ + + result_id: Optional[str] = rest_field(name="resultId") + """Analyze batch operation result ID.""" + status: Union[str, "_models.DocumentIntelligenceOperationStatus"] = rest_field() + """Operation status. notStarted, running, succeeded, or failed. Required. Known values are: + \"notStarted\", \"running\", \"failed\", \"succeeded\", \"canceled\", and \"skipped\".""" + created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") + """Date and time (UTC) when the operation was submitted. Required.""" + last_updated_date_time: datetime.datetime = rest_field(name="lastUpdatedDateTime", format="rfc3339") + """Date and time (UTC) when the status was last updated. Required.""" + percent_completed: Optional[int] = rest_field(name="percentCompleted") + """Operation progress (0-100).""" + error: Optional["_models.DocumentIntelligenceError"] = rest_field() + """Encountered error during batch document analysis.""" + result: Optional["_models.AnalyzeBatchResult"] = rest_field() + """Batch document analysis result.""" + + @overload + def __init__( + self, + *, + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], + created_date_time: datetime.datetime, + last_updated_date_time: datetime.datetime, + result_id: Optional[str] = None, + percent_completed: Optional[int] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, + result: Optional["_models.AnalyzeBatchResult"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -179,34 +242,35 @@ class AnalyzeBatchOperationDetail(_model_base.Model): :ivar status: Analyze status. succeeded, failed, or skipped. Required. Known values are: - "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar source_url: URL of the source document. Required. :vartype source_url: str :ivar result_url: URL of the analyze result JSON. :vartype result_url: str :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError """ - status: Union[str, "_models.OperationStatus"] = rest_field() + status: Union[str, "_models.DocumentIntelligenceOperationStatus"] = rest_field() """Analyze status. succeeded, failed, or skipped. Required. Known values are: \"notStarted\", - \"running\", \"failed\", \"succeeded\", \"completed\", and \"canceled\".""" + \"running\", \"failed\", \"succeeded\", \"canceled\", and \"skipped\".""" source_url: str = rest_field(name="sourceUrl") """URL of the source document. Required.""" result_url: Optional[str] = rest_field(name="resultUrl") """URL of the analyze result JSON.""" - error: Optional["_models.Error"] = rest_field() + error: Optional["_models.DocumentIntelligenceError"] = rest_field() """Encountered error.""" @overload def __init__( self, *, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], source_url: str, result_url: Optional[str] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, ) -> None: ... @overload @@ -216,7 +280,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -230,7 +294,7 @@ class AnalyzeBatchResult(_model_base.Model): :vartype failed_count: int :ivar skipped_count: Number of documents that completed with status skipped. Required. :vartype skipped_count: int - :ivar details: Operation detail for each document in the batch. Required. + :ivar details: Operation detail for each document in the batch. :vartype details: list[~azure.ai.documentintelligence.models.AnalyzeBatchOperationDetail] """ @@ -240,8 +304,8 @@ class AnalyzeBatchResult(_model_base.Model): """Number of documents that completed with status failed. Required.""" skipped_count: int = rest_field(name="skippedCount") """Number of documents that completed with status skipped. Required.""" - details: List["_models.AnalyzeBatchOperationDetail"] = rest_field() - """Operation detail for each document in the batch. Required.""" + details: Optional[List["_models.AnalyzeBatchOperationDetail"]] = rest_field() + """Operation detail for each document in the batch.""" @overload def __init__( @@ -250,7 +314,7 @@ def __init__( succeeded_count: int, failed_count: int, skipped_count: int, - details: List["_models.AnalyzeBatchOperationDetail"], + details: Optional[List["_models.AnalyzeBatchOperationDetail"]] = None, ) -> None: ... @overload @@ -260,53 +324,46 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AnalyzeBatchResultOperation(_model_base.Model): - """Status and result of the analyze batch operation. +class AnalyzedDocument(_model_base.Model): + """An object describing the location and semantic content of a document. - :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus - :ivar created_date_time: Date and time (UTC) when the operation was submitted. Required. - :vartype created_date_time: ~datetime.datetime - :ivar last_updated_date_time: Date and time (UTC) when the status was last updated. Required. - :vartype last_updated_date_time: ~datetime.datetime - :ivar percent_completed: Operation progress (0-100). - :vartype percent_completed: int - :ivar error: Encountered error during batch document analysis. - :vartype error: ~azure.ai.documentintelligence.models.Error - :ivar result: Batch document analysis result. - :vartype result: ~azure.ai.documentintelligence.models.AnalyzeBatchResult + :ivar doc_type: Document type. Required. + :vartype doc_type: str + :ivar bounding_regions: Bounding regions covering the document. + :vartype bounding_regions: list[~azure.ai.documentintelligence.models.BoundingRegion] + :ivar spans: Location of the document in the reading order concatenated content. Required. + :vartype spans: list[~azure.ai.documentintelligence.models.DocumentSpan] + :ivar fields: Dictionary of named field values. + :vartype fields: dict[str, ~azure.ai.documentintelligence.models.DocumentField] + :ivar confidence: Confidence of correctly extracting the document. Required. + :vartype confidence: float """ - status: Union[str, "_models.OperationStatus"] = rest_field() - """Operation status. notStarted, running, completed, or failed. Required. Known values are: - \"notStarted\", \"running\", \"failed\", \"succeeded\", \"completed\", and \"canceled\".""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") - """Date and time (UTC) when the operation was submitted. Required.""" - last_updated_date_time: datetime.datetime = rest_field(name="lastUpdatedDateTime", format="rfc3339") - """Date and time (UTC) when the status was last updated. Required.""" - percent_completed: Optional[int] = rest_field(name="percentCompleted") - """Operation progress (0-100).""" - error: Optional["_models.Error"] = rest_field() - """Encountered error during batch document analysis.""" - result: Optional["_models.AnalyzeBatchResult"] = rest_field() - """Batch document analysis result.""" + doc_type: str = rest_field(name="docType") + """Document type. Required.""" + bounding_regions: Optional[List["_models.BoundingRegion"]] = rest_field(name="boundingRegions") + """Bounding regions covering the document.""" + spans: List["_models.DocumentSpan"] = rest_field() + """Location of the document in the reading order concatenated content. Required.""" + fields: Optional[Dict[str, "_models.DocumentField"]] = rest_field() + """Dictionary of named field values.""" + confidence: float = rest_field() + """Confidence of correctly extracting the document. Required.""" @overload def __init__( self, *, - status: Union[str, "_models.OperationStatus"], - created_date_time: datetime.datetime, - last_updated_date_time: datetime.datetime, - percent_completed: Optional[int] = None, - error: Optional["_models.Error"] = None, - result: Optional["_models.AnalyzeBatchResult"] = None, + doc_type: str, + spans: List["_models.DocumentSpan"], + confidence: float, + bounding_regions: Optional[List["_models.BoundingRegion"]] = None, + fields: Optional[Dict[str, "_models.DocumentField"]] = None, ) -> None: ... @overload @@ -316,7 +373,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -352,11 +409,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AnalyzeResult(_model_base.Model): # pylint: disable=too-many-instance-attributes +class AnalyzeResult(_model_base.Model): """Document analysis result. @@ -369,7 +426,7 @@ class AnalyzeResult(_model_base.Model): # pylint: disable=too-many-instance-att :vartype string_index_type: str or ~azure.ai.documentintelligence.models.StringIndexType :ivar content_format: Format of the analyze result top-level content. Known values are: "text" and "markdown". - :vartype content_format: str or ~azure.ai.documentintelligence.models.ContentFormat + :vartype content_format: str or ~azure.ai.documentintelligence.models.DocumentContentFormat :ivar content: Concatenate string representation of all textual and visual elements in reading order. Required. :vartype content: str @@ -390,9 +447,9 @@ class AnalyzeResult(_model_base.Model): # pylint: disable=too-many-instance-att :ivar languages: Detected languages. :vartype languages: list[~azure.ai.documentintelligence.models.DocumentLanguage] :ivar documents: Extracted documents. - :vartype documents: list[~azure.ai.documentintelligence.models.Document] + :vartype documents: list[~azure.ai.documentintelligence.models.AnalyzedDocument] :ivar warnings: List of warnings encountered. - :vartype warnings: list[~azure.ai.documentintelligence.models.Warning] + :vartype warnings: list[~azure.ai.documentintelligence.models.DocumentIntelligenceWarning] """ api_version: str = rest_field(name="apiVersion") @@ -402,7 +459,7 @@ class AnalyzeResult(_model_base.Model): # pylint: disable=too-many-instance-att string_index_type: Union[str, "_models.StringIndexType"] = rest_field(name="stringIndexType") """Method used to compute string offset and length. Required. Known values are: \"textElements\", \"unicodeCodePoint\", and \"utf16CodeUnit\".""" - content_format: Optional[Union[str, "_models.ContentFormat"]] = rest_field(name="contentFormat") + content_format: Optional[Union[str, "_models.DocumentContentFormat"]] = rest_field(name="contentFormat") """Format of the analyze result top-level content. Known values are: \"text\" and \"markdown\".""" content: str = rest_field() """Concatenate string representation of all textual and visual elements in reading @@ -423,9 +480,9 @@ class AnalyzeResult(_model_base.Model): # pylint: disable=too-many-instance-att """Extracted font styles.""" languages: Optional[List["_models.DocumentLanguage"]] = rest_field() """Detected languages.""" - documents: Optional[List["_models.Document"]] = rest_field() + documents: Optional[List["_models.AnalyzedDocument"]] = rest_field() """Extracted documents.""" - warnings: Optional[List["_models.Warning"]] = rest_field() + warnings: Optional[List["_models.DocumentIntelligenceWarning"]] = rest_field() """List of warnings encountered.""" @overload @@ -437,7 +494,7 @@ def __init__( string_index_type: Union[str, "_models.StringIndexType"], content: str, pages: List["_models.DocumentPage"], - content_format: Optional[Union[str, "_models.ContentFormat"]] = None, + content_format: Optional[Union[str, "_models.DocumentContentFormat"]] = None, paragraphs: Optional[List["_models.DocumentParagraph"]] = None, tables: Optional[List["_models.DocumentTable"]] = None, figures: Optional[List["_models.DocumentFigure"]] = None, @@ -445,60 +502,8 @@ def __init__( key_value_pairs: Optional[List["_models.DocumentKeyValuePair"]] = None, styles: Optional[List["_models.DocumentStyle"]] = None, languages: Optional[List["_models.DocumentLanguage"]] = None, - documents: Optional[List["_models.Document"]] = None, - warnings: Optional[List["_models.Warning"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class AnalyzeResultOperation(_model_base.Model): - """Status and result of the analyze operation. - - - :ivar status: Operation status. notStarted, running, succeeded, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus - :ivar created_date_time: Date and time (UTC) when the analyze operation was submitted. - Required. - :vartype created_date_time: ~datetime.datetime - :ivar last_updated_date_time: Date and time (UTC) when the status was last updated. Required. - :vartype last_updated_date_time: ~datetime.datetime - :ivar error: Encountered error during document analysis. - :vartype error: ~azure.ai.documentintelligence.models.Error - :ivar analyze_result: Document analysis result. - :vartype analyze_result: ~azure.ai.documentintelligence.models.AnalyzeResult - """ - - status: Union[str, "_models.OperationStatus"] = rest_field() - """Operation status. notStarted, running, succeeded, or failed. Required. Known values are: - \"notStarted\", \"running\", \"failed\", \"succeeded\", \"completed\", and \"canceled\".""" - created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") - """Date and time (UTC) when the analyze operation was submitted. Required.""" - last_updated_date_time: datetime.datetime = rest_field(name="lastUpdatedDateTime", format="rfc3339") - """Date and time (UTC) when the status was last updated. Required.""" - error: Optional["_models.Error"] = rest_field() - """Encountered error during document analysis.""" - analyze_result: Optional["_models.AnalyzeResult"] = rest_field(name="analyzeResult") - """Document analysis result.""" - - @overload - def __init__( - self, - *, - status: Union[str, "_models.OperationStatus"], - created_date_time: datetime.datetime, - last_updated_date_time: datetime.datetime, - error: Optional["_models.Error"] = None, - analyze_result: Optional["_models.AnalyzeResult"] = None, + documents: Optional[List["_models.AnalyzedDocument"]] = None, + warnings: Optional[List["_models.DocumentIntelligenceWarning"]] = None, ) -> None: ... @overload @@ -508,7 +513,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -548,7 +553,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -588,7 +593,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -622,7 +627,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -657,7 +662,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -697,7 +702,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -748,7 +753,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -761,8 +766,8 @@ class BuildDocumentModelRequest(_model_base.Model): :vartype model_id: str :ivar description: Document model description. :vartype description: str - :ivar build_mode: Custom document model build mode. Required. Known values are: "template", - "neural", and "generative". + :ivar build_mode: Custom document model build mode. Required. Known values are: "template" and + "neural". :vartype build_mode: str or ~azure.ai.documentintelligence.models.DocumentBuildMode :ivar azure_blob_source: Azure Blob Storage location containing the training data. Either azureBlobSource or azureBlobFileListSource must be specified. @@ -786,8 +791,7 @@ class BuildDocumentModelRequest(_model_base.Model): description: Optional[str] = rest_field() """Document model description.""" build_mode: Union[str, "_models.DocumentBuildMode"] = rest_field(name="buildMode") - """Custom document model build mode. Required. Known values are: \"template\", \"neural\", and - \"generative\".""" + """Custom document model build mode. Required. Known values are: \"template\" and \"neural\".""" azure_blob_source: Optional["_models.AzureBlobContentSource"] = rest_field(name="azureBlobSource") """Azure Blob Storage location containing the training data. Either azureBlobSource or azureBlobFileListSource must be specified.""" @@ -824,7 +828,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -884,7 +888,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -937,7 +941,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -974,7 +978,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1030,66 +1034,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class CopyAuthorization(_model_base.Model): - """Authorization to copy a document model to the specified target resource and - modelId. - - - :ivar target_resource_id: ID of the target Azure resource where the document model should be - copied to. Required. - :vartype target_resource_id: str - :ivar target_resource_region: Location of the target Azure resource where the document model - should be copied - to. Required. - :vartype target_resource_region: str - :ivar target_model_id: Identifier of the target document model. Required. - :vartype target_model_id: str - :ivar target_model_location: URL of the copied document model in the target account. Required. - :vartype target_model_location: str - :ivar access_token: Token used to authorize the request. Required. - :vartype access_token: str - :ivar expiration_date_time: Date/time when the access token expires. Required. - :vartype expiration_date_time: ~datetime.datetime - """ - - target_resource_id: str = rest_field(name="targetResourceId") - """ID of the target Azure resource where the document model should be copied to. Required.""" - target_resource_region: str = rest_field(name="targetResourceRegion") - """Location of the target Azure resource where the document model should be copied - to. Required.""" - target_model_id: str = rest_field(name="targetModelId") - """Identifier of the target document model. Required.""" - target_model_location: str = rest_field(name="targetModelLocation") - """URL of the copied document model in the target account. Required.""" - access_token: str = rest_field(name="accessToken") - """Token used to authorize the request. Required.""" - expiration_date_time: datetime.datetime = rest_field(name="expirationDateTime", format="rfc3339") - """Date/time when the access token expires. Required.""" - - @overload - def __init__( - self, - *, - target_resource_id: str, - target_resource_region: str, - target_model_id: str, - target_model_location: str, - access_token: str, - expiration_date_time: datetime.datetime, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1128,7 +1073,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1163,56 +1108,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class Document(_model_base.Model): - """An object describing the location and semantic content of a document. - - - :ivar doc_type: Document type. Required. - :vartype doc_type: str - :ivar bounding_regions: Bounding regions covering the document. - :vartype bounding_regions: list[~azure.ai.documentintelligence.models.BoundingRegion] - :ivar spans: Location of the document in the reading order concatenated content. Required. - :vartype spans: list[~azure.ai.documentintelligence.models.DocumentSpan] - :ivar fields: Dictionary of named field values. - :vartype fields: dict[str, ~azure.ai.documentintelligence.models.DocumentField] - :ivar confidence: Confidence of correctly extracting the document. Required. - :vartype confidence: float - """ - - doc_type: str = rest_field(name="docType") - """Document type. Required.""" - bounding_regions: Optional[List["_models.BoundingRegion"]] = rest_field(name="boundingRegions") - """Bounding regions covering the document.""" - spans: List["_models.DocumentSpan"] = rest_field() - """Location of the document in the reading order concatenated content. Required.""" - fields: Optional[Dict[str, "_models.DocumentField"]] = rest_field() - """Dictionary of named field values.""" - confidence: float = rest_field() - """Confidence of correctly extracting the document. Required.""" - - @overload - def __init__( - self, - *, - doc_type: str, - spans: List["_models.DocumentSpan"], - confidence: float, - bounding_regions: Optional[List["_models.BoundingRegion"]] = None, - fields: Optional[Dict[str, "_models.DocumentField"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1271,7 +1167,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1315,11 +1211,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OperationDetails(_model_base.Model): +class DocumentIntelligenceOperationDetails(_model_base.Model): """Operation info. You probably want to use the sub-classes and not this class directly. Known sub-classes are: @@ -1331,8 +1227,9 @@ class OperationDetails(_model_base.Model): :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -1350,15 +1247,15 @@ class OperationDetails(_model_base.Model): :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError """ __mapping__: Dict[str, _model_base.Model] = {} operation_id: str = rest_field(name="operationId", visibility=["read", "create"]) """Operation ID. Required.""" - status: Union[str, "_models.OperationStatus"] = rest_field() + status: Union[str, "_models.DocumentIntelligenceOperationStatus"] = rest_field() """Operation status. notStarted, running, completed, or failed. Required. Known values are: - \"notStarted\", \"running\", \"failed\", \"succeeded\", \"completed\", and \"canceled\".""" + \"notStarted\", \"running\", \"failed\", \"succeeded\", \"canceled\", and \"skipped\".""" percent_completed: Optional[int] = rest_field(name="percentCompleted") """Operation progress (0-100).""" created_date_time: datetime.datetime = rest_field(name="createdDateTime", format="rfc3339") @@ -1375,7 +1272,7 @@ class OperationDetails(_model_base.Model): """API version used to create this operation.""" tags: Optional[Dict[str, str]] = rest_field() """List of key-value tag attributes associated with the document model.""" - error: Optional["_models.Error"] = rest_field() + error: Optional["_models.DocumentIntelligenceError"] = rest_field() """Encountered error.""" @overload @@ -1383,7 +1280,7 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, kind: str, @@ -1391,7 +1288,7 @@ def __init__( percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, ) -> None: ... @overload @@ -1401,21 +1298,22 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) class DocumentClassifierBuildOperationDetails( - OperationDetails, discriminator="documentClassifierBuild" -): # pylint: disable=too-many-instance-attributes + DocumentIntelligenceOperationDetails, discriminator="documentClassifierBuild" +): """Get Operation response object. :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -1429,7 +1327,7 @@ class DocumentClassifierBuildOperationDetails( :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError :ivar result: Operation result upon success. :vartype result: ~azure.ai.documentintelligence.models.DocumentClassifierDetails :ivar kind: Type of operation. Required. Build a new custom classifier model. @@ -1446,14 +1344,14 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, resource_location: str, percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, result: Optional["_models.DocumentClassifierDetails"] = None, ) -> None: ... @@ -1464,21 +1362,22 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=OperationKind.DOCUMENT_CLASSIFIER_BUILD, **kwargs) class DocumentClassifierCopyToOperationDetails( - OperationDetails, discriminator="documentClassifierCopyTo" -): # pylint: disable=too-many-instance-attributes + DocumentIntelligenceOperationDetails, discriminator="documentClassifierCopyTo" +): """Get Operation response object. :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -1492,7 +1391,7 @@ class DocumentClassifierCopyToOperationDetails( :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError :ivar result: Operation result upon success. :vartype result: ~azure.ai.documentintelligence.models.DocumentClassifierDetails :ivar kind: Type of operation. Required. Copy an existing document classifier to potentially a @@ -1513,14 +1412,14 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, resource_location: str, percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, result: Optional["_models.DocumentClassifierDetails"] = None, ) -> None: ... @@ -1531,13 +1430,15 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=OperationKind.DOCUMENT_CLASSIFIER_COPY_TO, **kwargs) class DocumentClassifierDetails(_model_base.Model): """Document classifier info. + Readonly variables are only populated by the server, and will be ignored when sending a request. + :ivar classifier_id: Unique document classifier name. Required. :vartype classifier_id: str @@ -1548,6 +1449,8 @@ class DocumentClassifierDetails(_model_base.Model): :vartype created_date_time: ~datetime.datetime :ivar expiration_date_time: Date and time (UTC) when the document classifier will expire. :vartype expiration_date_time: ~datetime.datetime + :ivar modified_date_time: Date and time (UTC) when the document model was last modified. + :vartype modified_date_time: ~datetime.datetime :ivar api_version: API version used to create this document classifier. Required. :vartype api_version: str :ivar base_classifier_id: Base classifierId on top of which the classifier was trained. @@ -1556,7 +1459,7 @@ class DocumentClassifierDetails(_model_base.Model): :vartype doc_types: dict[str, ~azure.ai.documentintelligence.models.ClassifierDocumentTypeDetails] :ivar warnings: List of warnings encountered while building the classifier. - :vartype warnings: list[~azure.ai.documentintelligence.models.Warning] + :vartype warnings: list[~azure.ai.documentintelligence.models.DocumentIntelligenceWarning] """ classifier_id: str = rest_field(name="classifierId", visibility=["read", "create"]) @@ -1567,13 +1470,17 @@ class DocumentClassifierDetails(_model_base.Model): """Date and time (UTC) when the document classifier was created. Required.""" expiration_date_time: Optional[datetime.datetime] = rest_field(name="expirationDateTime", format="rfc3339") """Date and time (UTC) when the document classifier will expire.""" + modified_date_time: Optional[datetime.datetime] = rest_field( + name="modifiedDateTime", visibility=["read"], format="rfc3339" + ) + """Date and time (UTC) when the document model was last modified.""" api_version: str = rest_field(name="apiVersion") """API version used to create this document classifier. Required.""" base_classifier_id: Optional[str] = rest_field(name="baseClassifierId") """Base classifierId on top of which the classifier was trained.""" doc_types: Dict[str, "_models.ClassifierDocumentTypeDetails"] = rest_field(name="docTypes") """List of document types to classify against. Required.""" - warnings: Optional[List["_models.Warning"]] = rest_field() + warnings: Optional[List["_models.DocumentIntelligenceWarning"]] = rest_field() """List of warnings encountered while building the classifier.""" @overload @@ -1587,7 +1494,7 @@ def __init__( description: Optional[str] = None, expiration_date_time: Optional[datetime.datetime] = None, base_classifier_id: Optional[str] = None, - warnings: Optional[List["_models.Warning"]] = None, + warnings: Optional[List["_models.DocumentIntelligenceWarning"]] = None, ) -> None: ... @overload @@ -1597,11 +1504,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DocumentField(_model_base.Model): # pylint: disable=too-many-instance-attributes +class DocumentField(_model_base.Model): """An object representing the content and location of a field value. @@ -1729,7 +1636,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1745,8 +1652,8 @@ class DocumentFieldSchema(_model_base.Model): :vartype description: str :ivar example: Example field content. :vartype example: str - :ivar items_property: Field type schema of each array element. - :vartype items_property: ~azure.ai.documentintelligence.models.DocumentFieldSchema + :ivar items_schema: Field type schema of each array element. + :vartype items_schema: ~azure.ai.documentintelligence.models.DocumentFieldSchema :ivar properties: Named sub-fields of the object field. :vartype properties: dict[str, ~azure.ai.documentintelligence.models.DocumentFieldSchema] """ @@ -1760,7 +1667,7 @@ class DocumentFieldSchema(_model_base.Model): """Field description.""" example: Optional[str] = rest_field() """Example field content.""" - items_property: Optional["_models.DocumentFieldSchema"] = rest_field(name="items") + items_schema: Optional["_models.DocumentFieldSchema"] = rest_field(name="items") """Field type schema of each array element.""" properties: Optional[Dict[str, "_models.DocumentFieldSchema"]] = rest_field() """Named sub-fields of the object field.""" @@ -1772,7 +1679,7 @@ def __init__( type: Union[str, "_models.DocumentFieldType"], description: Optional[str] = None, example: Optional[str] = None, - items_property: Optional["_models.DocumentFieldSchema"] = None, + items_schema: Optional["_models.DocumentFieldSchema"] = None, properties: Optional[Dict[str, "_models.DocumentFieldSchema"]] = None, ) -> None: ... @@ -1783,7 +1690,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1837,7 +1744,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1881,7 +1788,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1936,24 +1843,211 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DocumentKeyValueElement(_model_base.Model): - """An object representing the field key or value in a key-value pair. +class DocumentIntelligenceError(_model_base.Model): + """The error object. - :ivar content: Concatenated content of the key-value element in reading order. Required. - :vartype content: str - :ivar bounding_regions: Bounding regions covering the key-value element. - :vartype bounding_regions: list[~azure.ai.documentintelligence.models.BoundingRegion] - :ivar spans: Location of the key-value element in the reading order concatenated content. - Required. - :vartype spans: list[~azure.ai.documentintelligence.models.DocumentSpan] + :ivar code: One of a server-defined set of error codes. Required. + :vartype code: str + :ivar message: A human-readable representation of the error. Required. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: An array of details about specific errors that led to this reported error. + :vartype details: list[~azure.ai.documentintelligence.models.DocumentIntelligenceError] + :ivar innererror: An object containing more specific information than the current object about + the error. + :vartype innererror: ~azure.ai.documentintelligence.models.DocumentIntelligenceInnerError """ - content: str = rest_field() + code: str = rest_field() + """One of a server-defined set of error codes. Required.""" + message: str = rest_field() + """A human-readable representation of the error. Required.""" + target: Optional[str] = rest_field() + """The target of the error.""" + details: Optional[List["_models.DocumentIntelligenceError"]] = rest_field() + """An array of details about specific errors that led to this reported error.""" + innererror: Optional["_models.DocumentIntelligenceInnerError"] = rest_field() + """An object containing more specific information than the current object about the error.""" + + @overload + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + details: Optional[List["_models.DocumentIntelligenceError"]] = None, + innererror: Optional["_models.DocumentIntelligenceInnerError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentIntelligenceErrorResponse(_model_base.Model): + """Error response object. + + All required parameters must be populated in order to send to server. + + :ivar error: Error info. Required. + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError + """ + + error: "_models.DocumentIntelligenceError" = rest_field() + """Error info. Required.""" + + @overload + def __init__( + self, + *, + error: "_models.DocumentIntelligenceError", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentIntelligenceInnerError(_model_base.Model): + """An object containing more specific information about the error. + + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar innererror: Inner error. + :vartype innererror: ~azure.ai.documentintelligence.models.DocumentIntelligenceInnerError + """ + + code: Optional[str] = rest_field() + """One of a server-defined set of error codes.""" + message: Optional[str] = rest_field() + """A human-readable representation of the error.""" + innererror: Optional["_models.DocumentIntelligenceInnerError"] = rest_field() + """Inner error.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + innererror: Optional["_models.DocumentIntelligenceInnerError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentIntelligenceResourceDetails(_model_base.Model): + """General information regarding the current resource. + + + :ivar custom_document_models: Details regarding custom document models. Required. + :vartype custom_document_models: + ~azure.ai.documentintelligence.models.CustomDocumentModelsDetails + """ + + custom_document_models: "_models.CustomDocumentModelsDetails" = rest_field(name="customDocumentModels") + """Details regarding custom document models. Required.""" + + @overload + def __init__( + self, + *, + custom_document_models: "_models.CustomDocumentModelsDetails", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentIntelligenceWarning(_model_base.Model): + """The error object. + + + :ivar code: One of a server-defined set of warning codes. Required. + :vartype code: str + :ivar message: A human-readable representation of the warning. Required. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + """ + + code: str = rest_field() + """One of a server-defined set of warning codes. Required.""" + message: str = rest_field() + """A human-readable representation of the warning. Required.""" + target: Optional[str] = rest_field() + """The target of the error.""" + + @overload + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentKeyValueElement(_model_base.Model): + """An object representing the field key or value in a key-value pair. + + + :ivar content: Concatenated content of the key-value element in reading order. Required. + :vartype content: str + :ivar bounding_regions: Bounding regions covering the key-value element. + :vartype bounding_regions: list[~azure.ai.documentintelligence.models.BoundingRegion] + :ivar spans: Location of the key-value element in the reading order concatenated content. + Required. + :vartype spans: list[~azure.ai.documentintelligence.models.DocumentSpan] + """ + + content: str = rest_field() """Concatenated content of the key-value element in reading order. Required.""" bounding_regions: Optional[List["_models.BoundingRegion"]] = rest_field(name="boundingRegions") """Bounding regions covering the key-value element.""" @@ -1976,7 +2070,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2016,7 +2110,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2059,7 +2153,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2105,21 +2199,20 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DocumentModelBuildOperationDetails( - OperationDetails, discriminator="documentModelBuild" -): # pylint: disable=too-many-instance-attributes +class DocumentModelBuildOperationDetails(DocumentIntelligenceOperationDetails, discriminator="documentModelBuild"): """Get Operation response object. :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -2133,7 +2226,7 @@ class DocumentModelBuildOperationDetails( :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError :ivar result: Operation result upon success. :vartype result: ~azure.ai.documentintelligence.models.DocumentModelDetails :ivar kind: Type of operation. Required. Build a new custom document model. @@ -2150,14 +2243,14 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, resource_location: str, percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, result: Optional["_models.DocumentModelDetails"] = None, ) -> None: ... @@ -2168,21 +2261,20 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=OperationKind.DOCUMENT_MODEL_BUILD, **kwargs) -class DocumentModelComposeOperationDetails( - OperationDetails, discriminator="documentModelCompose" -): # pylint: disable=too-many-instance-attributes +class DocumentModelComposeOperationDetails(DocumentIntelligenceOperationDetails, discriminator="documentModelCompose"): """Get Operation response object. :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -2196,7 +2288,7 @@ class DocumentModelComposeOperationDetails( :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError :ivar result: Operation result upon success. :vartype result: ~azure.ai.documentintelligence.models.DocumentModelDetails :ivar kind: Type of operation. Required. Compose a new custom document model from existing @@ -2214,14 +2306,14 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, resource_location: str, percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, result: Optional["_models.DocumentModelDetails"] = None, ) -> None: ... @@ -2232,21 +2324,20 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=OperationKind.DOCUMENT_MODEL_COMPOSE, **kwargs) -class DocumentModelCopyToOperationDetails( - OperationDetails, discriminator="documentModelCopyTo" -): # pylint: disable=too-many-instance-attributes +class DocumentModelCopyToOperationDetails(DocumentIntelligenceOperationDetails, discriminator="documentModelCopyTo"): """Get Operation response object. :ivar operation_id: Operation ID. Required. :vartype operation_id: str :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". - :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". + :vartype status: str or + ~azure.ai.documentintelligence.models.DocumentIntelligenceOperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int :ivar created_date_time: Date and time (UTC) when the operation was created. Required. @@ -2260,7 +2351,7 @@ class DocumentModelCopyToOperationDetails( :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] :ivar error: Encountered error. - :vartype error: ~azure.ai.documentintelligence.models.Error + :vartype error: ~azure.ai.documentintelligence.models.DocumentIntelligenceError :ivar result: Operation result upon success. :vartype result: ~azure.ai.documentintelligence.models.DocumentModelDetails :ivar kind: Type of operation. Required. Copy an existing document model to potentially a @@ -2281,14 +2372,14 @@ def __init__( self, *, operation_id: str, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.DocumentIntelligenceOperationStatus"], created_date_time: datetime.datetime, last_updated_date_time: datetime.datetime, resource_location: str, percent_completed: Optional[int] = None, api_version: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.DocumentIntelligenceError"] = None, result: Optional["_models.DocumentModelDetails"] = None, ) -> None: ... @@ -2299,11 +2390,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=OperationKind.DOCUMENT_MODEL_COPY_TO, **kwargs) -class DocumentModelDetails(_model_base.Model): # pylint: disable=too-many-instance-attributes +class DocumentModelDetails(_model_base.Model): """Document model info. Readonly variables are only populated by the server, and will be ignored when sending a request. @@ -2317,12 +2408,13 @@ class DocumentModelDetails(_model_base.Model): # pylint: disable=too-many-insta :vartype created_date_time: ~datetime.datetime :ivar expiration_date_time: Date and time (UTC) when the document model will expire. :vartype expiration_date_time: ~datetime.datetime + :ivar modified_date_time: Date and time (UTC) when the document model was last modified. + :vartype modified_date_time: ~datetime.datetime :ivar api_version: API version used to create this document model. :vartype api_version: str :ivar tags: List of key-value tag attributes associated with the document model. :vartype tags: dict[str, str] - :ivar build_mode: Custom document model build mode. Known values are: "template", "neural", and - "generative". + :ivar build_mode: Custom document model build mode. Known values are: "template" and "neural". :vartype build_mode: str or ~azure.ai.documentintelligence.models.DocumentBuildMode :ivar azure_blob_source: Azure Blob Storage location containing the training data. Either azureBlobSource or azureBlobFileListSource must be specified. @@ -2341,7 +2433,7 @@ class DocumentModelDetails(_model_base.Model): # pylint: disable=too-many-insta :ivar doc_types: Supported document types. :vartype doc_types: dict[str, ~azure.ai.documentintelligence.models.DocumentTypeDetails] :ivar warnings: List of warnings encountered while building the model. - :vartype warnings: list[~azure.ai.documentintelligence.models.Warning] + :vartype warnings: list[~azure.ai.documentintelligence.models.DocumentIntelligenceWarning] :ivar training_hours: Number of V100-equivalent GPU hours consumed for model training. :vartype training_hours: float """ @@ -2356,13 +2448,16 @@ class DocumentModelDetails(_model_base.Model): # pylint: disable=too-many-insta name="expirationDateTime", visibility=["read"], format="rfc3339" ) """Date and time (UTC) when the document model will expire.""" + modified_date_time: Optional[datetime.datetime] = rest_field( + name="modifiedDateTime", visibility=["read"], format="rfc3339" + ) + """Date and time (UTC) when the document model was last modified.""" api_version: Optional[str] = rest_field(name="apiVersion", visibility=["read"]) """API version used to create this document model.""" tags: Optional[Dict[str, str]] = rest_field() """List of key-value tag attributes associated with the document model.""" build_mode: Optional[Union[str, "_models.DocumentBuildMode"]] = rest_field(name="buildMode", visibility=["read"]) - """Custom document model build mode. Known values are: \"template\", \"neural\", and - \"generative\".""" + """Custom document model build mode. Known values are: \"template\" and \"neural\".""" azure_blob_source: Optional["_models.AzureBlobContentSource"] = rest_field( name="azureBlobSource", visibility=["read"] ) @@ -2380,7 +2475,7 @@ class DocumentModelDetails(_model_base.Model): # pylint: disable=too-many-insta \"perPage\".""" doc_types: Optional[Dict[str, "_models.DocumentTypeDetails"]] = rest_field(name="docTypes", visibility=["read"]) """Supported document types.""" - warnings: Optional[List["_models.Warning"]] = rest_field(visibility=["read"]) + warnings: Optional[List["_models.DocumentIntelligenceWarning"]] = rest_field(visibility=["read"]) """List of warnings encountered while building the model.""" training_hours: Optional[float] = rest_field(name="trainingHours", visibility=["read"]) """Number of V100-equivalent GPU hours consumed for model training.""" @@ -2403,11 +2498,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DocumentPage(_model_base.Model): # pylint: disable=too-many-instance-attributes +class DocumentPage(_model_base.Model): """Content and layout elements extracted from a page from the input. @@ -2488,7 +2583,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2535,7 +2630,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2569,7 +2664,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2621,7 +2716,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2656,7 +2751,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2671,9 +2766,9 @@ class DocumentStyle(_model_base.Model): fallback fonts following CSS convention (ex. 'Arial, sans-serif'). :vartype similar_font_family: str :ivar font_style: Font style. Known values are: "normal" and "italic". - :vartype font_style: str or ~azure.ai.documentintelligence.models.FontStyle + :vartype font_style: str or ~azure.ai.documentintelligence.models.DocumentFontStyle :ivar font_weight: Font weight. Known values are: "normal" and "bold". - :vartype font_weight: str or ~azure.ai.documentintelligence.models.FontWeight + :vartype font_weight: str or ~azure.ai.documentintelligence.models.DocumentFontWeight :ivar color: Foreground color in #rrggbb hexadecimal format. :vartype color: str :ivar background_color: Background color in #rrggbb hexadecimal format.. @@ -2690,9 +2785,9 @@ class DocumentStyle(_model_base.Model): similar_font_family: Optional[str] = rest_field(name="similarFontFamily") """Visually most similar font from among the set of supported font families, with fallback fonts following CSS convention (ex. 'Arial, sans-serif').""" - font_style: Optional[Union[str, "_models.FontStyle"]] = rest_field(name="fontStyle") + font_style: Optional[Union[str, "_models.DocumentFontStyle"]] = rest_field(name="fontStyle") """Font style. Known values are: \"normal\" and \"italic\".""" - font_weight: Optional[Union[str, "_models.FontWeight"]] = rest_field(name="fontWeight") + font_weight: Optional[Union[str, "_models.DocumentFontWeight"]] = rest_field(name="fontWeight") """Font weight. Known values are: \"normal\" and \"bold\".""" color: Optional[str] = rest_field() """Foreground color in #rrggbb hexadecimal format.""" @@ -2711,8 +2806,8 @@ def __init__( confidence: float, is_handwritten: Optional[bool] = None, similar_font_family: Optional[str] = None, - font_style: Optional[Union[str, "_models.FontStyle"]] = None, - font_weight: Optional[Union[str, "_models.FontWeight"]] = None, + font_style: Optional[Union[str, "_models.DocumentFontStyle"]] = None, + font_weight: Optional[Union[str, "_models.DocumentFontWeight"]] = None, color: Optional[str] = None, background_color: Optional[str] = None, ) -> None: ... @@ -2724,7 +2819,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2783,7 +2878,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2854,7 +2949,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2863,8 +2958,7 @@ class DocumentTypeDetails(_model_base.Model): :ivar description: Document model description. :vartype description: str - :ivar build_mode: Custom document model build mode. Known values are: "template", "neural", and - "generative". + :ivar build_mode: Custom document model build mode. Known values are: "template" and "neural". :vartype build_mode: str or ~azure.ai.documentintelligence.models.DocumentBuildMode :ivar field_schema: Description of the document semantic schema using a JSON Schema style syntax. @@ -2887,8 +2981,7 @@ class DocumentTypeDetails(_model_base.Model): description: Optional[str] = rest_field() """Document model description.""" build_mode: Optional[Union[str, "_models.DocumentBuildMode"]] = rest_field(name="buildMode") - """Custom document model build mode. Known values are: \"template\", \"neural\", and - \"generative\".""" + """Custom document model build mode. Known values are: \"template\" and \"neural\".""" field_schema: Optional[Dict[str, "_models.DocumentFieldSchema"]] = rest_field(name="fieldSchema") """Description of the document semantic schema using a JSON Schema style syntax.""" field_confidence: Optional[Dict[str, float]] = rest_field(name="fieldConfidence") @@ -2926,7 +3019,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2978,183 +3071,56 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Error(_model_base.Model): - """The error object. - - - :ivar code: One of a server-defined set of error codes. Required. - :vartype code: str - :ivar message: A human-readable representation of the error. Required. - :vartype message: str - :ivar target: The target of the error. - :vartype target: str - :ivar details: An array of details about specific errors that led to this reported error. - :vartype details: list[~azure.ai.documentintelligence.models.Error] - :ivar innererror: An object containing more specific information than the current object about - the error. - :vartype innererror: ~azure.ai.documentintelligence.models.InnerError - """ - - code: str = rest_field() - """One of a server-defined set of error codes. Required.""" - message: str = rest_field() - """A human-readable representation of the error. Required.""" - target: Optional[str] = rest_field() - """The target of the error.""" - details: Optional[List["_models.Error"]] = rest_field() - """An array of details about specific errors that led to this reported error.""" - innererror: Optional["_models.InnerError"] = rest_field() - """An object containing more specific information than the current object about the error.""" - - @overload - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - details: Optional[List["_models.Error"]] = None, - innererror: Optional["_models.InnerError"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class ErrorResponse(_model_base.Model): - """Error response object. - - - :ivar error: Error info. Required. - :vartype error: ~azure.ai.documentintelligence.models.Error - """ - - error: "_models.Error" = rest_field() - """Error info. Required.""" - - @overload - def __init__( - self, - *, - error: "_models.Error", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class InnerError(_model_base.Model): - """An object containing more specific information about the error. - - :ivar code: One of a server-defined set of error codes. - :vartype code: str - :ivar message: A human-readable representation of the error. - :vartype message: str - :ivar innererror: Inner error. - :vartype innererror: ~azure.ai.documentintelligence.models.InnerError - """ - - code: Optional[str] = rest_field() - """One of a server-defined set of error codes.""" - message: Optional[str] = rest_field() - """A human-readable representation of the error.""" - innererror: Optional["_models.InnerError"] = rest_field() - """Inner error.""" - - @overload - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - innererror: Optional["_models.InnerError"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class ResourceDetails(_model_base.Model): - """General information regarding the current resource. - - - :ivar custom_document_models: Details regarding custom document models. Required. - :vartype custom_document_models: - ~azure.ai.documentintelligence.models.CustomDocumentModelsDetails - """ - - custom_document_models: "_models.CustomDocumentModelsDetails" = rest_field(name="customDocumentModels") - """Details regarding custom document models. Required.""" - - @overload - def __init__( - self, - *, - custom_document_models: "_models.CustomDocumentModelsDetails", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class Warning(_model_base.Model): - """The error object. +class ModelCopyAuthorization(_model_base.Model): + """Authorization to copy a document model to the specified target resource and + modelId. - :ivar code: One of a server-defined set of warning codes. Required. - :vartype code: str - :ivar message: A human-readable representation of the warning. Required. - :vartype message: str - :ivar target: The target of the error. - :vartype target: str + :ivar target_resource_id: ID of the target Azure resource where the document model should be + copied to. Required. + :vartype target_resource_id: str + :ivar target_resource_region: Location of the target Azure resource where the document model + should be copied + to. Required. + :vartype target_resource_region: str + :ivar target_model_id: Identifier of the target document model. Required. + :vartype target_model_id: str + :ivar target_model_location: URL of the copied document model in the target account. Required. + :vartype target_model_location: str + :ivar access_token: Token used to authorize the request. Required. + :vartype access_token: str + :ivar expiration_date_time: Date/time when the access token expires. Required. + :vartype expiration_date_time: ~datetime.datetime """ - code: str = rest_field() - """One of a server-defined set of warning codes. Required.""" - message: str = rest_field() - """A human-readable representation of the warning. Required.""" - target: Optional[str] = rest_field() - """The target of the error.""" + target_resource_id: str = rest_field(name="targetResourceId") + """ID of the target Azure resource where the document model should be copied to. Required.""" + target_resource_region: str = rest_field(name="targetResourceRegion") + """Location of the target Azure resource where the document model should be copied + to. Required.""" + target_model_id: str = rest_field(name="targetModelId") + """Identifier of the target document model. Required.""" + target_model_location: str = rest_field(name="targetModelLocation") + """URL of the copied document model in the target account. Required.""" + access_token: str = rest_field(name="accessToken") + """Token used to authorize the request. Required.""" + expiration_date_time: datetime.datetime = rest_field(name="expirationDateTime", format="rfc3339") + """Date/time when the access token expires. Required.""" @overload def __init__( self, *, - code: str, - message: str, - target: Optional[str] = None, + target_resource_id: str, + target_resource_region: str, + target_model_id: str, + target_model_location: str, + access_token: str, + expiration_date_time: datetime.datetime, ) -> None: ... @overload @@ -3164,5 +3130,5 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: :type mapping: Mapping[str, Any] """ - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_patch.py b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_patch.py index c385980aebd50..f7dd32510333d 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_patch.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/models/_patch.py @@ -6,45 +6,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List, Optional -from ._models import ( - AnalyzeDocumentRequest as GeneratedAnalyzeDocumentRequest, - ClassifyDocumentRequest as GeneratedClassifyDocumentRequest, -) -from .._model_base import rest_field +from typing import List - -class AnalyzeDocumentRequest(GeneratedAnalyzeDocumentRequest): - """Document analysis parameters. - - :ivar url_source: Document URL to analyze. Either url_source or bytes_source must be specified. - :vartype url_source: str - :ivar bytes_source: Document bytes to analyze. Either url_source or bytes_source must be specified. - :vartype bytes_source: bytes - """ - - bytes_source: Optional[bytes] = rest_field(name="base64Source", format="base64") - """Document bytes to analyze. Either url_source or bytes_source must be specified.""" - - -class ClassifyDocumentRequest(GeneratedClassifyDocumentRequest): - """Document classification parameters. - - :ivar url_source: Document URL to classify. Either url_source or bytes_source must be - specified. - :vartype url_source: str - :ivar bytes_source: Document bytes to classify. Either url_source or bytes_source must be specified. - :vartype bytes_source: bytes - """ - - bytes_source: Optional[bytes] = rest_field(name="base64Source", format="base64") - """Document bytes to classify. Either url_source or bytes_source must be specified.""" - - -__all__: List[str] = [ - "AnalyzeDocumentRequest", - "ClassifyDocumentRequest", -] # Add all objects you want publicly available to users at this package level +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_batch_documents_result.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_batch_documents_result.py new file mode 100644 index 0000000000000..e6cc5eeb045a5 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_batch_documents_result.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python delete_analyze_batch_documents_result.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + client.delete_analyze_batch_result( + model_id="prebuilt-invoice", + result_id="3b31320d-8bab-4f88-b19c-2322a7f11034", + ) + + +# x-ms-original-file: 2024-11-30/DeleteAnalyzeBatchDocumentsResult.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_document_result.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_document_result.py new file mode 100644 index 0000000000000..a52452fbe3242 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_analyze_document_result.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python delete_analyze_document_result.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + client.delete_analyze_result( + model_id="myCustomModel", + result_id="3b31320d-8bab-4f88-b19c-2322a7f11034", + ) + + +# x-ms-original-file: 2024-11-30/DeleteAnalyzeDocumentResult.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_classifier.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_classifier.py new file mode 100644 index 0000000000000..9e5e32890f4dd --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_classifier.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python delete_document_classifier.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + client.delete_classifier( + classifier_id="myClassifier", + ) + + +# x-ms-original-file: 2024-11-30/DeleteDocumentClassifier.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_model.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_model.py new file mode 100644 index 0000000000000..87c28058fbbd5 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/delete_document_model.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python delete_document_model.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + client.delete_model( + model_id="myCustomModel", + ) + + +# x-ms-original-file: 2024-11-30/DeleteDocumentModel.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_result.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_result.py new file mode 100644 index 0000000000000..7be38a8f67d49 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_result.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_analyze_batch_documents_result.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_analyze_batch_result( + model_id="prebuilt-invoice", + result_id="3b31320d-8bab-4f88-b19c-2322a7f11034", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetAnalyzeBatchDocumentsResult.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_results.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_results.py new file mode 100644 index 0000000000000..cd25ea958178d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_batch_documents_results.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_analyze_batch_documents_results.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.list_analyze_batch_results( + model_id="prebuilt-invoice", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-11-30/GetAnalyzeBatchDocumentsResults.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_figure.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_figure.py new file mode 100644 index 0000000000000..d8d3868c3b21a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_figure.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_analyze_document_result_figure.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_analyze_result_figure( + model_id="prebuilt-invoice", + result_id="3b31320d-8bab-4f88-b19c-2322a7f11034", + figure_id="1.0", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetAnalyzeDocumentResultFigure.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_fpdf.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_fpdf.py new file mode 100644 index 0000000000000..6a88b0888e07b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_analyze_document_result_fpdf.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_analyze_document_result_fpdf.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_analyze_result_pdf( + model_id="prebuilt-invoice", + result_id="3b31320d-8bab-4f88-b19c-2322a7f11034", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetAnalyzeDocumentResultFPdf.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifier.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifier.py new file mode 100644 index 0000000000000..76c5b95742260 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifier.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_document_classifier.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_classifier( + classifier_id="myClassifier", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetDocumentClassifier.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifiers.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifiers.py new file mode 100644 index 0000000000000..a02085b9c0bad --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_classifiers.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_document_classifiers.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.list_classifiers() + for item in response: + print(item) + + +# x-ms-original-file: 2024-11-30/GetDocumentClassifiers.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_custom.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_custom.py new file mode 100644 index 0000000000000..d12fae573bf97 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_custom.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_document_model_custom.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_model( + model_id="myCustomModel", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetDocumentModel_Custom.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_prebuilt.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_prebuilt.py new file mode 100644 index 0000000000000..c96ac2ee5c46a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_model_prebuilt.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_document_model_prebuilt.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_model( + model_id="prebuilt-invoice", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetDocumentModel_Prebuilt.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_models.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_models.py new file mode 100644 index 0000000000000..fdaeb7f783385 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_document_models.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_document_models.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.list_models() + for item in response: + print(item) + + +# x-ms-original-file: 2024-11-30/GetDocumentModels.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operation.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operation.py new file mode 100644 index 0000000000000..ca6341e11ef72 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operation.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_operation.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_operation( + operation_id="b704bb00-d130-4f3f-a1d8-ca96de3eabb4", + ) + print(response) + + +# x-ms-original-file: 2024-11-30/GetOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operations.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operations.py new file mode 100644 index 0000000000000..0b7758a41a6bd --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_operations.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.list_operations() + for item in response: + print(item) + + +# x-ms-original-file: 2024-11-30/GetOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_resource_details.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_resource_details.py new file mode 100644 index 0000000000000..ea49a684e457f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_samples/get_resource_details.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.ai.documentintelligence import DocumentIntelligenceClient + +""" +# PREREQUISITES + pip install azure-ai-documentintelligence +# USAGE + python get_resource_details.py +""" + + +def main(): + client = DocumentIntelligenceClient( + endpoint="https://myendpoint.cognitiveservices.azure.com", + credential="CREDENTIAL", + ) + + response = client.get_resource_details() + print(response) + + +# x-ms-original-file: 2024-11-30/GetResourceDetails.json +if __name__ == "__main__": + main() diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/conftest.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/conftest.py new file mode 100644 index 0000000000000..d647c5afe1fcc --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/conftest.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + documentintelligence_subscription_id = os.environ.get( + "DOCUMENTINTELLIGENCE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligence_tenant_id = os.environ.get( + "DOCUMENTINTELLIGENCE_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligence_client_id = os.environ.get( + "DOCUMENTINTELLIGENCE_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligence_client_secret = os.environ.get( + "DOCUMENTINTELLIGENCE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=documentintelligence_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=documentintelligence_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=documentintelligence_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=documentintelligence_client_secret, value="00000000-0000-0000-0000-000000000000") + + documentintelligenceadministration_subscription_id = os.environ.get( + "DOCUMENTINTELLIGENCEADMINISTRATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligenceadministration_tenant_id = os.environ.get( + "DOCUMENTINTELLIGENCEADMINISTRATION_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligenceadministration_client_id = os.environ.get( + "DOCUMENTINTELLIGENCEADMINISTRATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + documentintelligenceadministration_client_secret = os.environ.get( + "DOCUMENTINTELLIGENCEADMINISTRATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=documentintelligenceadministration_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=documentintelligenceadministration_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=documentintelligenceadministration_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=documentintelligenceadministration_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence.py new file mode 100644 index 0000000000000..bafbd67767a55 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import DocumentIntelligenceClientTestBase, DocumentIntelligencePreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDocumentIntelligence(DocumentIntelligenceClientTestBase): + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_begin_analyze_document(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.begin_analyze_document( + model_id="str", + body={"base64Source": bytes("bytes", encoding="utf-8"), "urlSource": "str"}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_get_analyze_result_pdf(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.get_analyze_result_pdf( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_get_analyze_result_figure(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.get_analyze_result_figure( + model_id="str", + result_id="str", + figure_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_delete_analyze_result(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.delete_analyze_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_begin_analyze_batch_documents(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.begin_analyze_batch_documents( + model_id="str", + body={ + "resultContainerUrl": "str", + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "overwriteExisting": bool, + "resultPrefix": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_list_analyze_batch_results(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.list_analyze_batch_results( + model_id="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_delete_analyze_batch_result(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.delete_analyze_batch_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_get_analyze_batch_result(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.get_analyze_batch_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy + def test_begin_classify_document(self, documentintelligence_endpoint): + client = self.create_client(endpoint=documentintelligence_endpoint) + response = client.begin_classify_document( + classifier_id="str", + body={"base64Source": bytes("bytes", encoding="utf-8"), "urlSource": "str"}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration.py new file mode 100644 index 0000000000000..e1e2126bb6b61 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration.py @@ -0,0 +1,245 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import DocumentIntelligenceAdministrationClientTestBase, DocumentIntelligenceAdministrationPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDocumentIntelligenceAdministration(DocumentIntelligenceAdministrationClientTestBase): + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_begin_build_document_model(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.begin_build_document_model( + body={ + "buildMode": "str", + "modelId": "str", + "allowOverwrite": bool, + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "description": "str", + "maxTrainingHours": 0.0, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_begin_compose_model(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.begin_compose_model( + body={ + "classifierId": "str", + "docTypes": { + "str": { + "buildMode": "str", + "confidenceThreshold": 0.0, + "description": "str", + "features": ["str"], + "fieldConfidence": {"str": 0.0}, + "fieldSchema": { + "str": { + "type": "str", + "description": "str", + "example": "str", + "items": ..., + "properties": {"str": ...}, + } + }, + "maxDocumentsToAnalyze": 0, + "modelId": "str", + "queryFields": ["str"], + } + }, + "modelId": "str", + "description": "str", + "split": "str", + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_authorize_model_copy(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.authorize_model_copy( + body={"modelId": "str", "description": "str", "tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_begin_copy_model_to(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.begin_copy_model_to( + model_id="str", + body={ + "accessToken": "str", + "expirationDateTime": "2020-02-20 00:00:00", + "targetModelId": "str", + "targetModelLocation": "str", + "targetResourceId": "str", + "targetResourceRegion": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_get_model(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.get_model( + model_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_list_models(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_models() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_delete_model(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.delete_model( + model_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_get_resource_details(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.get_resource_details() + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_get_operation(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.get_operation( + operation_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_list_operations(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_operations() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_begin_build_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.begin_build_classifier( + body={ + "classifierId": "str", + "docTypes": { + "str": { + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "sourceKind": "str", + } + }, + "allowOverwrite": bool, + "baseClassifierId": "str", + "description": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_authorize_classifier_copy(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.authorize_classifier_copy( + body={"classifierId": "str", "description": "str", "tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_begin_copy_classifier_to(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.begin_copy_classifier_to( + classifier_id="str", + body={ + "accessToken": "str", + "expirationDateTime": "2020-02-20 00:00:00", + "targetClassifierId": "str", + "targetClassifierLocation": "str", + "targetResourceId": "str", + "targetResourceRegion": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_get_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.get_classifier( + classifier_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_list_classifiers(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_classifiers() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy + def test_delete_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_client(endpoint=documentintelligenceadministration_endpoint) + response = client.delete_classifier( + classifier_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration_async.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration_async.py new file mode 100644 index 0000000000000..1522ffe7c182c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_administration_async.py @@ -0,0 +1,256 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import DocumentIntelligenceAdministrationPreparer +from testpreparer_async import DocumentIntelligenceAdministrationClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDocumentIntelligenceAdministrationAsync(DocumentIntelligenceAdministrationClientTestBaseAsync): + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_begin_build_document_model(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await ( + await client.begin_build_document_model( + body={ + "buildMode": "str", + "modelId": "str", + "allowOverwrite": bool, + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "description": "str", + "maxTrainingHours": 0.0, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_begin_compose_model(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await ( + await client.begin_compose_model( + body={ + "classifierId": "str", + "docTypes": { + "str": { + "buildMode": "str", + "confidenceThreshold": 0.0, + "description": "str", + "features": ["str"], + "fieldConfidence": {"str": 0.0}, + "fieldSchema": { + "str": { + "type": "str", + "description": "str", + "example": "str", + "items": ..., + "properties": {"str": ...}, + } + }, + "maxDocumentsToAnalyze": 0, + "modelId": "str", + "queryFields": ["str"], + } + }, + "modelId": "str", + "description": "str", + "split": "str", + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_authorize_model_copy(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.authorize_model_copy( + body={"modelId": "str", "description": "str", "tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_begin_copy_model_to(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await ( + await client.begin_copy_model_to( + model_id="str", + body={ + "accessToken": "str", + "expirationDateTime": "2020-02-20 00:00:00", + "targetModelId": "str", + "targetModelLocation": "str", + "targetResourceId": "str", + "targetResourceRegion": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_model(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.get_model( + model_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_models(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_models() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_delete_model(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.delete_model( + model_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_resource_details(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.get_resource_details() + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_operation(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.get_operation( + operation_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_operations(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_operations() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_begin_build_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await ( + await client.begin_build_classifier( + body={ + "classifierId": "str", + "docTypes": { + "str": { + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "sourceKind": "str", + } + }, + "allowOverwrite": bool, + "baseClassifierId": "str", + "description": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_authorize_classifier_copy(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.authorize_classifier_copy( + body={"classifierId": "str", "description": "str", "tags": {"str": "str"}}, + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_begin_copy_classifier_to(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await ( + await client.begin_copy_classifier_to( + classifier_id="str", + body={ + "accessToken": "str", + "expirationDateTime": "2020-02-20 00:00:00", + "targetClassifierId": "str", + "targetClassifierLocation": "str", + "targetResourceId": "str", + "targetResourceRegion": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.get_classifier( + classifier_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_classifiers(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = client.list_classifiers() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligenceAdministrationPreparer() + @recorded_by_proxy_async + async def test_delete_classifier(self, documentintelligenceadministration_endpoint): + client = self.create_async_client(endpoint=documentintelligenceadministration_endpoint) + response = await client.delete_classifier( + classifier_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_async.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_async.py new file mode 100644 index 0000000000000..8f826ada97636 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/test_document_intelligence_async.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import DocumentIntelligencePreparer +from testpreparer_async import DocumentIntelligenceClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDocumentIntelligenceAsync(DocumentIntelligenceClientTestBaseAsync): + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_begin_analyze_document(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await ( + await client.begin_analyze_document( + model_id="str", + body={"base64Source": bytes("bytes", encoding="utf-8"), "urlSource": "str"}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_get_analyze_result_pdf(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await client.get_analyze_result_pdf( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_get_analyze_result_figure(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await client.get_analyze_result_figure( + model_id="str", + result_id="str", + figure_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_delete_analyze_result(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await client.delete_analyze_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_begin_analyze_batch_documents(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await ( + await client.begin_analyze_batch_documents( + model_id="str", + body={ + "resultContainerUrl": "str", + "azureBlobFileListSource": {"containerUrl": "str", "fileList": "str"}, + "azureBlobSource": {"containerUrl": "str", "prefix": "str"}, + "overwriteExisting": bool, + "resultPrefix": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_list_analyze_batch_results(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = client.list_analyze_batch_results( + model_id="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_delete_analyze_batch_result(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await client.delete_analyze_batch_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_get_analyze_batch_result(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await client.get_analyze_batch_result( + model_id="str", + result_id="str", + ) + + # please add some check logic here by yourself + # ... + + @DocumentIntelligencePreparer() + @recorded_by_proxy_async + async def test_begin_classify_document(self, documentintelligence_endpoint): + client = self.create_async_client(endpoint=documentintelligence_endpoint) + response = await ( + await client.begin_classify_document( + classifier_id="str", + body={"base64Source": bytes("bytes", encoding="utf-8"), "urlSource": "str"}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer.py new file mode 100644 index 0000000000000..ed3b18488bf5d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from azure.ai.documentintelligence import DocumentIntelligenceAdministrationClient, DocumentIntelligenceClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class DocumentIntelligenceClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(DocumentIntelligenceClient) + return self.create_client_from_credential( + DocumentIntelligenceClient, + credential=credential, + endpoint=endpoint, + ) + + +DocumentIntelligencePreparer = functools.partial( + PowerShellPreparer, + "documentintelligence", + documentintelligence_endpoint="https://fake_documentintelligence_endpoint.com", +) + + +class DocumentIntelligenceAdministrationClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(DocumentIntelligenceAdministrationClient) + return self.create_client_from_credential( + DocumentIntelligenceAdministrationClient, + credential=credential, + endpoint=endpoint, + ) + + +DocumentIntelligenceAdministrationPreparer = functools.partial( + PowerShellPreparer, + "documentintelligenceadministration", + documentintelligenceadministration_endpoint="https://fake_documentintelligenceadministration_endpoint.com", +) diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer_async.py b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer_async.py new file mode 100644 index 0000000000000..fece6c220e812 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/generated_tests/testpreparer_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from azure.ai.documentintelligence.aio import DocumentIntelligenceAdministrationClient, DocumentIntelligenceClient +from devtools_testutils import AzureRecordedTestCase + + +class DocumentIntelligenceClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(DocumentIntelligenceClient, is_async=True) + return self.create_client_from_credential( + DocumentIntelligenceClient, + credential=credential, + endpoint=endpoint, + ) + + +class DocumentIntelligenceAdministrationClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(DocumentIntelligenceAdministrationClient, is_async=True) + return self.create_client_from_credential( + DocumentIntelligenceAdministrationClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/sdk_packaging.toml b/sdk/documentintelligence/azure-ai-documentintelligence/sdk_packaging.toml new file mode 100644 index 0000000000000..e7687fdae93bc --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/sdk_packaging.toml @@ -0,0 +1,2 @@ +[packaging] +auto_update = false \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/setup.py b/sdk/documentintelligence/azure-ai-documentintelligence/setup.py index 2eddf25a28820..efc94a2193752 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/setup.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/setup.py @@ -38,7 +38,7 @@ url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", keywords="azure, azure sdk", classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml b/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml index 18b1c4b0e7f44..d53a49cb26250 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml +++ b/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/DocumentIntelligence -commit: ec2a81edaecf3970e5938936e8256759905163e6 -additionalDirectories: [] +commit: dd0459d5a8d99b8a15dcbc33fd5b7befe5494897 repo: Azure/azure-rest-api-specs +additionalDirectories: