diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/__init__.py index d31051f3f519..e02c5400e3bd 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/__init__.py @@ -9,10 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .form_recognizer_client import FormRecognizerClient -from .version import VERSION +from ._configuration import FormRecognizerClientConfiguration +from ._form_recognizer_client import FormRecognizerClient +__all__ = ['FormRecognizerClient', 'FormRecognizerClientConfiguration'] -__all__ = ['FormRecognizerClient'] +from .version import VERSION __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_configuration.py new file mode 100644 index 000000000000..4871d3dcce40 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_configuration.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest import Configuration + +from .version import VERSION + + +class FormRecognizerClientConfiguration(Configuration): + """Configuration for FormRecognizerClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = '{endpoint}/formrecognizer/v2.0-preview' + + super(FormRecognizerClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-cognitiveservices-formrecognizer/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_form_recognizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_form_recognizer_client.py new file mode 100644 index 000000000000..1ba1add5c2ae --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/_form_recognizer_client.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import FormRecognizerClientConfiguration +from .operations import FormRecognizerClientOperationsMixin +from . import models + + +class FormRecognizerClient(FormRecognizerClientOperationsMixin, SDKClient): + """Extracts information from forms and images into structured data. + + :ivar config: Configuration for client. + :vartype config: FormRecognizerClientConfiguration + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = FormRecognizerClientConfiguration(endpoint, credentials) + super(FormRecognizerClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2.0-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py deleted file mode 100644 index cc24b2f0ccf6..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py +++ /dev/null @@ -1,423 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.service_client import SDKClient -from msrest import Configuration, Serializer, Deserializer -from .version import VERSION -from msrest.pipeline import ClientRawResponse -from . import models - - -class FormRecognizerClientConfiguration(Configuration): - """Configuration for FormRecognizerClient - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Supported Cognitive Services endpoints (protocol and - hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - :param credentials: Subscription credentials which uniquely identify - client subscription. - :type credentials: None - """ - - def __init__( - self, endpoint, credentials): - - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/formrecognizer/v1.0-preview' - - super(FormRecognizerClientConfiguration, self).__init__(base_url) - - self.add_user_agent('azure-cognitiveservices-formrecognizer/{}'.format(VERSION)) - - self.endpoint = endpoint - self.credentials = credentials - - -class FormRecognizerClient(SDKClient): - """Extracts information from forms and images into structured data based on a model created by a set of representative training forms. - - :ivar config: Configuration for client. - :vartype config: FormRecognizerClientConfiguration - - :param endpoint: Supported Cognitive Services endpoints (protocol and - hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - :param credentials: Subscription credentials which uniquely identify - client subscription. - :type credentials: None - """ - - def __init__( - self, endpoint, credentials): - - self.config = FormRecognizerClientConfiguration(endpoint, credentials) - super(FormRecognizerClient, self).__init__(self.config.credentials, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '1.0-preview' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - - def train_custom_model( - self, source, custom_headers=None, raw=False, **operation_config): - """Train Model. - - Create and train a custom model. The train request must include a - source parameter that is either an externally accessible Azure Storage - blob container Uri (preferably a Shared Access Signature Uri) or valid - path to a data folder in a locally mounted drive. When local paths are - specified, they must follow the Linux/Unix path format and be an - absolute path rooted to the input mount configuration - setting value e.g., if '{Mounts:Input}' configuration setting value is - '/input' then a valid source path would be '/input/contosodataset'. All - data to be trained is expected to be directly under the source folder. - Subfolders are not supported. Models are trained using documents that - are of the following content type - 'application/pdf', 'image/jpeg' and - 'image/png'." - Other type of content is ignored. - - :param source: Get or set source path. - :type source: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TrainResult or ClientRawResponse if raw=true - :rtype: ~azure.cognitiveservices.formrecognizer.models.TrainResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - train_request = models.TrainRequest(source=source) - - # Construct URL - url = self.train_custom_model.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct body - body_content = self._serialize.body(train_request, 'TrainRequest') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('TrainResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - train_custom_model.metadata = {'url': '/custom/train'} - - def get_extracted_keys( - self, id, custom_headers=None, raw=False, **operation_config): - """Get Keys. - - Retrieve the keys that were - extracted during the training of the specified model. - - :param id: Model identifier. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: KeysResult or ClientRawResponse if raw=true - :rtype: ~azure.cognitiveservices.formrecognizer.models.KeysResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.get_extracted_keys.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('KeysResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_extracted_keys.metadata = {'url': '/custom/models/{id}/keys'} - - def get_custom_models( - self, custom_headers=None, raw=False, **operation_config): - """Get Models. - - Get information about all trained custom models. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ModelsResult or ClientRawResponse if raw=true - :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelsResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.get_custom_models.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ModelsResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_custom_models.metadata = {'url': '/custom/models'} - - def get_custom_model( - self, id, custom_headers=None, raw=False, **operation_config): - """Get Model. - - Get information about a model. - - :param id: Model identifier. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ModelResult or ClientRawResponse if raw=true - :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.get_custom_model.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ModelResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_custom_model.metadata = {'url': '/custom/models/{id}'} - - def delete_custom_model( - self, id, custom_headers=None, raw=False, **operation_config): - """Delete Model. - - Delete model artifacts. - - :param id: The identifier of the model to delete. - :type id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.delete_custom_model.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - - # Construct headers - header_parameters = {} - if custom_headers: - header_parameters.update(custom_headers) - - # Construct and send request - request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_custom_model.metadata = {'url': '/custom/models/{id}'} - - def analyze_with_custom_model( - self, id, form_stream, keys=None, custom_headers=None, raw=False, **operation_config): - """Analyze Form. - - Extract key-value pairs from a given document. The input document must - be of one of the supported content types - 'application/pdf', - 'image/jpeg' or 'image/png'. A success response is returned in JSON. - - :param id: Model Identifier to analyze the document with. - :type id: str - :param form_stream: A pdf document or image (jpg,png) file to analyze. - :type form_stream: Generator - :param keys: An optional list of known keys to extract the values for. - :type keys: list[str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AnalyzeResult or ClientRawResponse if raw=true - :rtype: ~azure.cognitiveservices.formrecognizer.models.AnalyzeResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.analyze_with_custom_model.metadata['url'] - path_format_arguments = { - 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), - 'id': self._serialize.url("id", id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if keys is not None: - query_parameters['keys'] = self._serialize.query("keys", keys, '[str]', div=',') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'multipart/form-data' - if custom_headers: - header_parameters.update(custom_headers) - - # Construct form data - form_data_content = { - 'form_stream': form_stream, - } - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('AnalyzeResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - analyze_with_custom_model.metadata = {'url': '/custom/models/{id}/analyze'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py index 0c3013f53f9b..dd78bfef8aab 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py @@ -10,55 +10,96 @@ # -------------------------------------------------------------------------- try: - from .train_request_py3 import TrainRequest - from .form_document_report_py3 import FormDocumentReport - from .form_operation_error_py3 import FormOperationError - from .train_result_py3 import TrainResult - from .keys_result_py3 import KeysResult - from .model_result_py3 import ModelResult - from .models_result_py3 import ModelsResult - from .inner_error_py3 import InnerError - from .error_information_py3 import ErrorInformation - from .error_response_py3 import ErrorResponse, ErrorResponseException - from .extracted_token_py3 import ExtractedToken - from .extracted_key_value_pair_py3 import ExtractedKeyValuePair - from .extracted_table_column_py3 import ExtractedTableColumn - from .extracted_table_py3 import ExtractedTable - from .extracted_page_py3 import ExtractedPage - from .analyze_result_py3 import AnalyzeResult + from ._models_py3 import AnalyzeOperationResult + from ._models_py3 import AnalyzeResult + from ._models_py3 import DataTable + from ._models_py3 import DataTableCell + from ._models_py3 import DocumentResult + from ._models_py3 import ErrorInformation + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import FieldValue + from ._models_py3 import FormFieldsReport + from ._models_py3 import KeysResult + from ._models_py3 import KeyValueElement + from ._models_py3 import KeyValuePair + from ._models_py3 import Model + from ._models_py3 import ModelInfo + from ._models_py3 import ModelsModel + from ._models_py3 import ModelsSummary + from ._models_py3 import PageResult + from ._models_py3 import ReadResult + from ._models_py3 import SourcePath + from ._models_py3 import TextLine + from ._models_py3 import TextWord + from ._models_py3 import TrainingDocumentInfo + from ._models_py3 import TrainRequest + from ._models_py3 import TrainResult + from ._models_py3 import TrainSourceFilter except (SyntaxError, ImportError): - from .train_request import TrainRequest - from .form_document_report import FormDocumentReport - from .form_operation_error import FormOperationError - from .train_result import TrainResult - from .keys_result import KeysResult - from .model_result import ModelResult - from .models_result import ModelsResult - from .inner_error import InnerError - from .error_information import ErrorInformation - from .error_response import ErrorResponse, ErrorResponseException - from .extracted_token import ExtractedToken - from .extracted_key_value_pair import ExtractedKeyValuePair - from .extracted_table_column import ExtractedTableColumn - from .extracted_table import ExtractedTable - from .extracted_page import ExtractedPage - from .analyze_result import AnalyzeResult + from ._models import AnalyzeOperationResult + from ._models import AnalyzeResult + from ._models import DataTable + from ._models import DataTableCell + from ._models import DocumentResult + from ._models import ErrorInformation + from ._models import ErrorResponse, ErrorResponseException + from ._models import FieldValue + from ._models import FormFieldsReport + from ._models import KeysResult + from ._models import KeyValueElement + from ._models import KeyValuePair + from ._models import Model + from ._models import ModelInfo + from ._models import ModelsModel + from ._models import ModelsSummary + from ._models import PageResult + from ._models import ReadResult + from ._models import SourcePath + from ._models import TextLine + from ._models import TextWord + from ._models import TrainingDocumentInfo + from ._models import TrainRequest + from ._models import TrainResult + from ._models import TrainSourceFilter +from ._form_recognizer_client_enums import ( + FieldValueType, + Language, + LengthUnit, + ModelStatus, + OperationStatus, + TrainStatus, +) __all__ = [ - 'TrainRequest', - 'FormDocumentReport', - 'FormOperationError', - 'TrainResult', - 'KeysResult', - 'ModelResult', - 'ModelsResult', - 'InnerError', + 'AnalyzeOperationResult', + 'AnalyzeResult', + 'DataTable', + 'DataTableCell', + 'DocumentResult', 'ErrorInformation', 'ErrorResponse', 'ErrorResponseException', - 'ExtractedToken', - 'ExtractedKeyValuePair', - 'ExtractedTableColumn', - 'ExtractedTable', - 'ExtractedPage', - 'AnalyzeResult', + 'FieldValue', + 'FormFieldsReport', + 'KeysResult', + 'KeyValueElement', + 'KeyValuePair', + 'Model', + 'ModelInfo', + 'ModelsModel', + 'ModelsSummary', + 'PageResult', + 'ReadResult', + 'SourcePath', + 'TextLine', + 'TextWord', + 'TrainingDocumentInfo', + 'TrainRequest', + 'TrainResult', + 'TrainSourceFilter', + 'OperationStatus', + 'LengthUnit', + 'Language', + 'FieldValueType', + 'TrainStatus', + 'ModelStatus', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_form_recognizer_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_form_recognizer_client_enums.py new file mode 100644 index 000000000000..75dde304d70f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_form_recognizer_client_enums.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class OperationStatus(str, Enum): + + not_started = "notStarted" + running = "running" + succeeded = "succeeded" + failed = "failed" + + +class LengthUnit(str, Enum): + + pixel = "pixel" + inch = "inch" + + +class Language(str, Enum): + + en = "en" + es = "es" + + +class FieldValueType(str, Enum): + + string = "string" + date_enum = "date" + time = "time" + phone_number = "phoneNumber" + number = "number" + integer = "integer" + array = "array" + object_enum = "object" + + +class TrainStatus(str, Enum): + + succeeded = "succeeded" + partially_succeeded = "partiallySucceeded" + failed = "failed" + + +class ModelStatus(str, Enum): + + creating = "creating" + ready = "ready" + invalid = "invalid" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models.py new file mode 100644 index 000000000000..3cbfba51f004 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models.py @@ -0,0 +1,957 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AnalyzeOperationResult(Model): + """Status and result of the queued analyze operation. + + All required parameters must be populated in order to send to Azure. + + :param status: Required. Operation status. Possible values include: + 'notStarted', 'running', 'succeeded', 'failed' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.OperationStatus + :param created_date_time: Required. Date and time (UTC) when the analyze + operation was submitted. + :type created_date_time: datetime + :param last_updated_date_time: Required. Date and time (UTC) when the + status was last updated. + :type last_updated_date_time: datetime + :param analyze_result: Results of the analyze operation. + :type analyze_result: + ~azure.cognitiveservices.formrecognizer.models.AnalyzeResult + """ + + _validation = { + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'OperationStatus'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResult'}, + } + + def __init__(self, **kwargs): + super(AnalyzeOperationResult, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.last_updated_date_time = kwargs.get('last_updated_date_time', None) + self.analyze_result = kwargs.get('analyze_result', None) + + +class AnalyzeResult(Model): + """Analyze operation result. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Version of schema used for this result. + :type version: str + :param read_results: Required. Text extracted from the input. + :type read_results: + list[~azure.cognitiveservices.formrecognizer.models.ReadResult] + :param page_results: Page-level information extracted from the input. + :type page_results: + list[~azure.cognitiveservices.formrecognizer.models.PageResult] + :param document_results: Document-level information extracted from the + input. + :type document_results: + list[~azure.cognitiveservices.formrecognizer.models.DocumentResult] + :param errors: List of errors reported during the analyze operation. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + """ + + _validation = { + 'version': {'required': True}, + 'read_results': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'version', 'type': 'str'}, + 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, + 'page_results': {'key': 'pageResults', 'type': '[PageResult]'}, + 'document_results': {'key': 'documentResults', 'type': '[DocumentResult]'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + } + + def __init__(self, **kwargs): + super(AnalyzeResult, self).__init__(**kwargs) + self.version = kwargs.get('version', None) + self.read_results = kwargs.get('read_results', None) + self.page_results = kwargs.get('page_results', None) + self.document_results = kwargs.get('document_results', None) + self.errors = kwargs.get('errors', None) + + +class DataTable(Model): + """Information about the extracted table contained in a page. + + All required parameters must be populated in order to send to Azure. + + :param rows: Required. Number of rows. + :type rows: int + :param columns: Required. Number of columns. + :type columns: int + :param cells: Required. List of cells contained in the table. + :type cells: + list[~azure.cognitiveservices.formrecognizer.models.DataTableCell] + """ + + _validation = { + 'rows': {'required': True, 'minimum': 1}, + 'columns': {'required': True, 'minimum': 1}, + 'cells': {'required': True}, + } + + _attribute_map = { + 'rows': {'key': 'rows', 'type': 'int'}, + 'columns': {'key': 'columns', 'type': 'int'}, + 'cells': {'key': 'cells', 'type': '[DataTableCell]'}, + } + + def __init__(self, **kwargs): + super(DataTable, self).__init__(**kwargs) + self.rows = kwargs.get('rows', None) + self.columns = kwargs.get('columns', None) + self.cells = kwargs.get('cells', None) + + +class DataTableCell(Model): + """Information about the extracted cell in a table. + + All required parameters must be populated in order to send to Azure. + + :param row_index: Required. Row index of the cell. + :type row_index: int + :param column_index: Required. Column index of the cell. + :type column_index: int + :param row_span: Number of rows spanned by this cell. Default value: 1 . + :type row_span: int + :param column_span: Number of columns spanned by this cell. Default value: + 1 . + :type column_span: int + :param text: Required. Text content of the cell. + :type text: str + :param bounding_box: Required. Bounding box of the cell. + :type bounding_box: list[float] + :param confidence: Required. Confidence value. + :type confidence: float + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this table cell. + :type elements: list[str] + :param is_header: Is the current cell a header cell?. Default value: False + . + :type is_header: bool + :param is_footer: Is the current cell a footer cell?. Default value: False + . + :type is_footer: bool + """ + + _validation = { + 'row_index': {'required': True, 'minimum': 0}, + 'column_index': {'required': True, 'minimum': 0}, + 'row_span': {'minimum': 1}, + 'column_span': {'minimum': 1}, + 'text': {'required': True}, + 'bounding_box': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'row_index': {'key': 'rowIndex', 'type': 'int'}, + 'column_index': {'key': 'columnIndex', 'type': 'int'}, + 'row_span': {'key': 'rowSpan', 'type': 'int'}, + 'column_span': {'key': 'columnSpan', 'type': 'int'}, + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + 'is_header': {'key': 'isHeader', 'type': 'bool'}, + 'is_footer': {'key': 'isFooter', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(DataTableCell, self).__init__(**kwargs) + self.row_index = kwargs.get('row_index', None) + self.column_index = kwargs.get('column_index', None) + self.row_span = kwargs.get('row_span', 1) + self.column_span = kwargs.get('column_span', 1) + self.text = kwargs.get('text', None) + self.bounding_box = kwargs.get('bounding_box', None) + self.confidence = kwargs.get('confidence', None) + self.elements = kwargs.get('elements', None) + self.is_header = kwargs.get('is_header', False) + self.is_footer = kwargs.get('is_footer', False) + + +class DocumentResult(Model): + """A set of extracted fields corresponding to the input document. + + All required parameters must be populated in order to send to Azure. + + :param doc_type: Required. Document type. + :type doc_type: str + :param page_range: Required. First and last page number where the document + is found. + :type page_range: list[int] + :param fields: Required. Dictionary of named field values. + :type fields: dict[str, + ~azure.cognitiveservices.formrecognizer.models.FieldValue] + """ + + _validation = { + 'doc_type': {'required': True}, + 'page_range': {'required': True, 'max_items': 2, 'min_items': 2}, + 'fields': {'required': True}, + } + + _attribute_map = { + 'doc_type': {'key': 'docType', 'type': 'str'}, + 'page_range': {'key': 'pageRange', 'type': '[int]'}, + 'fields': {'key': 'fields', 'type': '{FieldValue}'}, + } + + def __init__(self, **kwargs): + super(DocumentResult, self).__init__(**kwargs) + self.doc_type = kwargs.get('doc_type', None) + self.page_range = kwargs.get('page_range', None) + self.fields = kwargs.get('fields', None) + + +class ErrorInformation(Model): + """ErrorInformation. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. + :type code: str + :param message: Required. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorInformation, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ErrorResponse(Model): + """ErrorResponse. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. + :type error: + ~azure.cognitiveservices.formrecognizer.models.ErrorInformation + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorInformation'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class FieldValue(Model): + """Recognized field value. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Type of field value. Possible values include: + 'string', 'date', 'time', 'phoneNumber', 'number', 'integer', 'array', + 'object' + :type type: str or + ~azure.cognitiveservices.formrecognizer.models.FieldValueType + :param value_string: String value. + :type value_string: str + :param value_date: Date value. + :type value_date: date + :param value_time: Time value. + :type value_time: str + :param value_phone_number: Phone number value. + :type value_phone_number: str + :param value_number: Floating point value. + :type value_number: float + :param value_integer: Integer value. + :type value_integer: int + :param value_array: Array of field values. + :type value_array: + list[~azure.cognitiveservices.formrecognizer.models.FieldValue] + :param value_object: Dictionary of named field values. + :type value_object: dict[str, + ~azure.cognitiveservices.formrecognizer.models.FieldValue] + :param text: Text content of the extracted field. + :type text: str + :param bounding_box: Bounding box of the field value, if appropriate. + :type bounding_box: list[float] + :param confidence: Confidence score. + :type confidence: float + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this field. + :type elements: list[str] + :param page: The 1-based page number in the input document. + :type page: int + """ + + _validation = { + 'type': {'required': True}, + 'page': {'minimum': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'FieldValueType'}, + 'value_string': {'key': 'valueString', 'type': 'str'}, + 'value_date': {'key': 'valueDate', 'type': 'date'}, + 'value_time': {'key': 'valueTime', 'type': 'str'}, + 'value_phone_number': {'key': 'valuePhoneNumber', 'type': 'str'}, + 'value_number': {'key': 'valueNumber', 'type': 'float'}, + 'value_integer': {'key': 'valueInteger', 'type': 'int'}, + 'value_array': {'key': 'valueArray', 'type': '[FieldValue]'}, + 'value_object': {'key': 'valueObject', 'type': '{FieldValue}'}, + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + 'page': {'key': 'page', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(FieldValue, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.value_string = kwargs.get('value_string', None) + self.value_date = kwargs.get('value_date', None) + self.value_time = kwargs.get('value_time', None) + self.value_phone_number = kwargs.get('value_phone_number', None) + self.value_number = kwargs.get('value_number', None) + self.value_integer = kwargs.get('value_integer', None) + self.value_array = kwargs.get('value_array', None) + self.value_object = kwargs.get('value_object', None) + self.text = kwargs.get('text', None) + self.bounding_box = kwargs.get('bounding_box', None) + self.confidence = kwargs.get('confidence', None) + self.elements = kwargs.get('elements', None) + self.page = kwargs.get('page', None) + + +class FormFieldsReport(Model): + """Report for a custom model training field. + + All required parameters must be populated in order to send to Azure. + + :param field_name: Required. Training field name. + :type field_name: str + :param accuracy: Required. Estimated extraction accuracy for this field. + :type accuracy: float + """ + + _validation = { + 'field_name': {'required': True}, + 'accuracy': {'required': True}, + } + + _attribute_map = { + 'field_name': {'key': 'fieldName', 'type': 'str'}, + 'accuracy': {'key': 'accuracy', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(FormFieldsReport, self).__init__(**kwargs) + self.field_name = kwargs.get('field_name', None) + self.accuracy = kwargs.get('accuracy', None) + + +class KeysResult(Model): + """Keys extracted by the custom model. + + All required parameters must be populated in order to send to Azure. + + :param clusters: Required. Object mapping clusterIds to a list of keys. + :type clusters: dict[str, list[str]] + """ + + _validation = { + 'clusters': {'required': True}, + } + + _attribute_map = { + 'clusters': {'key': 'clusters', 'type': '{[str]}'}, + } + + def __init__(self, **kwargs): + super(KeysResult, self).__init__(**kwargs) + self.clusters = kwargs.get('clusters', None) + + +class KeyValueElement(Model): + """Information about the extracted key or value in a key-value pair. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the key or value. + :type text: str + :param bounding_box: Bounding box of the key or value. + :type bounding_box: list[float] + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this key or value. + :type elements: list[str] + """ + + _validation = { + 'text': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(KeyValueElement, self).__init__(**kwargs) + self.text = kwargs.get('text', None) + self.bounding_box = kwargs.get('bounding_box', None) + self.elements = kwargs.get('elements', None) + + +class KeyValuePair(Model): + """Information about the extracted key-value pair. + + All required parameters must be populated in order to send to Azure. + + :param label: A user defined label for the key/value pair entry. + :type label: str + :param key: Required. Information about the extracted key in a key-value + pair. + :type key: ~azure.cognitiveservices.formrecognizer.models.KeyValueElement + :param value: Required. Information about the extracted value in a + key-value pair. + :type value: + ~azure.cognitiveservices.formrecognizer.models.KeyValueElement + :param confidence: Required. Confidence value. + :type confidence: float + """ + + _validation = { + 'key': {'required': True}, + 'value': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'label': {'key': 'label', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'KeyValueElement'}, + 'value': {'key': 'value', 'type': 'KeyValueElement'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(KeyValuePair, self).__init__(**kwargs) + self.label = kwargs.get('label', None) + self.key = kwargs.get('key', None) + self.value = kwargs.get('value', None) + self.confidence = kwargs.get('confidence', None) + + +class Model(Model): + """Response to the get custom model operation. + + All required parameters must be populated in order to send to Azure. + + :param model_info: Required. + :type model_info: ~azure.cognitiveservices.formrecognizer.models.ModelInfo + :param keys: + :type keys: ~azure.cognitiveservices.formrecognizer.models.KeysResult + :param train_result: + :type train_result: + ~azure.cognitiveservices.formrecognizer.models.TrainResult + """ + + _validation = { + 'model_info': {'required': True}, + } + + _attribute_map = { + 'model_info': {'key': 'modelInfo', 'type': 'ModelInfo'}, + 'keys': {'key': 'keys', 'type': 'KeysResult'}, + 'train_result': {'key': 'trainResult', 'type': 'TrainResult'}, + } + + def __init__(self, **kwargs): + super(Model, self).__init__(**kwargs) + self.model_info = kwargs.get('model_info', None) + self.keys = kwargs.get('keys', None) + self.train_result = kwargs.get('train_result', None) + + +class ModelInfo(Model): + """Basic custom model information. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param status: Required. Status of the model. Possible values include: + 'creating', 'ready', 'invalid' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.ModelStatus + :param created_date_time: Required. Date and time (UTC) when the model was + created. + :type created_date_time: datetime + :param last_updated_date_time: Required. Date and time (UTC) when the + status was last updated. + :type last_updated_date_time: datetime + """ + + _validation = { + 'model_id': {'required': True}, + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ModelInfo, self).__init__(**kwargs) + self.model_id = kwargs.get('model_id', None) + self.status = kwargs.get('status', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.last_updated_date_time = kwargs.get('last_updated_date_time', None) + + +class ModelsModel(Model): + """Response to the list custom models operation. + + :param summary: Summary of all trained custom models. + :type summary: + ~azure.cognitiveservices.formrecognizer.models.ModelsSummary + :param model_list: Collection of trained custom models. + :type model_list: + list[~azure.cognitiveservices.formrecognizer.models.ModelInfo] + :param next_link: Link to the next page of custom models. + :type next_link: str + """ + + _attribute_map = { + 'summary': {'key': 'summary', 'type': 'ModelsSummary'}, + 'model_list': {'key': 'modelList', 'type': '[ModelInfo]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ModelsModel, self).__init__(**kwargs) + self.summary = kwargs.get('summary', None) + self.model_list = kwargs.get('model_list', None) + self.next_link = kwargs.get('next_link', None) + + +class ModelsSummary(Model): + """Summary of all trained custom models. + + All required parameters must be populated in order to send to Azure. + + :param count: Required. Current count of trained custom models. + :type count: int + :param limit: Required. Max number of models that can be trained for this + account. + :type limit: int + :param last_updated_date_time: Required. Date and time (UTC) when the + summary was last updated. + :type last_updated_date_time: datetime + """ + + _validation = { + 'count': {'required': True}, + 'limit': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'count': {'key': 'count', 'type': 'int'}, + 'limit': {'key': 'limit', 'type': 'int'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(ModelsSummary, self).__init__(**kwargs) + self.count = kwargs.get('count', None) + self.limit = kwargs.get('limit', None) + self.last_updated_date_time = kwargs.get('last_updated_date_time', None) + + +class PageResult(Model): + """Extracted information from a single page. + + All required parameters must be populated in order to send to Azure. + + :param page: Required. Page number. + :type page: int + :param cluster_id: Cluster identifier. + :type cluster_id: int + :param key_value_pairs: List of key-value pairs extracted from the page. + :type key_value_pairs: + list[~azure.cognitiveservices.formrecognizer.models.KeyValuePair] + :param tables: List of data tables extracted from the page. + :type tables: + list[~azure.cognitiveservices.formrecognizer.models.DataTable] + """ + + _validation = { + 'page': {'required': True, 'minimum': 1}, + 'cluster_id': {'minimum': 0}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'cluster_id': {'key': 'clusterId', 'type': 'int'}, + 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[KeyValuePair]'}, + 'tables': {'key': 'tables', 'type': '[DataTable]'}, + } + + def __init__(self, **kwargs): + super(PageResult, self).__init__(**kwargs) + self.page = kwargs.get('page', None) + self.cluster_id = kwargs.get('cluster_id', None) + self.key_value_pairs = kwargs.get('key_value_pairs', None) + self.tables = kwargs.get('tables', None) + + +class ReadResult(Model): + """Text extracted from a page in the input document. + + All required parameters must be populated in order to send to Azure. + + :param page: Required. The 1-based page number in the input document. + :type page: int + :param angle: Required. The general orientation of the text in clockwise + direction, measured in degrees between (-180, 180]. + :type angle: float + :param width: Required. The width of the image/PDF in pixels/inches, + respectively. + :type width: float + :param height: Required. The height of the image/PDF in pixels/inches, + respectively. + :type height: float + :param unit: Required. The unit used by the width, height and boundingBox + properties. For images, the unit is "pixel". For PDF, the unit is "inch". + Possible values include: 'pixel', 'inch' + :type unit: str or + ~azure.cognitiveservices.formrecognizer.models.LengthUnit + :param language: The detected language on the page overall. Possible + values include: 'en', 'es' + :type language: str or + ~azure.cognitiveservices.formrecognizer.models.Language + :param lines: When includeTextDetails is set to true, a list of recognized + text lines. The maximum number of lines returned is 300 per page. The + lines are sorted top to bottom, left to right, although in certain cases + proximity is treated with higher priority. As the sorting order depends on + the detected text, it may change across images and OCR version updates. + Thus, business logic should be built upon the actual line location instead + of order. + :type lines: list[~azure.cognitiveservices.formrecognizer.models.TextLine] + """ + + _validation = { + 'page': {'required': True, 'minimum': 1}, + 'angle': {'required': True, 'maximum': 180, 'minimum_ex': -180}, + 'width': {'required': True, 'minimum': 0}, + 'height': {'required': True, 'minimum': 0}, + 'unit': {'required': True}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'angle': {'key': 'angle', 'type': 'float'}, + 'width': {'key': 'width', 'type': 'float'}, + 'height': {'key': 'height', 'type': 'float'}, + 'unit': {'key': 'unit', 'type': 'LengthUnit'}, + 'language': {'key': 'language', 'type': 'str'}, + 'lines': {'key': 'lines', 'type': '[TextLine]'}, + } + + def __init__(self, **kwargs): + super(ReadResult, self).__init__(**kwargs) + self.page = kwargs.get('page', None) + self.angle = kwargs.get('angle', None) + self.width = kwargs.get('width', None) + self.height = kwargs.get('height', None) + self.unit = kwargs.get('unit', None) + self.language = kwargs.get('language', None) + self.lines = kwargs.get('lines', None) + + +class SourcePath(Model): + """Uri or local path to source data. + + :param source: File source path. + :type source: str + """ + + _validation = { + 'source': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SourcePath, self).__init__(**kwargs) + self.source = kwargs.get('source', None) + + +class TextLine(Model): + """An object representing an extracted text line. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the line. + :type text: str + :param bounding_box: Required. Bounding box of an extracted line. + :type bounding_box: list[float] + :param language: The detected language of this line, if different from the + overall page language. Possible values include: 'en', 'es' + :type language: str or + ~azure.cognitiveservices.formrecognizer.models.Language + :param words: Required. List of words in the text line. + :type words: list[~azure.cognitiveservices.formrecognizer.models.TextWord] + """ + + _validation = { + 'text': {'required': True}, + 'bounding_box': {'required': True}, + 'words': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'language': {'key': 'language', 'type': 'str'}, + 'words': {'key': 'words', 'type': '[TextWord]'}, + } + + def __init__(self, **kwargs): + super(TextLine, self).__init__(**kwargs) + self.text = kwargs.get('text', None) + self.bounding_box = kwargs.get('bounding_box', None) + self.language = kwargs.get('language', None) + self.words = kwargs.get('words', None) + + +class TextWord(Model): + """An object representing a word. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the word. + :type text: str + :param bounding_box: Required. Bounding box of an extracted word. + :type bounding_box: list[float] + :param confidence: Confidence value. + :type confidence: float + """ + + _validation = { + 'text': {'required': True}, + 'bounding_box': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(TextWord, self).__init__(**kwargs) + self.text = kwargs.get('text', None) + self.bounding_box = kwargs.get('bounding_box', None) + self.confidence = kwargs.get('confidence', None) + + +class TrainingDocumentInfo(Model): + """Report for a custom model training document. + + All required parameters must be populated in order to send to Azure. + + :param document_name: Required. Training document name. + :type document_name: str + :param pages: Required. Total number of pages trained. + :type pages: int + :param errors: Required. List of errors. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + :param status: Required. Status of the training operation. Possible values + include: 'succeeded', 'partiallySucceeded', 'failed' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.TrainStatus + """ + + _validation = { + 'document_name': {'required': True}, + 'pages': {'required': True}, + 'errors': {'required': True}, + 'status': {'required': True}, + } + + _attribute_map = { + 'document_name': {'key': 'documentName', 'type': 'str'}, + 'pages': {'key': 'pages', 'type': 'int'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + 'status': {'key': 'status', 'type': 'TrainStatus'}, + } + + def __init__(self, **kwargs): + super(TrainingDocumentInfo, self).__init__(**kwargs) + self.document_name = kwargs.get('document_name', None) + self.pages = kwargs.get('pages', None) + self.errors = kwargs.get('errors', None) + self.status = kwargs.get('status', None) + + +class TrainRequest(Model): + """Request parameter to train a new custom model. + + All required parameters must be populated in order to send to Azure. + + :param source: Required. Source path containing the training documents. + :type source: str + :param source_filter: Filter to apply to the documents in the source path + for training. + :type source_filter: + ~azure.cognitiveservices.formrecognizer.models.TrainSourceFilter + :param use_label_file: Use label file for training a model. Default value: + False . + :type use_label_file: bool + """ + + _validation = { + 'source': {'required': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + 'source_filter': {'key': 'sourceFilter', 'type': 'TrainSourceFilter'}, + 'use_label_file': {'key': 'useLabelFile', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(TrainRequest, self).__init__(**kwargs) + self.source = kwargs.get('source', None) + self.source_filter = kwargs.get('source_filter', None) + self.use_label_file = kwargs.get('use_label_file', False) + + +class TrainResult(Model): + """Custom model training result. + + All required parameters must be populated in order to send to Azure. + + :param training_documents: Required. List of the documents used to train + the model and any errors reported in each document. + :type training_documents: + list[~azure.cognitiveservices.formrecognizer.models.TrainingDocumentInfo] + :param fields: List of fields used to train the model and the train + operation error reported by each. + :type fields: + list[~azure.cognitiveservices.formrecognizer.models.FormFieldsReport] + :param average_model_accuracy: Average accuracy. + :type average_model_accuracy: float + :param errors: Errors returned during the training operation. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + """ + + _validation = { + 'training_documents': {'required': True}, + } + + _attribute_map = { + 'training_documents': {'key': 'trainingDocuments', 'type': '[TrainingDocumentInfo]'}, + 'fields': {'key': 'fields', 'type': '[FormFieldsReport]'}, + 'average_model_accuracy': {'key': 'averageModelAccuracy', 'type': 'float'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + } + + def __init__(self, **kwargs): + super(TrainResult, self).__init__(**kwargs) + self.training_documents = kwargs.get('training_documents', None) + self.fields = kwargs.get('fields', None) + self.average_model_accuracy = kwargs.get('average_model_accuracy', None) + self.errors = kwargs.get('errors', None) + + +class TrainSourceFilter(Model): + """Filter to apply to the documents in the source path for training. + + :param prefix: A case-sensitive prefix string to filter documents in the + source path for training. For example, when using a Azure storage blob + Uri, use the prefix to restrict sub folders for training. + :type prefix: str + :param include_sub_folders: A flag to indicate if sub folders within the + set of prefix folders will also need to be included when searching for + content to be preprocessed. Default value: False . + :type include_sub_folders: bool + """ + + _validation = { + 'prefix': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'prefix': {'key': 'prefix', 'type': 'str'}, + 'include_sub_folders': {'key': 'includeSubFolders', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(TrainSourceFilter, self).__init__(**kwargs) + self.prefix = kwargs.get('prefix', None) + self.include_sub_folders = kwargs.get('include_sub_folders', False) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models_py3.py new file mode 100644 index 000000000000..be49b44f0f58 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/_models_py3.py @@ -0,0 +1,957 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AnalyzeOperationResult(Model): + """Status and result of the queued analyze operation. + + All required parameters must be populated in order to send to Azure. + + :param status: Required. Operation status. Possible values include: + 'notStarted', 'running', 'succeeded', 'failed' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.OperationStatus + :param created_date_time: Required. Date and time (UTC) when the analyze + operation was submitted. + :type created_date_time: datetime + :param last_updated_date_time: Required. Date and time (UTC) when the + status was last updated. + :type last_updated_date_time: datetime + :param analyze_result: Results of the analyze operation. + :type analyze_result: + ~azure.cognitiveservices.formrecognizer.models.AnalyzeResult + """ + + _validation = { + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'OperationStatus'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResult'}, + } + + def __init__(self, *, status, created_date_time, last_updated_date_time, analyze_result=None, **kwargs) -> None: + super(AnalyzeOperationResult, self).__init__(**kwargs) + self.status = status + self.created_date_time = created_date_time + self.last_updated_date_time = last_updated_date_time + self.analyze_result = analyze_result + + +class AnalyzeResult(Model): + """Analyze operation result. + + All required parameters must be populated in order to send to Azure. + + :param version: Required. Version of schema used for this result. + :type version: str + :param read_results: Required. Text extracted from the input. + :type read_results: + list[~azure.cognitiveservices.formrecognizer.models.ReadResult] + :param page_results: Page-level information extracted from the input. + :type page_results: + list[~azure.cognitiveservices.formrecognizer.models.PageResult] + :param document_results: Document-level information extracted from the + input. + :type document_results: + list[~azure.cognitiveservices.formrecognizer.models.DocumentResult] + :param errors: List of errors reported during the analyze operation. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + """ + + _validation = { + 'version': {'required': True}, + 'read_results': {'required': True}, + } + + _attribute_map = { + 'version': {'key': 'version', 'type': 'str'}, + 'read_results': {'key': 'readResults', 'type': '[ReadResult]'}, + 'page_results': {'key': 'pageResults', 'type': '[PageResult]'}, + 'document_results': {'key': 'documentResults', 'type': '[DocumentResult]'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + } + + def __init__(self, *, version: str, read_results, page_results=None, document_results=None, errors=None, **kwargs) -> None: + super(AnalyzeResult, self).__init__(**kwargs) + self.version = version + self.read_results = read_results + self.page_results = page_results + self.document_results = document_results + self.errors = errors + + +class DataTable(Model): + """Information about the extracted table contained in a page. + + All required parameters must be populated in order to send to Azure. + + :param rows: Required. Number of rows. + :type rows: int + :param columns: Required. Number of columns. + :type columns: int + :param cells: Required. List of cells contained in the table. + :type cells: + list[~azure.cognitiveservices.formrecognizer.models.DataTableCell] + """ + + _validation = { + 'rows': {'required': True, 'minimum': 1}, + 'columns': {'required': True, 'minimum': 1}, + 'cells': {'required': True}, + } + + _attribute_map = { + 'rows': {'key': 'rows', 'type': 'int'}, + 'columns': {'key': 'columns', 'type': 'int'}, + 'cells': {'key': 'cells', 'type': '[DataTableCell]'}, + } + + def __init__(self, *, rows: int, columns: int, cells, **kwargs) -> None: + super(DataTable, self).__init__(**kwargs) + self.rows = rows + self.columns = columns + self.cells = cells + + +class DataTableCell(Model): + """Information about the extracted cell in a table. + + All required parameters must be populated in order to send to Azure. + + :param row_index: Required. Row index of the cell. + :type row_index: int + :param column_index: Required. Column index of the cell. + :type column_index: int + :param row_span: Number of rows spanned by this cell. Default value: 1 . + :type row_span: int + :param column_span: Number of columns spanned by this cell. Default value: + 1 . + :type column_span: int + :param text: Required. Text content of the cell. + :type text: str + :param bounding_box: Required. Bounding box of the cell. + :type bounding_box: list[float] + :param confidence: Required. Confidence value. + :type confidence: float + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this table cell. + :type elements: list[str] + :param is_header: Is the current cell a header cell?. Default value: False + . + :type is_header: bool + :param is_footer: Is the current cell a footer cell?. Default value: False + . + :type is_footer: bool + """ + + _validation = { + 'row_index': {'required': True, 'minimum': 0}, + 'column_index': {'required': True, 'minimum': 0}, + 'row_span': {'minimum': 1}, + 'column_span': {'minimum': 1}, + 'text': {'required': True}, + 'bounding_box': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'row_index': {'key': 'rowIndex', 'type': 'int'}, + 'column_index': {'key': 'columnIndex', 'type': 'int'}, + 'row_span': {'key': 'rowSpan', 'type': 'int'}, + 'column_span': {'key': 'columnSpan', 'type': 'int'}, + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + 'is_header': {'key': 'isHeader', 'type': 'bool'}, + 'is_footer': {'key': 'isFooter', 'type': 'bool'}, + } + + def __init__(self, *, row_index: int, column_index: int, text: str, bounding_box, confidence: float, row_span: int=1, column_span: int=1, elements=None, is_header: bool=False, is_footer: bool=False, **kwargs) -> None: + super(DataTableCell, self).__init__(**kwargs) + self.row_index = row_index + self.column_index = column_index + self.row_span = row_span + self.column_span = column_span + self.text = text + self.bounding_box = bounding_box + self.confidence = confidence + self.elements = elements + self.is_header = is_header + self.is_footer = is_footer + + +class DocumentResult(Model): + """A set of extracted fields corresponding to the input document. + + All required parameters must be populated in order to send to Azure. + + :param doc_type: Required. Document type. + :type doc_type: str + :param page_range: Required. First and last page number where the document + is found. + :type page_range: list[int] + :param fields: Required. Dictionary of named field values. + :type fields: dict[str, + ~azure.cognitiveservices.formrecognizer.models.FieldValue] + """ + + _validation = { + 'doc_type': {'required': True}, + 'page_range': {'required': True, 'max_items': 2, 'min_items': 2}, + 'fields': {'required': True}, + } + + _attribute_map = { + 'doc_type': {'key': 'docType', 'type': 'str'}, + 'page_range': {'key': 'pageRange', 'type': '[int]'}, + 'fields': {'key': 'fields', 'type': '{FieldValue}'}, + } + + def __init__(self, *, doc_type: str, page_range, fields, **kwargs) -> None: + super(DocumentResult, self).__init__(**kwargs) + self.doc_type = doc_type + self.page_range = page_range + self.fields = fields + + +class ErrorInformation(Model): + """ErrorInformation. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. + :type code: str + :param message: Required. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str, message: str, **kwargs) -> None: + super(ErrorInformation, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponse(Model): + """ErrorResponse. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. + :type error: + ~azure.cognitiveservices.formrecognizer.models.ErrorInformation + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorInformation'}, + } + + def __init__(self, *, error, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class FieldValue(Model): + """Recognized field value. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Type of field value. Possible values include: + 'string', 'date', 'time', 'phoneNumber', 'number', 'integer', 'array', + 'object' + :type type: str or + ~azure.cognitiveservices.formrecognizer.models.FieldValueType + :param value_string: String value. + :type value_string: str + :param value_date: Date value. + :type value_date: date + :param value_time: Time value. + :type value_time: str + :param value_phone_number: Phone number value. + :type value_phone_number: str + :param value_number: Floating point value. + :type value_number: float + :param value_integer: Integer value. + :type value_integer: int + :param value_array: Array of field values. + :type value_array: + list[~azure.cognitiveservices.formrecognizer.models.FieldValue] + :param value_object: Dictionary of named field values. + :type value_object: dict[str, + ~azure.cognitiveservices.formrecognizer.models.FieldValue] + :param text: Text content of the extracted field. + :type text: str + :param bounding_box: Bounding box of the field value, if appropriate. + :type bounding_box: list[float] + :param confidence: Confidence score. + :type confidence: float + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this field. + :type elements: list[str] + :param page: The 1-based page number in the input document. + :type page: int + """ + + _validation = { + 'type': {'required': True}, + 'page': {'minimum': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'FieldValueType'}, + 'value_string': {'key': 'valueString', 'type': 'str'}, + 'value_date': {'key': 'valueDate', 'type': 'date'}, + 'value_time': {'key': 'valueTime', 'type': 'str'}, + 'value_phone_number': {'key': 'valuePhoneNumber', 'type': 'str'}, + 'value_number': {'key': 'valueNumber', 'type': 'float'}, + 'value_integer': {'key': 'valueInteger', 'type': 'int'}, + 'value_array': {'key': 'valueArray', 'type': '[FieldValue]'}, + 'value_object': {'key': 'valueObject', 'type': '{FieldValue}'}, + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + 'page': {'key': 'page', 'type': 'int'}, + } + + def __init__(self, *, type, value_string: str=None, value_date=None, value_time: str=None, value_phone_number: str=None, value_number: float=None, value_integer: int=None, value_array=None, value_object=None, text: str=None, bounding_box=None, confidence: float=None, elements=None, page: int=None, **kwargs) -> None: + super(FieldValue, self).__init__(**kwargs) + self.type = type + self.value_string = value_string + self.value_date = value_date + self.value_time = value_time + self.value_phone_number = value_phone_number + self.value_number = value_number + self.value_integer = value_integer + self.value_array = value_array + self.value_object = value_object + self.text = text + self.bounding_box = bounding_box + self.confidence = confidence + self.elements = elements + self.page = page + + +class FormFieldsReport(Model): + """Report for a custom model training field. + + All required parameters must be populated in order to send to Azure. + + :param field_name: Required. Training field name. + :type field_name: str + :param accuracy: Required. Estimated extraction accuracy for this field. + :type accuracy: float + """ + + _validation = { + 'field_name': {'required': True}, + 'accuracy': {'required': True}, + } + + _attribute_map = { + 'field_name': {'key': 'fieldName', 'type': 'str'}, + 'accuracy': {'key': 'accuracy', 'type': 'float'}, + } + + def __init__(self, *, field_name: str, accuracy: float, **kwargs) -> None: + super(FormFieldsReport, self).__init__(**kwargs) + self.field_name = field_name + self.accuracy = accuracy + + +class KeysResult(Model): + """Keys extracted by the custom model. + + All required parameters must be populated in order to send to Azure. + + :param clusters: Required. Object mapping clusterIds to a list of keys. + :type clusters: dict[str, list[str]] + """ + + _validation = { + 'clusters': {'required': True}, + } + + _attribute_map = { + 'clusters': {'key': 'clusters', 'type': '{[str]}'}, + } + + def __init__(self, *, clusters, **kwargs) -> None: + super(KeysResult, self).__init__(**kwargs) + self.clusters = clusters + + +class KeyValueElement(Model): + """Information about the extracted key or value in a key-value pair. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the key or value. + :type text: str + :param bounding_box: Bounding box of the key or value. + :type bounding_box: list[float] + :param elements: When includeTextDetails is set to true, a list of + references to the text elements constituting this key or value. + :type elements: list[str] + """ + + _validation = { + 'text': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'elements': {'key': 'elements', 'type': '[str]'}, + } + + def __init__(self, *, text: str, bounding_box=None, elements=None, **kwargs) -> None: + super(KeyValueElement, self).__init__(**kwargs) + self.text = text + self.bounding_box = bounding_box + self.elements = elements + + +class KeyValuePair(Model): + """Information about the extracted key-value pair. + + All required parameters must be populated in order to send to Azure. + + :param label: A user defined label for the key/value pair entry. + :type label: str + :param key: Required. Information about the extracted key in a key-value + pair. + :type key: ~azure.cognitiveservices.formrecognizer.models.KeyValueElement + :param value: Required. Information about the extracted value in a + key-value pair. + :type value: + ~azure.cognitiveservices.formrecognizer.models.KeyValueElement + :param confidence: Required. Confidence value. + :type confidence: float + """ + + _validation = { + 'key': {'required': True}, + 'value': {'required': True}, + 'confidence': {'required': True}, + } + + _attribute_map = { + 'label': {'key': 'label', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'KeyValueElement'}, + 'value': {'key': 'value', 'type': 'KeyValueElement'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, key, value, confidence: float, label: str=None, **kwargs) -> None: + super(KeyValuePair, self).__init__(**kwargs) + self.label = label + self.key = key + self.value = value + self.confidence = confidence + + +class Model(Model): + """Response to the get custom model operation. + + All required parameters must be populated in order to send to Azure. + + :param model_info: Required. + :type model_info: ~azure.cognitiveservices.formrecognizer.models.ModelInfo + :param keys: + :type keys: ~azure.cognitiveservices.formrecognizer.models.KeysResult + :param train_result: + :type train_result: + ~azure.cognitiveservices.formrecognizer.models.TrainResult + """ + + _validation = { + 'model_info': {'required': True}, + } + + _attribute_map = { + 'model_info': {'key': 'modelInfo', 'type': 'ModelInfo'}, + 'keys': {'key': 'keys', 'type': 'KeysResult'}, + 'train_result': {'key': 'trainResult', 'type': 'TrainResult'}, + } + + def __init__(self, *, model_info, keys=None, train_result=None, **kwargs) -> None: + super(Model, self).__init__(**kwargs) + self.model_info = model_info + self.keys = keys + self.train_result = train_result + + +class ModelInfo(Model): + """Basic custom model information. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param status: Required. Status of the model. Possible values include: + 'creating', 'ready', 'invalid' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.ModelStatus + :param created_date_time: Required. Date and time (UTC) when the model was + created. + :type created_date_time: datetime + :param last_updated_date_time: Required. Date and time (UTC) when the + status was last updated. + :type last_updated_date_time: datetime + """ + + _validation = { + 'model_id': {'required': True}, + 'status': {'required': True}, + 'created_date_time': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, model_id: str, status, created_date_time, last_updated_date_time, **kwargs) -> None: + super(ModelInfo, self).__init__(**kwargs) + self.model_id = model_id + self.status = status + self.created_date_time = created_date_time + self.last_updated_date_time = last_updated_date_time + + +class ModelsModel(Model): + """Response to the list custom models operation. + + :param summary: Summary of all trained custom models. + :type summary: + ~azure.cognitiveservices.formrecognizer.models.ModelsSummary + :param model_list: Collection of trained custom models. + :type model_list: + list[~azure.cognitiveservices.formrecognizer.models.ModelInfo] + :param next_link: Link to the next page of custom models. + :type next_link: str + """ + + _attribute_map = { + 'summary': {'key': 'summary', 'type': 'ModelsSummary'}, + 'model_list': {'key': 'modelList', 'type': '[ModelInfo]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, summary=None, model_list=None, next_link: str=None, **kwargs) -> None: + super(ModelsModel, self).__init__(**kwargs) + self.summary = summary + self.model_list = model_list + self.next_link = next_link + + +class ModelsSummary(Model): + """Summary of all trained custom models. + + All required parameters must be populated in order to send to Azure. + + :param count: Required. Current count of trained custom models. + :type count: int + :param limit: Required. Max number of models that can be trained for this + account. + :type limit: int + :param last_updated_date_time: Required. Date and time (UTC) when the + summary was last updated. + :type last_updated_date_time: datetime + """ + + _validation = { + 'count': {'required': True}, + 'limit': {'required': True}, + 'last_updated_date_time': {'required': True}, + } + + _attribute_map = { + 'count': {'key': 'count', 'type': 'int'}, + 'limit': {'key': 'limit', 'type': 'int'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, count: int, limit: int, last_updated_date_time, **kwargs) -> None: + super(ModelsSummary, self).__init__(**kwargs) + self.count = count + self.limit = limit + self.last_updated_date_time = last_updated_date_time + + +class PageResult(Model): + """Extracted information from a single page. + + All required parameters must be populated in order to send to Azure. + + :param page: Required. Page number. + :type page: int + :param cluster_id: Cluster identifier. + :type cluster_id: int + :param key_value_pairs: List of key-value pairs extracted from the page. + :type key_value_pairs: + list[~azure.cognitiveservices.formrecognizer.models.KeyValuePair] + :param tables: List of data tables extracted from the page. + :type tables: + list[~azure.cognitiveservices.formrecognizer.models.DataTable] + """ + + _validation = { + 'page': {'required': True, 'minimum': 1}, + 'cluster_id': {'minimum': 0}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'cluster_id': {'key': 'clusterId', 'type': 'int'}, + 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[KeyValuePair]'}, + 'tables': {'key': 'tables', 'type': '[DataTable]'}, + } + + def __init__(self, *, page: int, cluster_id: int=None, key_value_pairs=None, tables=None, **kwargs) -> None: + super(PageResult, self).__init__(**kwargs) + self.page = page + self.cluster_id = cluster_id + self.key_value_pairs = key_value_pairs + self.tables = tables + + +class ReadResult(Model): + """Text extracted from a page in the input document. + + All required parameters must be populated in order to send to Azure. + + :param page: Required. The 1-based page number in the input document. + :type page: int + :param angle: Required. The general orientation of the text in clockwise + direction, measured in degrees between (-180, 180]. + :type angle: float + :param width: Required. The width of the image/PDF in pixels/inches, + respectively. + :type width: float + :param height: Required. The height of the image/PDF in pixels/inches, + respectively. + :type height: float + :param unit: Required. The unit used by the width, height and boundingBox + properties. For images, the unit is "pixel". For PDF, the unit is "inch". + Possible values include: 'pixel', 'inch' + :type unit: str or + ~azure.cognitiveservices.formrecognizer.models.LengthUnit + :param language: The detected language on the page overall. Possible + values include: 'en', 'es' + :type language: str or + ~azure.cognitiveservices.formrecognizer.models.Language + :param lines: When includeTextDetails is set to true, a list of recognized + text lines. The maximum number of lines returned is 300 per page. The + lines are sorted top to bottom, left to right, although in certain cases + proximity is treated with higher priority. As the sorting order depends on + the detected text, it may change across images and OCR version updates. + Thus, business logic should be built upon the actual line location instead + of order. + :type lines: list[~azure.cognitiveservices.formrecognizer.models.TextLine] + """ + + _validation = { + 'page': {'required': True, 'minimum': 1}, + 'angle': {'required': True, 'maximum': 180, 'minimum_ex': -180}, + 'width': {'required': True, 'minimum': 0}, + 'height': {'required': True, 'minimum': 0}, + 'unit': {'required': True}, + } + + _attribute_map = { + 'page': {'key': 'page', 'type': 'int'}, + 'angle': {'key': 'angle', 'type': 'float'}, + 'width': {'key': 'width', 'type': 'float'}, + 'height': {'key': 'height', 'type': 'float'}, + 'unit': {'key': 'unit', 'type': 'LengthUnit'}, + 'language': {'key': 'language', 'type': 'str'}, + 'lines': {'key': 'lines', 'type': '[TextLine]'}, + } + + def __init__(self, *, page: int, angle: float, width: float, height: float, unit, language=None, lines=None, **kwargs) -> None: + super(ReadResult, self).__init__(**kwargs) + self.page = page + self.angle = angle + self.width = width + self.height = height + self.unit = unit + self.language = language + self.lines = lines + + +class SourcePath(Model): + """Uri or local path to source data. + + :param source: File source path. + :type source: str + """ + + _validation = { + 'source': {'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + } + + def __init__(self, *, source: str=None, **kwargs) -> None: + super(SourcePath, self).__init__(**kwargs) + self.source = source + + +class TextLine(Model): + """An object representing an extracted text line. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the line. + :type text: str + :param bounding_box: Required. Bounding box of an extracted line. + :type bounding_box: list[float] + :param language: The detected language of this line, if different from the + overall page language. Possible values include: 'en', 'es' + :type language: str or + ~azure.cognitiveservices.formrecognizer.models.Language + :param words: Required. List of words in the text line. + :type words: list[~azure.cognitiveservices.formrecognizer.models.TextWord] + """ + + _validation = { + 'text': {'required': True}, + 'bounding_box': {'required': True}, + 'words': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'language': {'key': 'language', 'type': 'str'}, + 'words': {'key': 'words', 'type': '[TextWord]'}, + } + + def __init__(self, *, text: str, bounding_box, words, language=None, **kwargs) -> None: + super(TextLine, self).__init__(**kwargs) + self.text = text + self.bounding_box = bounding_box + self.language = language + self.words = words + + +class TextWord(Model): + """An object representing a word. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The text content of the word. + :type text: str + :param bounding_box: Required. Bounding box of an extracted word. + :type bounding_box: list[float] + :param confidence: Confidence value. + :type confidence: float + """ + + _validation = { + 'text': {'required': True}, + 'bounding_box': {'required': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, text: str, bounding_box, confidence: float=None, **kwargs) -> None: + super(TextWord, self).__init__(**kwargs) + self.text = text + self.bounding_box = bounding_box + self.confidence = confidence + + +class TrainingDocumentInfo(Model): + """Report for a custom model training document. + + All required parameters must be populated in order to send to Azure. + + :param document_name: Required. Training document name. + :type document_name: str + :param pages: Required. Total number of pages trained. + :type pages: int + :param errors: Required. List of errors. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + :param status: Required. Status of the training operation. Possible values + include: 'succeeded', 'partiallySucceeded', 'failed' + :type status: str or + ~azure.cognitiveservices.formrecognizer.models.TrainStatus + """ + + _validation = { + 'document_name': {'required': True}, + 'pages': {'required': True}, + 'errors': {'required': True}, + 'status': {'required': True}, + } + + _attribute_map = { + 'document_name': {'key': 'documentName', 'type': 'str'}, + 'pages': {'key': 'pages', 'type': 'int'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + 'status': {'key': 'status', 'type': 'TrainStatus'}, + } + + def __init__(self, *, document_name: str, pages: int, errors, status, **kwargs) -> None: + super(TrainingDocumentInfo, self).__init__(**kwargs) + self.document_name = document_name + self.pages = pages + self.errors = errors + self.status = status + + +class TrainRequest(Model): + """Request parameter to train a new custom model. + + All required parameters must be populated in order to send to Azure. + + :param source: Required. Source path containing the training documents. + :type source: str + :param source_filter: Filter to apply to the documents in the source path + for training. + :type source_filter: + ~azure.cognitiveservices.formrecognizer.models.TrainSourceFilter + :param use_label_file: Use label file for training a model. Default value: + False . + :type use_label_file: bool + """ + + _validation = { + 'source': {'required': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + 'source_filter': {'key': 'sourceFilter', 'type': 'TrainSourceFilter'}, + 'use_label_file': {'key': 'useLabelFile', 'type': 'bool'}, + } + + def __init__(self, *, source: str, source_filter=None, use_label_file: bool=False, **kwargs) -> None: + super(TrainRequest, self).__init__(**kwargs) + self.source = source + self.source_filter = source_filter + self.use_label_file = use_label_file + + +class TrainResult(Model): + """Custom model training result. + + All required parameters must be populated in order to send to Azure. + + :param training_documents: Required. List of the documents used to train + the model and any errors reported in each document. + :type training_documents: + list[~azure.cognitiveservices.formrecognizer.models.TrainingDocumentInfo] + :param fields: List of fields used to train the model and the train + operation error reported by each. + :type fields: + list[~azure.cognitiveservices.formrecognizer.models.FormFieldsReport] + :param average_model_accuracy: Average accuracy. + :type average_model_accuracy: float + :param errors: Errors returned during the training operation. + :type errors: + list[~azure.cognitiveservices.formrecognizer.models.ErrorInformation] + """ + + _validation = { + 'training_documents': {'required': True}, + } + + _attribute_map = { + 'training_documents': {'key': 'trainingDocuments', 'type': '[TrainingDocumentInfo]'}, + 'fields': {'key': 'fields', 'type': '[FormFieldsReport]'}, + 'average_model_accuracy': {'key': 'averageModelAccuracy', 'type': 'float'}, + 'errors': {'key': 'errors', 'type': '[ErrorInformation]'}, + } + + def __init__(self, *, training_documents, fields=None, average_model_accuracy: float=None, errors=None, **kwargs) -> None: + super(TrainResult, self).__init__(**kwargs) + self.training_documents = training_documents + self.fields = fields + self.average_model_accuracy = average_model_accuracy + self.errors = errors + + +class TrainSourceFilter(Model): + """Filter to apply to the documents in the source path for training. + + :param prefix: A case-sensitive prefix string to filter documents in the + source path for training. For example, when using a Azure storage blob + Uri, use the prefix to restrict sub folders for training. + :type prefix: str + :param include_sub_folders: A flag to indicate if sub folders within the + set of prefix folders will also need to be included when searching for + content to be preprocessed. Default value: False . + :type include_sub_folders: bool + """ + + _validation = { + 'prefix': {'max_length': 1024, 'min_length': 0}, + } + + _attribute_map = { + 'prefix': {'key': 'prefix', 'type': 'str'}, + 'include_sub_folders': {'key': 'includeSubFolders', 'type': 'bool'}, + } + + def __init__(self, *, prefix: str=None, include_sub_folders: bool=False, **kwargs) -> None: + super(TrainSourceFilter, self).__init__(**kwargs) + self.prefix = prefix + self.include_sub_folders = include_sub_folders diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result.py deleted file mode 100644 index bdbb2ea70d4b..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class AnalyzeResult(Model): - """Analyze API call result. - - :param status: Status of the analyze operation. Possible values include: - 'success', 'partialSuccess', 'failure' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - :param pages: Page level information extracted in the analyzed - document. - :type pages: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedPage] - :param errors: List of errors reported during the analyze - operation. - :type errors: - list[~azure.cognitiveservices.formrecognizer.models.FormOperationError] - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': '[ExtractedPage]'}, - 'errors': {'key': 'errors', 'type': '[FormOperationError]'}, - } - - def __init__(self, **kwargs): - super(AnalyzeResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.pages = kwargs.get('pages', None) - self.errors = kwargs.get('errors', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result_py3.py deleted file mode 100644 index 37a061efc106..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/analyze_result_py3.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class AnalyzeResult(Model): - """Analyze API call result. - - :param status: Status of the analyze operation. Possible values include: - 'success', 'partialSuccess', 'failure' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - :param pages: Page level information extracted in the analyzed - document. - :type pages: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedPage] - :param errors: List of errors reported during the analyze - operation. - :type errors: - list[~azure.cognitiveservices.formrecognizer.models.FormOperationError] - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': '[ExtractedPage]'}, - 'errors': {'key': 'errors', 'type': '[FormOperationError]'}, - } - - def __init__(self, *, status=None, pages=None, errors=None, **kwargs) -> None: - super(AnalyzeResult, self).__init__(**kwargs) - self.status = status - self.pages = pages - self.errors = errors diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information.py deleted file mode 100644 index 00349ae06374..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ErrorInformation(Model): - """ErrorInformation. - - :param code: - :type code: str - :param inner_error: - :type inner_error: - ~azure.cognitiveservices.formrecognizer.models.InnerError - :param message: - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ErrorInformation, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.inner_error = kwargs.get('inner_error', None) - self.message = kwargs.get('message', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information_py3.py deleted file mode 100644 index d45c61027540..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_information_py3.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ErrorInformation(Model): - """ErrorInformation. - - :param code: - :type code: str - :param inner_error: - :type inner_error: - ~azure.cognitiveservices.formrecognizer.models.InnerError - :param message: - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__(self, *, code: str=None, inner_error=None, message: str=None, **kwargs) -> None: - super(ErrorInformation, self).__init__(**kwargs) - self.code = code - self.inner_error = inner_error - self.message = message diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response.py deleted file mode 100644 index 3fa6860416f3..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError - - -class ErrorResponse(Model): - """ErrorResponse. - - :param error: - :type error: - ~azure.cognitiveservices.formrecognizer.models.ErrorInformation - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorInformation'}, - } - - def __init__(self, **kwargs): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response_py3.py deleted file mode 100644 index dfbb3323b825..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/error_response_py3.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError - - -class ErrorResponse(Model): - """ErrorResponse. - - :param error: - :type error: - ~azure.cognitiveservices.formrecognizer.models.ErrorInformation - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorInformation'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair.py deleted file mode 100644 index ec7eeed9710a..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedKeyValuePair(Model): - """Representation of a key-value pair as a list - of key and value tokens. - - :param key: List of tokens for the extracted key in a key-value pair. - :type key: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - :param value: List of tokens for the extracted value in a key-value pair. - :type value: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - """ - - _attribute_map = { - 'key': {'key': 'key', 'type': '[ExtractedToken]'}, - 'value': {'key': 'value', 'type': '[ExtractedToken]'}, - } - - def __init__(self, **kwargs): - super(ExtractedKeyValuePair, self).__init__(**kwargs) - self.key = kwargs.get('key', None) - self.value = kwargs.get('value', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair_py3.py deleted file mode 100644 index e1c1984f463c..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_key_value_pair_py3.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedKeyValuePair(Model): - """Representation of a key-value pair as a list - of key and value tokens. - - :param key: List of tokens for the extracted key in a key-value pair. - :type key: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - :param value: List of tokens for the extracted value in a key-value pair. - :type value: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - """ - - _attribute_map = { - 'key': {'key': 'key', 'type': '[ExtractedToken]'}, - 'value': {'key': 'value', 'type': '[ExtractedToken]'}, - } - - def __init__(self, *, key=None, value=None, **kwargs) -> None: - super(ExtractedKeyValuePair, self).__init__(**kwargs) - self.key = key - self.value = value diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page.py deleted file mode 100644 index 8c330dc51983..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedPage(Model): - """Extraction information of a single page in a - with a document. - - :param number: Page number. - :type number: int - :param height: Height of the page (in pixels). - :type height: int - :param width: Width of the page (in pixels). - :type width: int - :param cluster_id: Cluster identifier. - :type cluster_id: int - :param key_value_pairs: List of Key-Value pairs extracted from the page. - :type key_value_pairs: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedKeyValuePair] - :param tables: List of Tables and their information extracted from the - page. - :type tables: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedTable] - """ - - _attribute_map = { - 'number': {'key': 'number', 'type': 'int'}, - 'height': {'key': 'height', 'type': 'int'}, - 'width': {'key': 'width', 'type': 'int'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[ExtractedKeyValuePair]'}, - 'tables': {'key': 'tables', 'type': '[ExtractedTable]'}, - } - - def __init__(self, **kwargs): - super(ExtractedPage, self).__init__(**kwargs) - self.number = kwargs.get('number', None) - self.height = kwargs.get('height', None) - self.width = kwargs.get('width', None) - self.cluster_id = kwargs.get('cluster_id', None) - self.key_value_pairs = kwargs.get('key_value_pairs', None) - self.tables = kwargs.get('tables', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page_py3.py deleted file mode 100644 index a207800c968e..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_page_py3.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedPage(Model): - """Extraction information of a single page in a - with a document. - - :param number: Page number. - :type number: int - :param height: Height of the page (in pixels). - :type height: int - :param width: Width of the page (in pixels). - :type width: int - :param cluster_id: Cluster identifier. - :type cluster_id: int - :param key_value_pairs: List of Key-Value pairs extracted from the page. - :type key_value_pairs: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedKeyValuePair] - :param tables: List of Tables and their information extracted from the - page. - :type tables: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedTable] - """ - - _attribute_map = { - 'number': {'key': 'number', 'type': 'int'}, - 'height': {'key': 'height', 'type': 'int'}, - 'width': {'key': 'width', 'type': 'int'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[ExtractedKeyValuePair]'}, - 'tables': {'key': 'tables', 'type': '[ExtractedTable]'}, - } - - def __init__(self, *, number: int=None, height: int=None, width: int=None, cluster_id: int=None, key_value_pairs=None, tables=None, **kwargs) -> None: - super(ExtractedPage, self).__init__(**kwargs) - self.number = number - self.height = height - self.width = width - self.cluster_id = cluster_id - self.key_value_pairs = key_value_pairs - self.tables = tables diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table.py deleted file mode 100644 index ab8d1781fc5a..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedTable(Model): - """Extraction information about a table - contained in a page. - - :param id: Table identifier. - :type id: str - :param columns: List of columns contained in the table. - :type columns: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedTableColumn] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'columns': {'key': 'columns', 'type': '[ExtractedTableColumn]'}, - } - - def __init__(self, **kwargs): - super(ExtractedTable, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.columns = kwargs.get('columns', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column.py deleted file mode 100644 index e1633e91cbfe..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedTableColumn(Model): - """Extraction information of a column in - a table. - - :param header: List of extracted tokens for the column header. - :type header: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - :param entries: Extracted text for each cell of a column. Each cell - in the column can have a list of one or more tokens. - :type entries: - list[list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken]] - """ - - _attribute_map = { - 'header': {'key': 'header', 'type': '[ExtractedToken]'}, - 'entries': {'key': 'entries', 'type': '[[ExtractedToken]]'}, - } - - def __init__(self, **kwargs): - super(ExtractedTableColumn, self).__init__(**kwargs) - self.header = kwargs.get('header', None) - self.entries = kwargs.get('entries', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column_py3.py deleted file mode 100644 index 38cf4113cee1..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_column_py3.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedTableColumn(Model): - """Extraction information of a column in - a table. - - :param header: List of extracted tokens for the column header. - :type header: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken] - :param entries: Extracted text for each cell of a column. Each cell - in the column can have a list of one or more tokens. - :type entries: - list[list[~azure.cognitiveservices.formrecognizer.models.ExtractedToken]] - """ - - _attribute_map = { - 'header': {'key': 'header', 'type': '[ExtractedToken]'}, - 'entries': {'key': 'entries', 'type': '[[ExtractedToken]]'}, - } - - def __init__(self, *, header=None, entries=None, **kwargs) -> None: - super(ExtractedTableColumn, self).__init__(**kwargs) - self.header = header - self.entries = entries diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_py3.py deleted file mode 100644 index 2a4bcbdba728..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_table_py3.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedTable(Model): - """Extraction information about a table - contained in a page. - - :param id: Table identifier. - :type id: str - :param columns: List of columns contained in the table. - :type columns: - list[~azure.cognitiveservices.formrecognizer.models.ExtractedTableColumn] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'columns': {'key': 'columns', 'type': '[ExtractedTableColumn]'}, - } - - def __init__(self, *, id: str=None, columns=None, **kwargs) -> None: - super(ExtractedTable, self).__init__(**kwargs) - self.id = id - self.columns = columns diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token.py deleted file mode 100644 index 33edf3c69c7d..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedToken(Model): - """Canonical representation of single extracted text. - - :param text: String value of the extracted text. - :type text: str - :param bounding_box: Bounding box of the extracted text. Represents the - location of the extracted text as a pair of - cartesian co-ordinates. The co-ordinate pairs are arranged by - top-left, top-right, bottom-right and bottom-left endpoints box - with origin reference from the bottom-left of the page. - :type bounding_box: list[float] - :param confidence: A measure of accuracy of the extracted text. - :type confidence: float - """ - - _attribute_map = { - 'text': {'key': 'text', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__(self, **kwargs): - super(ExtractedToken, self).__init__(**kwargs) - self.text = kwargs.get('text', None) - self.bounding_box = kwargs.get('bounding_box', None) - self.confidence = kwargs.get('confidence', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token_py3.py deleted file mode 100644 index 400013ae29a6..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/extracted_token_py3.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ExtractedToken(Model): - """Canonical representation of single extracted text. - - :param text: String value of the extracted text. - :type text: str - :param bounding_box: Bounding box of the extracted text. Represents the - location of the extracted text as a pair of - cartesian co-ordinates. The co-ordinate pairs are arranged by - top-left, top-right, bottom-right and bottom-left endpoints box - with origin reference from the bottom-left of the page. - :type bounding_box: list[float] - :param confidence: A measure of accuracy of the extracted text. - :type confidence: float - """ - - _attribute_map = { - 'text': {'key': 'text', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__(self, *, text: str=None, bounding_box=None, confidence: float=None, **kwargs) -> None: - super(ExtractedToken, self).__init__(**kwargs) - self.text = text - self.bounding_box = bounding_box - self.confidence = confidence diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report.py deleted file mode 100644 index eaa6a888e732..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class FormDocumentReport(Model): - """FormDocumentReport. - - :param document_name: Reference to the data that the report is for. - :type document_name: str - :param pages: Total number of pages trained on. - :type pages: int - :param errors: List of errors per page. - :type errors: list[str] - :param status: Status of the training operation. Possible values include: - 'success', 'partialSuccess', 'failure' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - """ - - _attribute_map = { - 'document_name': {'key': 'documentName', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': 'int'}, - 'errors': {'key': 'errors', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(FormDocumentReport, self).__init__(**kwargs) - self.document_name = kwargs.get('document_name', None) - self.pages = kwargs.get('pages', None) - self.errors = kwargs.get('errors', None) - self.status = kwargs.get('status', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report_py3.py deleted file mode 100644 index c28ccd6f95fa..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_document_report_py3.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class FormDocumentReport(Model): - """FormDocumentReport. - - :param document_name: Reference to the data that the report is for. - :type document_name: str - :param pages: Total number of pages trained on. - :type pages: int - :param errors: List of errors per page. - :type errors: list[str] - :param status: Status of the training operation. Possible values include: - 'success', 'partialSuccess', 'failure' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - """ - - _attribute_map = { - 'document_name': {'key': 'documentName', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': 'int'}, - 'errors': {'key': 'errors', 'type': '[str]'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__(self, *, document_name: str=None, pages: int=None, errors=None, status=None, **kwargs) -> None: - super(FormDocumentReport, self).__init__(**kwargs) - self.document_name = document_name - self.pages = pages - self.errors = errors - self.status = status diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error.py deleted file mode 100644 index d73b7f8101e7..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class FormOperationError(Model): - """Error reported during an operation. - - :param error_message: Message reported during the train operation. - :type error_message: str - """ - - _attribute_map = { - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(FormOperationError, self).__init__(**kwargs) - self.error_message = kwargs.get('error_message', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error_py3.py deleted file mode 100644 index 1735f168271d..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/form_operation_error_py3.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class FormOperationError(Model): - """Error reported during an operation. - - :param error_message: Message reported during the train operation. - :type error_message: str - """ - - _attribute_map = { - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - } - - def __init__(self, *, error_message: str=None, **kwargs) -> None: - super(FormOperationError, self).__init__(**kwargs) - self.error_message = error_message diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error_py3.py deleted file mode 100644 index 018aab0362b7..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error_py3.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class InnerError(Model): - """InnerError. - - :param request_id: - :type request_id: str - """ - - _attribute_map = { - 'request_id': {'key': 'requestId', 'type': 'str'}, - } - - def __init__(self, *, request_id: str=None, **kwargs) -> None: - super(InnerError, self).__init__(**kwargs) - self.request_id = request_id diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result.py deleted file mode 100644 index 72cde6beb9e2..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class KeysResult(Model): - """Result of an operation to get - the keys extracted by a model. - - :param clusters: Object mapping ClusterIds to Key lists. - :type clusters: dict[str, list[str]] - """ - - _attribute_map = { - 'clusters': {'key': 'clusters', 'type': '{[str]}'}, - } - - def __init__(self, **kwargs): - super(KeysResult, self).__init__(**kwargs) - self.clusters = kwargs.get('clusters', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result_py3.py deleted file mode 100644 index 493c8d6743bf..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/keys_result_py3.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class KeysResult(Model): - """Result of an operation to get - the keys extracted by a model. - - :param clusters: Object mapping ClusterIds to Key lists. - :type clusters: dict[str, list[str]] - """ - - _attribute_map = { - 'clusters': {'key': 'clusters', 'type': '{[str]}'}, - } - - def __init__(self, *, clusters=None, **kwargs) -> None: - super(KeysResult, self).__init__(**kwargs) - self.clusters = clusters diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result.py deleted file mode 100644 index 2debe9430acb..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ModelResult(Model): - """Result of a model status query operation. - - :param model_id: Get or set model identifier. - :type model_id: str - :param status: Get or set the status of model. Possible values include: - 'created', 'ready', 'invalid' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - :param created_date_time: Get or set the created date time of the model. - :type created_date_time: datetime - :param last_updated_date_time: Get or set the model last updated datetime. - :type last_updated_date_time: datetime - """ - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - } - - def __init__(self, **kwargs): - super(ModelResult, self).__init__(**kwargs) - self.model_id = kwargs.get('model_id', None) - self.status = kwargs.get('status', None) - self.created_date_time = kwargs.get('created_date_time', None) - self.last_updated_date_time = kwargs.get('last_updated_date_time', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result_py3.py deleted file mode 100644 index 220186a88bbe..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/model_result_py3.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ModelResult(Model): - """Result of a model status query operation. - - :param model_id: Get or set model identifier. - :type model_id: str - :param status: Get or set the status of model. Possible values include: - 'created', 'ready', 'invalid' - :type status: str or ~azure.cognitiveservices.formrecognizer.models.enum - :param created_date_time: Get or set the created date time of the model. - :type created_date_time: datetime - :param last_updated_date_time: Get or set the model last updated datetime. - :type last_updated_date_time: datetime - """ - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - } - - def __init__(self, *, model_id: str=None, status=None, created_date_time=None, last_updated_date_time=None, **kwargs) -> None: - super(ModelResult, self).__init__(**kwargs) - self.model_id = model_id - self.status = status - self.created_date_time = created_date_time - self.last_updated_date_time = last_updated_date_time diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result.py deleted file mode 100644 index 82c1bc80ab08..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ModelsResult(Model): - """Result of query operation to fetch multiple models. - - :param models_property: Collection of models. - :type models_property: - list[~azure.cognitiveservices.formrecognizer.models.ModelResult] - """ - - _attribute_map = { - 'models_property': {'key': 'models', 'type': '[ModelResult]'}, - } - - def __init__(self, **kwargs): - super(ModelsResult, self).__init__(**kwargs) - self.models_property = kwargs.get('models_property', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result_py3.py deleted file mode 100644 index 3b79d8e4e315..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/models_result_py3.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class ModelsResult(Model): - """Result of query operation to fetch multiple models. - - :param models_property: Collection of models. - :type models_property: - list[~azure.cognitiveservices.formrecognizer.models.ModelResult] - """ - - _attribute_map = { - 'models_property': {'key': 'models', 'type': '[ModelResult]'}, - } - - def __init__(self, *, models_property=None, **kwargs) -> None: - super(ModelsResult, self).__init__(**kwargs) - self.models_property = models_property diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py deleted file mode 100644 index b29c8b6e02eb..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class TrainRequest(Model): - """Contract to initiate a train request. - - All required parameters must be populated in order to send to Azure. - - :param source: Required. Get or set source path. - :type source: str - """ - - _validation = { - 'source': {'required': True, 'max_length': 2048, 'min_length': 0}, - } - - _attribute_map = { - 'source': {'key': 'source', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(TrainRequest, self).__init__(**kwargs) - self.source = kwargs.get('source', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py deleted file mode 100644 index e32bbf06cad1..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class TrainRequest(Model): - """Contract to initiate a train request. - - All required parameters must be populated in order to send to Azure. - - :param source: Required. Get or set source path. - :type source: str - """ - - _validation = { - 'source': {'required': True, 'max_length': 2048, 'min_length': 0}, - } - - _attribute_map = { - 'source': {'key': 'source', 'type': 'str'}, - } - - def __init__(self, *, source: str, **kwargs) -> None: - super(TrainRequest, self).__init__(**kwargs) - self.source = source diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result.py deleted file mode 100644 index 1194baf6dbf2..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class TrainResult(Model): - """Response of the Train API call. - - :param model_id: Identifier of the model. - :type model_id: str - :param training_documents: List of documents used to train the model and - the - train operation error reported by each. - :type training_documents: - list[~azure.cognitiveservices.formrecognizer.models.FormDocumentReport] - :param errors: Errors returned during the training operation. - :type errors: - list[~azure.cognitiveservices.formrecognizer.models.FormOperationError] - """ - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'training_documents': {'key': 'trainingDocuments', 'type': '[FormDocumentReport]'}, - 'errors': {'key': 'errors', 'type': '[FormOperationError]'}, - } - - def __init__(self, **kwargs): - super(TrainResult, self).__init__(**kwargs) - self.model_id = kwargs.get('model_id', None) - self.training_documents = kwargs.get('training_documents', None) - self.errors = kwargs.get('errors', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result_py3.py deleted file mode 100644 index 13d61822ce30..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_result_py3.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.serialization import Model - - -class TrainResult(Model): - """Response of the Train API call. - - :param model_id: Identifier of the model. - :type model_id: str - :param training_documents: List of documents used to train the model and - the - train operation error reported by each. - :type training_documents: - list[~azure.cognitiveservices.formrecognizer.models.FormDocumentReport] - :param errors: Errors returned during the training operation. - :type errors: - list[~azure.cognitiveservices.formrecognizer.models.FormOperationError] - """ - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'training_documents': {'key': 'trainingDocuments', 'type': '[FormDocumentReport]'}, - 'errors': {'key': 'errors', 'type': '[FormOperationError]'}, - } - - def __init__(self, *, model_id: str=None, training_documents=None, errors=None, **kwargs) -> None: - super(TrainResult, self).__init__(**kwargs) - self.model_id = model_id - self.training_documents = training_documents - self.errors = errors diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/__init__.py similarity index 55% rename from sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error.py rename to sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/__init__.py index 1fba4f234e92..28f7635abe61 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/inner_error.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/__init__.py @@ -9,20 +9,8 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from ._form_recognizer_client_operations import FormRecognizerClientOperationsMixin - -class InnerError(Model): - """InnerError. - - :param request_id: - :type request_id: str - """ - - _attribute_map = { - 'request_id': {'key': 'requestId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(InnerError, self).__init__(**kwargs) - self.request_id = kwargs.get('request_id', None) +__all__ = [ + 'FormRecognizerClientOperationsMixin', +] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/_form_recognizer_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/_form_recognizer_client_operations.py new file mode 100644 index 000000000000..b574e05b0cd8 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/operations/_form_recognizer_client_operations.py @@ -0,0 +1,666 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from .. import models + + +class FormRecognizerClientOperationsMixin(object): + + def train_custom_model_async( + self, train_request, custom_headers=None, raw=False, **operation_config): + """Train Custom Model. + + Create and train a custom model. The request must include a source + parameter that is either an externally accessible Azure storage blob + container Uri (preferably a Shared Access Signature Uri) or valid path + to a data folder in a locally mounted drive. When local paths are + specified, they must follow the Linux/Unix path format and be an + absolute path rooted to the input mount configuration setting value + e.g., if '{Mounts:Input}' configuration setting value is '/input' then + a valid source path would be '/input/contosodataset'. All data to be + trained is expected to be under the source folder or sub folders under + it. Models are trained using documents that are of the following + content type - 'application/pdf', 'image/jpeg', 'image/png', + 'image/tiff'. Other type of content is ignored. + + :param train_request: Training request parameters. + :type train_request: + ~azure.cognitiveservices.formrecognizer.models.TrainRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.train_custom_model_async.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(train_request, 'TrainRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Location': 'str', + }) + return client_raw_response + train_custom_model_async.metadata = {'url': '/custom/models'} + + def get_custom_model( + self, model_id, include_keys=False, custom_headers=None, raw=False, **operation_config): + """Get Custom Model. + + Get detailed information about a custom model. + + :param model_id: Model identifier. + :type model_id: str + :param include_keys: Include list of extracted keys in model + information. + :type include_keys: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Model or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.formrecognizer.models.Model or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_custom_model.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if include_keys is not None: + query_parameters['includeKeys'] = self._serialize.query("include_keys", include_keys, 'bool') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Model', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_custom_model.metadata = {'url': '/custom/models/{modelId}'} + + def delete_custom_model( + self, model_id, custom_headers=None, raw=False, **operation_config): + """Delete Custom Model. + + Mark model for deletion. Model artifacts will be permanently removed + within a predetermined period. + + :param model_id: Model identifier. + :type model_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete_custom_model.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_custom_model.metadata = {'url': '/custom/models/{modelId}'} + + def analyze_with_custom_model( + self, model_id, include_text_details=False, source=None, custom_headers=None, raw=False, **operation_config): + """Analyze Form. + + Extract key-value pairs, tables, and semantic values from a given + document. The input document must be of one of the supported content + types - 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. + Alternatively, use 'application/json' type to specify the location (Uri + or local path) of the document to be analyzed. + + :param model_id: Model identifier. + :type model_id: str + :param include_text_details: Include text lines and element references + in the result. + :type include_text_details: bool + :param source: File source path. + :type source: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + file_stream = None + if source is not None: + file_stream = models.SourcePath(source=source) + + # Construct URL + url = self.analyze_with_custom_model.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if include_text_details is not None: + query_parameters['includeTextDetails'] = self._serialize.query("include_text_details", include_text_details, 'bool') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + if file_stream is not None: + body_content = self._serialize.body(file_stream, 'SourcePath') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Operation-Location': 'str', + }) + return client_raw_response + analyze_with_custom_model.metadata = {'url': '/custom/models/{modelId}/analyze'} + + def get_analyze_form_result( + self, model_id, result_id, custom_headers=None, raw=False, **operation_config): + """Get Analyze Form Result. + + Obtain current status and the result of the analyze form operation. + + :param model_id: Model identifier. + :type model_id: str + :param result_id: Analyze operation result identifier. + :type result_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AnalyzeOperationResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.formrecognizer.models.AnalyzeOperationResult + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_analyze_form_result.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str'), + 'resultId': self._serialize.url("result_id", result_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AnalyzeOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_analyze_form_result.metadata = {'url': '/custom/models/{modelId}/analyzeResults/{resultId}'} + + def analyze_receipt_async( + self, include_text_details=False, source=None, custom_headers=None, raw=False, **operation_config): + """Analyze Receipt. + + Extract field text and semantic values from a given receipt document. + The input document must be of one of the supported content types - + 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. + Alternatively, use 'application/json' type to specify the location (Uri + or local path) of the document to be analyzed. + + :param include_text_details: Include text lines and element references + in the result. + :type include_text_details: bool + :param source: File source path. + :type source: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + file_stream = None + if source is not None: + file_stream = models.SourcePath(source=source) + + # Construct URL + url = self.analyze_receipt_async.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if include_text_details is not None: + query_parameters['includeTextDetails'] = self._serialize.query("include_text_details", include_text_details, 'bool') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + if file_stream is not None: + body_content = self._serialize.body(file_stream, 'SourcePath') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Operation-Location': 'str', + }) + return client_raw_response + analyze_receipt_async.metadata = {'url': '/prebuilt/receipt/analyze'} + + def get_analyze_receipt_result( + self, result_id, custom_headers=None, raw=False, **operation_config): + """Get Analyze Receipt Result. + + Track the progress and obtain the result of the analyze receipt + operation. + + :param result_id: Analyze operation result identifier. + :type result_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AnalyzeOperationResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.formrecognizer.models.AnalyzeOperationResult + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_analyze_receipt_result.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'resultId': self._serialize.url("result_id", result_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AnalyzeOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_analyze_receipt_result.metadata = {'url': '/prebuilt/receipt/analyzeResults/{resultId}'} + + def analyze_layout_async( + self, source=None, custom_headers=None, raw=False, **operation_config): + """Analyze Layout. + + Extract text and layout information from a given document. The input + document must be of one of the supported content types - + 'application/pdf', 'image/jpeg', 'image/png' or 'image/tiff'. + Alternatively, use 'application/json' type to specify the location (Uri + or local path) of the document to be analyzed. + + :param source: File source path. + :type source: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + file_stream = None + if source is not None: + file_stream = models.SourcePath(source=source) + + # Construct URL + url = self.analyze_layout_async.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + if file_stream is not None: + body_content = self._serialize.body(file_stream, 'SourcePath') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Operation-Location': 'str', + }) + return client_raw_response + analyze_layout_async.metadata = {'url': '/layout/analyze'} + + def get_analyze_layout_result( + self, result_id, custom_headers=None, raw=False, **operation_config): + """Get Analyze Layout Result. + + Track the progress and obtain the result of the analyze layout + operation. + + :param result_id: Analyze operation result identifier. + :type result_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AnalyzeOperationResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.formrecognizer.models.AnalyzeOperationResult + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_analyze_layout_result.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'resultId': self._serialize.url("result_id", result_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AnalyzeOperationResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_analyze_layout_result.metadata = {'url': '/layout/analyzeResults/{resultId}'} + + def list_custom_models( + self, custom_headers=None, raw=False, **operation_config): + """List Custom Models. + + Get information about all custom models. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ModelsModel or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelsModel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + op = "full" + + # Construct URL + url = self.list_custom_models.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['op'] = self._serialize.query("op", op, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ModelsModel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_custom_models.metadata = {'url': '/custom/models'} + + def get_custom_models( + self, custom_headers=None, raw=False, **operation_config): + """Get Custom Models. + + Get information about all custom models. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ModelsModel or ClientRawResponse if raw=true + :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelsModel or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + op = "summary" + + # Construct URL + url = self.get_custom_models.metadata['url'] + path_format_arguments = { + 'endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['op'] = self._serialize.query("op", op, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ModelsModel', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_custom_models.metadata = {'url': '/custom/models'}