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 5d62b4bb7381..c474f6a4267e 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 a90c19d86ac2..a0fc5dce5b25 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 2a0cd7b02089..791799f9cf28 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 9d401b0cf012..e6a2730f9276 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]: 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 98b551bb5d27..63b6bbb81ed8 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 4e00f61ddfd2..7c18acd91101 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 @@ -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, *, @@ -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 @@ -426,7 +533,7 @@ def build_document_intelligence_administration_get_resource_info_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 @@ -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 @@ -747,7 +854,7 @@ def begin_analyze_document( :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 + :keyword pages: List 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 @@ -799,7 +906,7 @@ def begin_analyze_document( :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 + :keyword pages: List 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 @@ -851,7 +958,7 @@ def begin_analyze_document( :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 + :keyword pages: List 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 @@ -904,7 +1011,7 @@ def begin_analyze_document( 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 + :keyword pages: List 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 @@ -994,6 +1101,193 @@ 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 = _deserialize(_models.ErrorResponse, 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 = _deserialize(_models.ErrorResponse, 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 = _deserialize(_models.ErrorResponse, 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, @@ -1101,7 +1395,7 @@ def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -1153,7 +1447,7 @@ def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -1205,7 +1499,7 @@ def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -1258,7 +1552,7 @@ def begin_analyze_batch_documents( 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 + :keyword pages: List 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 @@ -1349,15 +1643,106 @@ 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.AnalyzeBatchResultOperation"]: + """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 AnalyzeBatchResultOperation + :rtype: + ~azure.core.paging.ItemPaged[~azure.ai.documentintelligence.models.AnalyzeBatchResultOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AnalyzeBatchResultOperation]] = 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.AnalyzeBatchResultOperation], 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 = _deserialize(_models.ErrorResponse, 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 +1756,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 +1770,34 @@ 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()) 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.AnalyzeBatchResultOperation: + """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: AnalyzeBatchResultOperation. The AnalyzeBatchResultOperation is compatible with + MutableMapping + :rtype: ~azure.ai.documentintelligence.models.AnalyzeBatchResultOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1439,12 +1811,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.AnalyzeBatchResultOperation] = 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 +1825,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 ) @@ -1471,13 +1842,13 @@ def get_analyze_result_figure( error = _deserialize(_models.ErrorResponse, 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.AnalyzeBatchResultOperation, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @@ -1579,7 +1950,7 @@ def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1615,7 +1986,7 @@ def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1651,7 +2022,7 @@ def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1688,7 +2059,7 @@ def begin_classify_document( :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 + :keyword pages: List of 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 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 bec6b5ae77c5..570dfd5039f5 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 @@ -32,7 +32,6 @@ 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): @@ -40,12 +39,6 @@ def _parse_operation_id(operation_location_header): 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]: @@ -73,16 +66,6 @@ def from_continuation_token( 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 @@ -598,6 +581,162 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @overload + def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_request: Optional[_models.AnalyzeBatchDocumentsRequest] = 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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult is + compatible with MutableMapping + :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult is + compatible with MutableMapping + :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult is + compatible with MutableMapping + :rtype: AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def begin_analyze_batch_documents( self, @@ -612,22 +751,120 @@ def begin_analyze_batch_documents( output_content_format: Optional[Union[str, _models.ContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any, - ) -> LROPoller[_models.AnalyzeBatchResult]: + ) -> AnalyzeDocumentLROPoller[_models.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult is + compatible with MutableMapping + :rtype:AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :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.AnalyzeBatchResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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, + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._analyze_batch_documents_initial( + 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, + 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.AnalyzeBatchResult, response.json().get("result")) + 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.AnalyzeBatchResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AnalyzeDocumentLROPoller[_models.AnalyzeBatchResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace + async def get_batch_analyze_result( + self, continuation_token: str + ) -> AnalyzeDocumentLROPoller[_models.AnalyzeBatchResult]: + """Gets the result of batch document analysis. + + :param continuation_token: An opaque continuation token. Required. + :type model_id: str + :return: An instance of AnalyzeDocumentLROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult is + compatible with MutableMapping + :rtype:AnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + return self.begin_analyze_batch_documents(None, None, continuation_token=continuation_token) + __all__: List[str] = [ "DocumentIntelligenceClientOperationsMixin", 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 480e941d758f..ce17d1798ce7 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. @@ -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: 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 d42be0aa8a75..02790b905f25 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 9ecaaa07990b..3fd4e8d23300 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 9615be1e277a..658a80cfa20c 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 98b551bb5d27..63b6bbb81ed8 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 aa9dc521495f..0d33061735bb 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 @@ -53,8 +53,12 @@ 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 @@ -176,7 +180,7 @@ async def begin_analyze_document( :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 + :keyword pages: List 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 @@ -228,7 +232,7 @@ async def begin_analyze_document( :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 + :keyword pages: List 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 @@ -280,7 +284,7 @@ async def begin_analyze_document( :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 + :keyword pages: List 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 @@ -333,7 +337,7 @@ async def begin_analyze_document( 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 + :keyword pages: List 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 @@ -424,6 +428,191 @@ 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 = _deserialize(_models.ErrorResponse, 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 = _deserialize(_models.ErrorResponse, 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 = _deserialize(_models.ErrorResponse, 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, @@ -531,7 +720,7 @@ async def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -584,7 +773,7 @@ async def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -637,7 +826,7 @@ async def begin_analyze_batch_documents( :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 + :keyword pages: List 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 @@ -691,7 +880,7 @@ async def begin_analyze_batch_documents( 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 + :keyword pages: List 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 @@ -783,16 +972,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.AnalyzeBatchResultOperation"]: + """List batch document analysis results. + + :param model_id: Unique document model name. Required. + :type model_id: str + :return: An iterator like instance of AnalyzeBatchResultOperation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.documentintelligence.models.AnalyzeBatchResultOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AnalyzeBatchResultOperation]] = 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.AnalyzeBatchResultOperation], 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 = _deserialize(_models.ErrorResponse, 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 +1084,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 +1098,34 @@ 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()) 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.AnalyzeBatchResultOperation: + """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: AnalyzeBatchResultOperation. The AnalyzeBatchResultOperation is compatible with + MutableMapping + :rtype: ~azure.ai.documentintelligence.models.AnalyzeBatchResultOperation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -874,12 +1139,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.AnalyzeBatchResultOperation] = 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 +1153,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 ) @@ -906,13 +1170,13 @@ async def get_analyze_result_figure( error = _deserialize(_models.ErrorResponse, 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.AnalyzeBatchResultOperation, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @@ -1014,7 +1278,7 @@ async def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1050,7 +1314,7 @@ async def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1086,7 +1350,7 @@ async def begin_classify_document( :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 + :keyword pages: List of 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. @@ -1123,7 +1387,7 @@ async def begin_classify_document( :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 + :keyword pages: List of 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 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 da3223c795b7..264bba4e8ddd 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 @@ -22,7 +22,7 @@ ) from ... import models as _models from ..._model_base import _deserialize -from ..._operations._patch import PollingReturnType_co, _parse_operation_id, _finished +from ..._operations._patch import PollingReturnType_co, _parse_operation_id if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -60,16 +60,6 @@ def from_continuation_token( 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 @@ -580,7 +570,7 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncAnalyzeDocumentLROPoller[_models.AnalyzeBatchResult].from_continuation_token( + return AsyncAnalyzeDocumentLROPoller[_models.AnalyzeResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, @@ -590,8 +580,164 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @overload + async def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_request: Optional[_models.AnalyzeBatchDocumentsRequest] = 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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult + is compatible with MutableMapping + :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AsAsyncAnalyzeDocumentLROPolleryncLROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult + is compatible with MutableMapping + :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_analyze_batch_documents( + self, + model_id: str, + analyze_batch_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.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AsyncAsyncAnalyzeDocumentLROPollerLROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult + is compatible with MutableMapping + :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_analyze_batch_documents( # type: ignore[override] + async def begin_analyze_batch_documents( self, model_id: str, analyze_batch_request: Optional[Union[_models.AnalyzeBatchDocumentsRequest, JSON, IO[bytes]]] = None, @@ -604,21 +750,120 @@ async def begin_analyze_batch_documents( # type: ignore[override] output_content_format: Optional[Union[str, _models.ContentFormat]] = None, output: Optional[List[Union[str, _models.AnalyzeOutputOption]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.AnalyzeBatchResult]: + ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeBatchResult]: + """Analyzes batch documents with document model. + + :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: List 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 AnalyzeBatchResult. The AnalyzeBatchResult + is compatible with MutableMapping + :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :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.AnalyzeBatchResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._analyze_batch_documents_initial( + 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, + 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.AnalyzeBatchResult, response.json().get("result")) + 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.AnalyzeBatchResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + @distributed_trace_async + async def get_batch_analyze_result( + self, continuation_token: str + ) -> AsyncAnalyzeDocumentLROPoller[_models.AnalyzeBatchResult]: + """Gets the result of batch document analysis. + + :param continuation_token: An opaque continuation token. Required. + :type model_id: str + :return: An instance of AsyncAnalyzeDocumentLROPoller that returns AnalyzeBatchResult. The AnalyzeBatchResult + is compatible with MutableMapping + :rtype: AsyncAnalyzeDocumentLROPoller[~azure.ai.documentintelligence.models.AnalyzeBatchResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + return await self.begin_analyze_batch_documents(None, None, continuation_token=continuation_token) __all__: List[str] = [ 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 2f7221ee110a..f82d490b0a79 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,85 +5,97 @@ # 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, + AnalyzeBatchOperationDetail, + AnalyzeBatchResult, + AnalyzeBatchResultOperation, + AnalyzeDocumentRequest, + AnalyzeResult, + AnalyzeResultOperation, + AuthorizeClassifierCopyRequest, + AuthorizeCopyRequest, + AzureBlobContentSource, + AzureBlobFileListContentSource, + BoundingRegion, + BuildDocumentClassifierRequest, + BuildDocumentModelRequest, + ClassifierCopyAuthorization, + ClassifierDocumentTypeDetails, + ClassifyDocumentRequest, + ComposeDocumentModelRequest, + CopyAuthorization, + CurrencyValue, + CustomDocumentModelsDetails, + Document, + DocumentBarcode, + DocumentCaption, + DocumentClassifierBuildOperationDetails, + DocumentClassifierCopyToOperationDetails, + DocumentClassifierDetails, + DocumentField, + DocumentFieldSchema, + DocumentFigure, + DocumentFootnote, + DocumentFormula, + DocumentKeyValueElement, + DocumentKeyValuePair, + DocumentLanguage, + DocumentLine, + DocumentModelBuildOperationDetails, + DocumentModelComposeOperationDetails, + DocumentModelCopyToOperationDetails, + DocumentModelDetails, + DocumentPage, + DocumentParagraph, + DocumentSection, + DocumentSelectionMark, + DocumentSpan, + DocumentStyle, + DocumentTable, + DocumentTableCell, + DocumentTypeDetails, + DocumentWord, + Error, + ErrorResponse, + InnerError, + OperationDetails, + ResourceDetails, + Warning, +) + +from ._enums import ( # type: ignore + AnalyzeOutputOption, + ContentFormat, + ContentSourceKind, + DocumentAnalysisFeature, + DocumentBarcodeKind, + DocumentBuildMode, + DocumentFieldType, + DocumentFormulaKind, + DocumentSelectionMarkState, + DocumentSignatureType, + DocumentTableCellKind, + FontStyle, + FontWeight, + LengthUnit, + OperationKind, + OperationStatus, + ParagraphRole, + SplitMode, + StringIndexType, +) +from ._patch import __all__ as _patch_all +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -164,4 +176,5 @@ "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 de21b9aa550e..138aa3c140f3 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 @@ -107,8 +107,6 @@ 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 DocumentFieldType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -246,10 +244,10 @@ class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operation has failed.""" SUCCEEDED = "succeeded" """The operation has succeeded.""" - COMPLETED = "completed" - """The operation has completed.""" CANCELED = "canceled" """The operation has been canceled.""" + SKIPPED = "skipped" + """The operation has been skipped.""" class ParagraphRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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 95af408671b0..44829446fd67 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,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) @@ -179,7 +180,7 @@ class AnalyzeBatchOperationDetail(_model_base.Model): :ivar status: Analyze status. succeeded, failed, or skipped. Required. Known values are: - "notStarted", "running", "failed", "succeeded", "completed", and "canceled". + "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar source_url: URL of the source document. Required. :vartype source_url: str @@ -191,7 +192,7 @@ class AnalyzeBatchOperationDetail(_model_base.Model): status: Union[str, "_models.OperationStatus"] = 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") @@ -216,7 +217,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 +231,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 +241,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 +251,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,7 +261,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) @@ -268,8 +269,8 @@ class AnalyzeBatchResultOperation(_model_base.Model): """Status and result of the analyze batch operation. - :ivar status: Operation status. notStarted, running, completed, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". + :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.OperationStatus :ivar created_date_time: Date and time (UTC) when the operation was submitted. Required. :vartype created_date_time: ~datetime.datetime @@ -284,8 +285,8 @@ class AnalyzeBatchResultOperation(_model_base.Model): """ 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\".""" + """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") @@ -316,7 +317,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 +353,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. @@ -456,7 +457,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) @@ -465,7 +466,7 @@ class AnalyzeResultOperation(_model_base.Model): :ivar status: Operation status. notStarted, running, succeeded, or failed. Required. Known - values are: "notStarted", "running", "failed", "succeeded", "completed", and "canceled". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar created_date_time: Date and time (UTC) when the analyze operation was submitted. Required. @@ -480,7 +481,7 @@ class AnalyzeResultOperation(_model_base.Model): 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\".""" + \"notStarted\", \"running\", \"failed\", \"succeeded\", \"canceled\", and \"skipped\".""" 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") @@ -508,7 +509,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 +549,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 +589,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 +623,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 +658,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 +698,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 +749,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 +762,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 +787,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 +824,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 +884,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 +937,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 +974,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,7 +1030,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) @@ -1089,7 +1089,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) @@ -1128,7 +1128,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,7 +1163,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) @@ -1212,7 +1212,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) @@ -1271,7 +1271,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,7 +1315,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) @@ -1331,7 +1331,7 @@ 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -1358,7 +1358,7 @@ class OperationDetails(_model_base.Model): """Operation ID. Required.""" 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\".""" + \"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") @@ -1401,20 +1401,18 @@ 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 +class DocumentClassifierBuildOperationDetails(OperationDetails, 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -1464,20 +1462,18 @@ 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 +class DocumentClassifierCopyToOperationDetails(OperationDetails, 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -1531,13 +1527,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 +1546,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. @@ -1567,6 +1567,10 @@ 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") @@ -1597,11 +1601,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 +1733,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) @@ -1783,7 +1787,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 +1841,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 +1885,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,7 +1940,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) @@ -1976,7 +1980,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 +2020,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 +2063,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,20 +2109,18 @@ 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(OperationDetails, 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -2168,20 +2170,18 @@ 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(OperationDetails, 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -2232,20 +2232,18 @@ 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(OperationDetails, 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". + values are: "notStarted", "running", "failed", "succeeded", "canceled", and "skipped". :vartype status: str or ~azure.ai.documentintelligence.models.OperationStatus :ivar percent_completed: Operation progress (0-100). :vartype percent_completed: int @@ -2299,11 +2297,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 +2315,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. @@ -2356,13 +2355,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"] ) @@ -2403,11 +2405,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 +2490,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 +2537,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 +2571,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 +2623,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 +2658,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) @@ -2724,7 +2726,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 +2785,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 +2856,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 +2865,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 +2888,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 +2926,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,7 +2978,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) @@ -3028,7 +3028,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) @@ -3057,7 +3057,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) @@ -3095,7 +3095,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) @@ -3125,7 +3125,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) @@ -3164,5 +3164,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/samples/sample_analyze_batch_documents.py b/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_analyze_batch_documents.py new file mode 100644 index 000000000000..dfb54b98eba1 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_analyze_batch_documents.py @@ -0,0 +1,113 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_analyze_batch_documents.py + +USAGE: + python sample_analyze_batch_documents.py + + Set the environment variables with your own values before running the sample: + 1) DOCUMENTINTELLIGENCE_ENDPOINT - the endpoint to your Document Intelligence resource. + 2) DOCUMENTINTELLIGENCE_API_KEY - your Document Intelligence API key. +""" + +import os + + +def analyze_batch_docs(): + from azure.core.credentials import AzureKeyCredential + from azure.ai.documentintelligence import DocumentIntelligenceClient + from azure.ai.documentintelligence.models import AnalyzeBatchDocumentsRequest, AzureBlobContentSource, AnalyzeBatchResultOperation, AnalyzeBatchResult + + endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"] + key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"] + result_container_sas_url = os.environ["RESULT_SAS_URL"] + batch_training_data_container_sas_url = os.environ["TRAINING_DATA_SAS_URL"] + + + document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key)) + + # Solution1: + request = AnalyzeBatchDocumentsRequest( + result_container_url=result_container_sas_url, + azure_blob_source=AzureBlobContentSource( + container_url=batch_training_data_container_sas_url, + ), + ) + poller = document_intelligence_client.begin_analyze_batch_documents( + model_id="model_id", + analyze_batch_request=request, + ) + if poller.done(): + final_result = poller.result() + print(f"Succeeded count: {final_result.succeeded_count}") + print(f"Failed count: {final_result.failed_count}") + print(f"Skipped count: {final_result.skipped_count}") + else: + operation_id = poller.details["operation_id"] + result: AnalyzeBatchResultOperation = document_intelligence_client.get_analyze_batch_result(model_id="model_id", operation_id=operation_id) + if result.status == "succeeded": + final_result: AnalyzeBatchResult = result.result + print(f"Succeeded count: {final_result.succeeded_count}") + print(f"Failed count: {final_result.failed_count}") + print(f"Skipped count: {final_result.skipped_count}") + else: + print("The batch analyze is still in process...") + + + # Solution2 + request = AnalyzeBatchDocumentsRequest( + result_container_url=result_container_sas_url, + azure_blob_source=AzureBlobContentSource( + container_url=batch_training_data_container_sas_url, + ), + ) + poller = document_intelligence_client.begin_analyze_batch_documents( + model_id="model_id", + analyze_batch_request=request, + ) + if poller.done(): + final_result = poller.result() + print(f"Succeeded count: {final_result.succeeded_count}") + print(f"Failed count: {final_result.failed_count}") + print(f"Skipped count: {final_result.skipped_count}") + else: + contination_token = poller.continuation_token() # a continuation token that allows to restart the poller later. + poller2 = document_intelligence_client.get_batch_analyze_result(contination_token) + if poller2.done(): + final_result = poller2.result() + print(f"Succeeded count: {final_result.succeeded_count}") + print(f"Failed count: {final_result.failed_count}") + print(f"Skipped count: {final_result.skipped_count}") + else: + print("The batch analyze is still in process...") + + +if __name__ == "__main__": + from azure.core.exceptions import HttpResponseError + from dotenv import find_dotenv, load_dotenv + + try: + load_dotenv(find_dotenv()) + analyze_batch_docs() + except HttpResponseError as error: + # Examples of how to check an HttpResponseError + # Check by error code: + if error.error is not None: + if error.error.code == "InvalidImage": + print(f"Received an invalid image error: {error.error}") + if error.error.code == "InvalidRequest": + print(f"Received an invalid request error: {error.error}") + # Raise the error again after printing it + raise + # If the inner error is None and then it is possible to check the message to get more information: + if "Invalid request".casefold() in error.message.casefold(): + print(f"Uh-oh! Seems there was an invalid request: {error}") + # Raise the error again + raise diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml b/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml index 18b1c4b0e7f4..a9d474e0cc2f 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 +commit: 0ce1ef34e25930d3dfc732c452cd35ec0943c04d additionalDirectories: [] repo: Azure/azure-rest-api-specs