diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/CHANGELOG.md b/sdk/documentintelligence/azure-ai-documentintelligence/CHANGELOG.md new file mode 100644 index 000000000000..d3d0c4b5692c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/CHANGELOG.md @@ -0,0 +1,13 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure DocumentIntelligence client library for Java. This package contains Microsoft Azure DocumentIntelligence client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/README.md b/sdk/documentintelligence/azure-ai-documentintelligence/README.md new file mode 100644 index 000000000000..c5c279331041 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/README.md @@ -0,0 +1,483 @@ +# Azure DocumentIntelligence client library for Java + +Azure Document Intelligence ([previously known as Document Intelligence][service-rename]) is a cloud service that uses machine +learning to analyze text and structured data from your documents. +It includes the following main features: + +* Layout - Extract text, table structures, and selection marks, along with their bounding region coordinates, from documents. +* Document - Analyze entities, key-value pairs, tables, and selection marks from documents using the general prebuilt document model. +* Prebuilt - Analyze data from certain types of common documents (such as receipts, invoices, identity documents or US W2 tax forms) using prebuilt models. +* Custom - Build custom models to extract text, field values, selection marks, and table data from documents. Custom models are built with your own data, so they're tailored to your documents. +* Read - Read information about textual elements, such as page words and lines in addition to text language information. +* Classifiers - Build custom classifiers to categorize documents into predefined classes. + +[Source code][source_code] | [Package (Maven)][package] | [API reference documentation][api_reference_doc] | [Product Documentation][product_documentation] | [Samples][sample_readme] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] +- [Cognitive Services or Document Intelligence account][form_recognizer_account] to use this package. + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure:azure-ai-documentintelligence;current}) +```xml + + com.azure + azure-ai-documentintelligence + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +In order to interact with the Azure Document Intelligence Service you'll need to create an instance of client class, +[DocumentIntelligenceAsyncClient][document_analysis_async_client] or [DocumentIntelligenceClient][document_analysis_sync_client] by using +[DocumentIntelligenceClientBuilder][document_analysis_client_builder]. To configure a client for use with +Azure DocumentIntelligence, provide a valid endpoint URI to an Azure DocumentIntelligence resource along with a corresponding key credential, +token credential, or [Azure Identity][azure_identity] credential that's authorized to use the Azure DocumentIntelligence resource. + +#### Create a Azure DocumentIntelligence client with key credential +Get Azure DocumentIntelligence `key` credential from the Azure Portal. + +```java com.azure.ai.documentintelligence.readme.createDocumentAnalysisClient +DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildClient(); +``` +or +```java readme-sample-createDocumentModelAdministrationClient +DocumentModelAdministrationClient client = + new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildClient(); +``` + +#### Create an Azure DocumentIntelligence client with Azure Active Directory credential +Azure SDK for Java supports an Azure Identity package, making it easy to get credentials from Microsoft identity +platform. + +Authentication with AAD requires some initial setup: +* Add the Azure Identity package + +[//]: # ({x-version-update-start;com.azure:azure-identity;dependency}) +```xml + + com.azure + azure-identity + 1.10.4 + +``` +[//]: # ({x-version-update-end}) + +After setup, you can choose which type of [credential][azure_identity_credential_type] from azure.identity to use. +As an example, [DefaultAzureCredential][wiki_identity] can be used to authenticate the client: +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +Authorization is easiest using [DefaultAzureCredential][wiki_identity]. It finds the best credential to use in its +running environment. For more information about using Azure Active Directory authorization with DocumentIntelligence service, please +refer to [the associated documentation][aad_authorization]. + +```java com.azure.ai.documentanalysis.readme.DocumentAnalysisAsyncClient.withAAD +DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder() + .credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildAsyncClient(); +``` + +## Key concepts +### DocumentAnalysisClient +The [DocumentAnalysisClient][document_analysis_sync_client] and [DocumentAnalysisAsyncClient][document_analysis_async_client] +provide both synchronous and asynchronous operations for analyzing input documents using custom and prebuilt models +through the `beginAnalyzeDocument` API. +See a full list of supported models [here][fr_models]. + +Sample code snippets to illustrate using a DocumentAnalysisClient [here][sample_readme]. +More information about analyzing documents, including supported features, locales, and document types can be found +[here][fr_models]. + +### DocumentModelAdministrationClient +The [DocumentModelAdministrationClient][document_model_admin_sync_client] and +[DocumentModelAdministrationAsyncClient][document_model_admin_async_client] provide both synchronous and asynchronous operations +- Build custom document analysis models to analyze text content, fields, and values found in your custom documents. See example [Build a document model](#build-a-document-model). + A `DocumentModelDetails` is returned indicating the document types that the model can analyze, along with the fields and schemas it will extract. +- Managing models created in your account by building, listing, deleting, and see the limit of custom models your account. See example [Manage models](#manage-your-models). +- Copying a custom model from one Document Intelligence resource to another. +- Creating a composed model from a collection of existing built models. +- Listing document model operations associated with the Document Intelligence resource. + +Sample code snippets are provided to illustrate using a DocumentModelAdministrationClient [here](#examples "Examples"). + +### Long-running operations +Long-running operations are operations that consist of an initial request sent to the service to start an operation, +followed by polling the service at intervals to determine whether the operation has completed or failed, and if it has +succeeded, to get the result. + +Methods that build models, analyze values from documents, or copy and compose models are modeled as long-running operations. +The client exposes a `begin` method that returns a `SyncPoller` or `PollerFlux` instance. +Callers should wait for the operation to be completed by calling `getFinalResult()` on the returned operation from the +`begin` method. Sample code snippets are provided to illustrate using long-running operations +[below](#examples). + +## Examples + +The following section provides several code snippets covering some of the most common Document Intelligence tasks, including: + +* [Extract Layout](#extract-layout "Extract Layout") +* [Use Prebuilt Models](#use-prebuilt-models) +* [Build a Document Model](#build-a-document-model "Build a Document Model") +* [Analyze Documents using a Custom Model](#analyze-documents-using-a-custom-model "Analyze Documents using a Custom Model") +* [Manage Your Models](#manage-your-models "Manage Your Models") + +### Extract Layout +Extract text, table structures, and selection marks like radio buttons and check boxes, along with their bounding box coordinates from documents without the need to build a model. +```java com.azure.ai.documentintelligence.readme.analyzeLayout +File layoutDocument = new File("local/file_path/filename.png"); +Path filePath = layoutDocument.toPath(); +BinaryData layoutDocumentData = BinaryData.fromFile(filePath, (int) layoutDocument.length()); + +SyncPoller analyzeLayoutResultPoller = + documentAnalysisClient.beginAnalyzeDocument("prebuilt-layout", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(layoutDocument.toPath()))); + +AnalyzeResult analyzeLayoutResult = analyzeLayoutResultPoller.getFinalResult(); + +// pages +analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding box %s.%n", + documentLine.getContent(), + documentLine.getPolygon().toString())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding box %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon().toString(), + documentSelectionMark.getConfidence())); +}); + +// tables +List tables = analyzeLayoutResult.getTables(); +for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); +} +``` + +### Use Prebuilt Models +Extract fields from select document types such as receipts, invoices, and identity documents using prebuilt models provided by the Document Intelligence service. +Supported prebuilt models are: +- Analyze receipts using the `prebuilt-receipt` model (fields recognized by the service can be found [here][service_analyze_receipt_fields]) +- Analyze invoices using the `prebuilt-invoice` model (fields recognized by the service can be found [here][service_analyze_invoices_fields]). +- Analyze identity documents using the `prebuilt-idDocuments` model (fields recognized by the service can be found [here][service_analyze_identity_documents_fields]). +- Analyze US W2 tax forms using the `prebuilt-tax.us.w2` model. [Supported fields][service_analyze_w2_documents_fields]. + +For example, to analyze fields from a sales receipt, into the `beginAnalyzeDocumentFromUrl` method: +```java com.azure.ai.documentintelligence.readme.analyzeReceipt +File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/receipts/contoso-allinone.jpg"); + +SyncPoller analyzeReceiptPoller = + documentAnalysisClient.beginAnalyzeDocument("prebuilt-receipt", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(sourceFile.toPath()))); + +AnalyzeResult receiptResults = analyzeReceiptPoller.getFinalResult(); + +for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } +} +``` + +For more information and samples using prebuilt models, see: +- [Identity Documents][analyze_identity_documents_from_url] +- [Invoices][analyze_invoices_from_url] +- [Receipts sample][analyze_receipts_from_url] + +### Build a document model +Build a machine-learned model on your own document type. The resulting model will be able to analyze values from the types of documents it was built on. +Provide a container SAS url to your Azure Storage Blob container where you're storing the training documents. See details on setting this up +in the [service quickstart documentation][quickstart_training]. + +**Note** + +You can use the [Document Intelligence Studio preview][fr-studio] for creating a labeled file for your training forms. +More details on setting up a container and required file structure can be found in [here][fr_build_training_set]. + +```java com.azure.ai.documentintelligence.readme.buildModel +// Build custom document analysis model +String blobContainerUrl = "{SAS_URL_of_your_container_in_blob_storage}"; +// The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. +SyncPoller buildOperationPoller = + administrationClient.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))); + +DocumentModelDetails documentModelDetails = buildOperationPoller.getFinalResult(); + +// Model Info +System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); +System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); +System.out.printf("Model created on: %s%n%n", documentModelDetails.getCreatedDateTime()); + +System.out.println("Document Fields:"); +documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); +}); +``` + +### Analyze Documents using a Custom Model +Analyze the key/value pairs and table data from documents. These models are built with your own data, +so they're tailored to your documents. You should only analyze documents of the same doc type that the custom model +was built on. +```java com.azure.ai.documentintelligence.readme.analyzeCustomModel +String documentUrl = "{document-url}"; +String modelId = "{custom-built-model-ID}"; +SyncPoller analyzeDocumentPoller = documentAnalysisClient.beginAnalyzeDocument(modelId, + "1", + "en-US", + StringIndexType.TEXT_ELEMENTS, + Arrays.asList(DocumentAnalysisFeature.LANGUAGES), + null, + ContentFormat.TEXT, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)); + +AnalyzeResult analyzeResult = analyzeDocumentPoller.getFinalResult(); + +for (int i = 0; i < analyzeResult.getDocuments().size(); i++) { + final Document analyzedDocument = analyzeResult.getDocuments().get(i); + System.out.printf("----------- Analyzing custom document %d -----------%n", i); + System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n", + analyzedDocument.getDocType(), analyzedDocument.getConfidence()); +} + +analyzeResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); +}); + +// tables +List tables = analyzeResult.getTables(); +for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); +} +``` + +### Manage your models +Manage the models in your Document Intelligence account. +```java com.azure.ai.documentintelligence.readme.manageModels + +ResourceDetails resourceDetails = administrationClient.getResourceInfo(); +System.out.printf("The resource has %s models, and we can have at most %s models.%n", + resourceDetails.getCustomDocumentModels().getCount(), resourceDetails.getCustomDocumentModels().getLimit()); + +// Next, we get a paged list of all of our models +PagedIterable customDocumentModels = administrationClient.listModels(); +System.out.println("We have following models in the account:"); +customDocumentModels.forEach(documentModelInfo -> { + System.out.println(); + // get custom document analysis model info + DocumentModelDetails documentModel = administrationClient.getModel(documentModelInfo.getModelId()); + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model created on: %s%n", documentModel.getCreatedDateTime()); + if (documentModel.getDocTypes() != null) { + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s, ", field); + System.out.printf("Field type: %s, ", documentFieldSchema.getType()); + if (documentTypeDetails.getFieldConfidence() != null) { + System.out.printf("Field confidence: %.2f%n", + documentTypeDetails.getFieldConfidence().get(field)); + } + }); + }); + } +}); +``` + +For more detailed examples, refer to [samples][sample_examples]. + +## Troubleshooting +### Enable client logging +You can set the `AZURE_LOG_LEVEL` environment variable to view logging statements made in the client library. For +example, setting `AZURE_LOG_LEVEL=2` would show all informational, warning, and error log messages. The log levels can +be found here: [log levels][logLevels]. + +### Default HTTP Client +All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure +the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the +[HTTP clients wiki](https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients). + +### Default SSL library +All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSL +operations. The Boring SSL library is an uber jar containing native libraries for Linux / macOS / Windows, and provides +better performance compared to the default SSL implementation within the JDK. For more information, including how to +reduce the dependency size, refer to the [performance tuning][performance_tuning] section of the wiki. + +## Next steps +- Samples are explained in detail [here][samples_readme]. + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[aad_authorization]: https://docs.microsoft.com/azure/cognitive-services/authentication#authenticate-with-azure-active-directory +[azure_key_credential]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/credential/AzureKeyCredential.java +[key]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows#get-the-keys-for-your-resource +[api_reference_doc]: https://azure.github.io/azure-sdk-for-java +[form_recognizer_doc]: https://aka.ms/azsdk-java-documentIntelligence-ref-doc +[azure_identity_credential_type]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_cli]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli?tabs=windows +[azure_cli_endpoint]: https://docs.microsoft.com/cli/azure/cognitiveservices/account?view=azure-cli-latest#az-cognitiveservices-account-show +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_portal]: https://ms.portal.azure.com +[azure_subscription]: https://azure.microsoft.com/free +[cla]: https://cla.microsoft.com +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ +[coc_contact]: mailto:opencode@microsoft.com +[create_new_resource]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows#create-a-new-azure-cognitive-services-resource +[form_recognizer_account]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows +[grant_access]: https://docs.microsoft.com/azure/cognitive-services/authentication#assign-a-role-to-a-service-principal +[http_clients_wiki]: https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients +[http_response_exception]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/exception/HttpResponseException.java +[jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable +[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK +[package]: https://central.sonatype.com/artifact/com.azure/azure-ai-documentIntelligence +[product_documentation]: https://docs.microsoft.com/azure/cognitive-services/form-recognizer/overview +[register_AAD_application]: https://docs.microsoft.com/azure/cognitive-services/authentication#assign-a-role-to-a-service-principal +[fr-studio]: https://aka.ms/azsdk/formrecognizer/documentIntelligencestudio +[fr_build_training_set]: https://aka.ms/azsdk/formrecognizer/buildcustommodel +[sample_examples]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples#examples +[sample_readme]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples#readme +[migration_guide]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/documentIntelligence/azure-ai-documentIntelligence/migration-guide.md +[changelog]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/CHANGELOG.md + +[sample_readme]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/ +[document_analysis_async_client]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/main/java/com/azure/ai/documentIntelligence/documentanalysis/DocumentAnalysisAsyncClient.java +[document_analysis_sync_client]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/main/java/com/azure/ai/documentIntelligence/documentanalysis/DocumentAnalysisClient.java +[document_model_admin_async_client]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/main/java/com/azure/ai/documentIntelligence/documentanalysis/administration/DocumentModelAdministrationAsyncClient.java +[document_model_admin_sync_client]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/main/java/com/azure/ai/documentIntelligence/documentanalysis/administration/DocumentModelAdministrationClient.java +[document_analysis_client_builder]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/main/java/com/azure/ai/documentIntelligence/documentanalysis/DocumentAnalysisClientBuilder.java +[manage_custom_models]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/ManageCustomModels.java +[manage_custom_models_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/ManageCustomModelsAsync.java +[build_model]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/BuildDocumentModel.java +[build_model_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/BuildDocumentModelAsync.java +[build_document_classifier]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/BuildDocumentClassifier.java +[build_document_classifier_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/administration/BuildDocumentClassifierAsync.java +[analyze_identity_documents_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/AnalyzeIdentityDocumentsFromUrl.java +[analyze_identity_documents_from_url_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/AnalyzeIdentityDocumentsFromUrlAsync.java +[analyze_invoices_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/AnalyzeInvoicesFromUrl.java +[analyze_receipts_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src/samples/java/com/azure/ai/documentIntelligence/AnalyzeReceiptsFromUrl.java + +[fr_models]: https://aka.ms/azsdk/formrecognizer/models +[service_access]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows +[service_analyze_invoices_fields]: https://aka.ms/azsdk/formrecognizer/invoicefieldschema +[service_analyze_identity_documents_fields]: https://aka.ms/azsdk/formrecognizer/iddocumentfieldschema +[service_analyze_receipt_fields]: https://aka.ms/azsdk/formrecognizer/receiptfieldschema +[service_analyze_w2_documents_fields]: https://aka.ms/azsdk/formrecognizer/taxusw2fieldschema +[service-rename]: https://techcommunity.microsoft.com/t5/azure-ai-services-blog/azure-form-recognizer-is-now-azure-ai-document-intelligence-with/ba-p/3875765 +[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentIntelligence/azure-ai-documentIntelligence/src +[quickstart_training]: https://learn.microsoft.com/azure/applied-ai-services/form-recognizer/quickstarts/get-started-sdks-rest-api?view=form-recog-3.0.0&pivots=programming-language-java +[wiki_identity]: https://github.com/Azure/azure-sdk-for-java/wiki/Identity-and-Authentication diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/assets.json b/sdk/documentintelligence/azure-ai-documentintelligence/assets.json new file mode 100644 index 000000000000..f35191297bb5 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo" : "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath" : "java", + "TagPrefix" : "java/documentintelligence/azure-ai-documentintelligence", + "Tag" : "" +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/pom.xml b/sdk/documentintelligence/azure-ai-documentintelligence/pom.xml new file mode 100644 index 000000000000..10c44ce5a06f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-ai-documentintelligence + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for DocumentIntelligence + This package contains Microsoft Azure DocumentIntelligence client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + com.azure + azure-core + 1.45.0 + + + com.azure + azure-core-http-netty + 1.13.10 + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.9.3 + test + + + org.mockito + mockito-core + 4.11.0 + test + + + com.azure + azure-core-test + 1.22.0 + test + + + com.azure + azure-identity + 1.10.4 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + com.azure + azure-core-experimental + 1.0.0-beta.46 + + + diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClient.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClient.java new file mode 100644 index 000000000000..f464a40b57cf --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClient.java @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentAnalysisClientImpl; +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.ClassifyDocumentRequest; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.SplitMode; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** Initializes a new instance of the asynchronous DocumentAnalysisClient type. */ +@ServiceClient(builder = DocumentAnalysisClientBuilder.class, isAsync = true) +public final class DocumentAnalysisAsyncClient { + @Generated private final DocumentAnalysisClientImpl serviceClient; + + /** + * Initializes an instance of DocumentAnalysisAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DocumentAnalysisAsyncClient(DocumentAnalysisClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginAnalyzeDocument(String modelId, RequestOptions requestOptions) { + return this.serviceClient.beginAnalyzeDocumentAsync(modelId, requestOptions); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginClassifyDocument( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return this.serviceClient.beginClassifyDocumentAsync(classifierId, classifyRequest, requestOptions); + } + + /** + * Analyzes document with document model. + * + * @param modelId Unique document model name. + * @param pages List of 1-based page numbers to analyze. Ex. "1-3,5,7-9". + * @param locale Locale hint for text recognition and document analysis. Value may contain only the language code + * (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). + * @param stringIndexType Method used to compute string offset and length. + * @param features List of optional analysis features. + * @param queryFields List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". + * @param outputContentFormat Format of the analyze result top-level content. + * @param analyzeRequest Analyze request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginAnalyzeDocument( + String modelId, + String pages, + String locale, + StringIndexType stringIndexType, + List features, + List queryFields, + ContentFormat outputContentFormat, + AnalyzeDocumentRequest analyzeRequest) { + // Generated convenience method for beginAnalyzeDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + if (pages != null) { + requestOptions.addQueryParam("pages", pages, false); + } + if (locale != null) { + requestOptions.addQueryParam("locale", locale, false); + } + if (stringIndexType != null) { + requestOptions.addQueryParam("stringIndexType", stringIndexType.toString(), false); + } + if (features != null) { + requestOptions.addQueryParam( + "features", + JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(features, CollectionFormat.CSV), + false); + } + if (queryFields != null) { + requestOptions.addQueryParam( + "queryFields", + queryFields.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (outputContentFormat != null) { + requestOptions.addQueryParam("outputContentFormat", outputContentFormat.toString(), false); + } + if (analyzeRequest != null) { + requestOptions.setBody(BinaryData.fromObject(analyzeRequest)); + } + return serviceClient.beginAnalyzeDocumentWithModelAsync(modelId, requestOptions); + } + + /** + * Analyzes document with document model. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginAnalyzeDocument(String modelId) { + // Generated convenience method for beginAnalyzeDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginAnalyzeDocumentWithModelAsync(modelId, requestOptions); + } + + /** + * Classifies document with document classifier. + * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param stringIndexType Method used to compute string offset and length. + * @param split Document splitting mode. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginClassifyDocument( + String classifierId, + ClassifyDocumentRequest classifyRequest, + StringIndexType stringIndexType, + SplitMode split) { + // Generated convenience method for beginClassifyDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + if (stringIndexType != null) { + requestOptions.addQueryParam("stringIndexType", stringIndexType.toString(), false); + } + if (split != null) { + requestOptions.addQueryParam("split", split.toString(), false); + } + return serviceClient.beginClassifyDocumentWithModelAsync( + classifierId, BinaryData.fromObject(classifyRequest), requestOptions); + } + + /** + * Classifies document with document classifier. + * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginClassifyDocument( + String classifierId, ClassifyDocumentRequest classifyRequest) { + // Generated convenience method for beginClassifyDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginClassifyDocumentWithModelAsync( + classifierId, BinaryData.fromObject(classifyRequest), requestOptions); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClient.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClient.java new file mode 100644 index 000000000000..b467f40d7c36 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClient.java @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentAnalysisClientImpl; +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.ClassifyDocumentRequest; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.SplitMode; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.CollectionFormat; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** Initializes a new instance of the synchronous DocumentAnalysisClient type. */ +@ServiceClient(builder = DocumentAnalysisClientBuilder.class) +public final class DocumentAnalysisClient { + @Generated private final DocumentAnalysisClientImpl serviceClient; + + /** + * Initializes an instance of DocumentAnalysisClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DocumentAnalysisClient(DocumentAnalysisClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginAnalyzeDocument(String modelId, RequestOptions requestOptions) { + return this.serviceClient.beginAnalyzeDocument(modelId, requestOptions); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginClassifyDocument( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return this.serviceClient.beginClassifyDocument(classifierId, classifyRequest, requestOptions); + } + + /** + * Analyzes document with document model. + * + * @param modelId Unique document model name. + * @param pages List of 1-based page numbers to analyze. Ex. "1-3,5,7-9". + * @param locale Locale hint for text recognition and document analysis. Value may contain only the language code + * (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). + * @param stringIndexType Method used to compute string offset and length. + * @param features List of optional analysis features. + * @param queryFields List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". + * @param outputContentFormat Format of the analyze result top-level content. + * @param analyzeRequest Analyze request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginAnalyzeDocument( + String modelId, + String pages, + String locale, + StringIndexType stringIndexType, + List features, + List queryFields, + ContentFormat outputContentFormat, + AnalyzeDocumentRequest analyzeRequest) { + // Generated convenience method for beginAnalyzeDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + if (pages != null) { + requestOptions.addQueryParam("pages", pages, false); + } + if (locale != null) { + requestOptions.addQueryParam("locale", locale, false); + } + if (stringIndexType != null) { + requestOptions.addQueryParam("stringIndexType", stringIndexType.toString(), false); + } + if (features != null) { + requestOptions.addQueryParam( + "features", + JacksonAdapter.createDefaultSerializerAdapter().serializeIterable(features, CollectionFormat.CSV), + false); + } + if (queryFields != null) { + requestOptions.addQueryParam( + "queryFields", + queryFields.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (outputContentFormat != null) { + requestOptions.addQueryParam("outputContentFormat", outputContentFormat.toString(), false); + } + if (analyzeRequest != null) { + requestOptions.setBody(BinaryData.fromObject(analyzeRequest)); + } + return serviceClient.beginAnalyzeDocumentWithModel(modelId, requestOptions); + } + + /** + * Analyzes document with document model. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginAnalyzeDocument(String modelId) { + // Generated convenience method for beginAnalyzeDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginAnalyzeDocumentWithModel(modelId, requestOptions); + } + + /** + * Classifies document with document classifier. + * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param stringIndexType Method used to compute string offset and length. + * @param split Document splitting mode. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginClassifyDocument( + String classifierId, + ClassifyDocumentRequest classifyRequest, + StringIndexType stringIndexType, + SplitMode split) { + // Generated convenience method for beginClassifyDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + if (stringIndexType != null) { + requestOptions.addQueryParam("stringIndexType", stringIndexType.toString(), false); + } + if (split != null) { + requestOptions.addQueryParam("split", split.toString(), false); + } + return serviceClient.beginClassifyDocumentWithModel( + classifierId, BinaryData.fromObject(classifyRequest), requestOptions); + } + + /** + * Classifies document with document classifier. + * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginClassifyDocument( + String classifierId, ClassifyDocumentRequest classifyRequest) { + // Generated convenience method for beginClassifyDocumentWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginClassifyDocumentWithModel( + classifierId, BinaryData.fromObject(classifyRequest), requestOptions); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClientBuilder.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClientBuilder.java new file mode 100644 index 000000000000..392d1981c0a6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentAnalysisClientBuilder.java @@ -0,0 +1,323 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentAnalysisClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A builder for creating a new instance of the DocumentAnalysisClient type. */ +@ServiceClientBuilder(serviceClients = {DocumentAnalysisClient.class, DocumentAnalysisAsyncClient.class}) +public final class DocumentAnalysisClientBuilder + implements HttpTrait, + ConfigurationTrait, + TokenCredentialTrait, + KeyCredentialTrait, + EndpointTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] {"https://cognitiveservices.azure.com/.default"}; + + @Generated + private static final Map PROPERTIES = + CoreUtils.getProperties("azure-ai-documentintelligence.properties"); + + @Generated private final List pipelinePolicies; + + /** Create an instance of the DocumentAnalysisClientBuilder. */ + @Generated + public DocumentAnalysisClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated private HttpPipeline pipeline; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated private ClientOptions clientOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated private RetryOptions retryOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated private Configuration configuration; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated private TokenCredential tokenCredential; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated private KeyCredential keyCredential; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated private String endpoint; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentAnalysisClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated private DocumentIntelligenceServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the DocumentAnalysisClientBuilder. + */ + @Generated + public DocumentAnalysisClientBuilder serviceVersion(DocumentIntelligenceServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the DocumentAnalysisClientBuilder. + */ + @Generated + public DocumentAnalysisClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DocumentAnalysisClientImpl with the provided parameters. + * + * @return an instance of DocumentAnalysisClientImpl. + */ + @Generated + private DocumentAnalysisClientImpl buildInnerClient() { + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + DocumentIntelligenceServiceVersion localServiceVersion = + (serviceVersion != null) ? serviceVersion : DocumentIntelligenceServiceVersion.getLatest(); + DocumentAnalysisClientImpl client = + new DocumentAnalysisClientImpl( + localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, + localServiceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + localClientOptions + .getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("Ocp-Apim-Subscription-Key", keyCredential)); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of DocumentAnalysisAsyncClient class. + * + * @return an instance of DocumentAnalysisAsyncClient. + */ + @Generated + public DocumentAnalysisAsyncClient buildAsyncClient() { + return new DocumentAnalysisAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of DocumentAnalysisClient class. + * + * @return an instance of DocumentAnalysisClient. + */ + @Generated + public DocumentAnalysisClient buildClient() { + return new DocumentAnalysisClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DocumentAnalysisClientBuilder.class); +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentIntelligenceServiceVersion.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentIntelligenceServiceVersion.java new file mode 100644 index 000000000000..f1de30ca5b5b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentIntelligenceServiceVersion.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.core.util.ServiceVersion; + +/** Service version of DocumentIntelligenceClient. */ +public enum DocumentIntelligenceServiceVersion implements ServiceVersion { + /** Enum value 2023-10-31-preview. */ + V2023_10_31_PREVIEW("2023-10-31-preview"); + + private final String version; + + DocumentIntelligenceServiceVersion(String version) { + this.version = version; + } + + /** {@inheritDoc} */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link DocumentIntelligenceServiceVersion}. + */ + public static DocumentIntelligenceServiceVersion getLatest() { + return V2023_10_31_PREVIEW; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationAsyncClient.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationAsyncClient.java new file mode 100644 index 000000000000..6bb4ea325c81 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationAsyncClient.java @@ -0,0 +1,963 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentModelAdministrationClientImpl; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ComposeDocumentModelRequest; +import com.azure.ai.documentintelligence.models.CopyAuthorization; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.OperationDetails; +import com.azure.ai.documentintelligence.models.ResourceDetails; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the asynchronous DocumentModelAdministrationClient type. */ +@ServiceClient(builder = DocumentModelAdministrationClientBuilder.class, isAsync = true) +public final class DocumentModelAdministrationAsyncClient { + @Generated private final DocumentModelAdministrationClientImpl serviceClient; + + /** + * Initializes an instance of DocumentModelAdministrationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DocumentModelAdministrationAsyncClient(DocumentModelAdministrationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildDocumentModel( + BinaryData buildRequest, RequestOptions requestOptions) { + return this.serviceClient.beginBuildDocumentModelAsync(buildRequest, requestOptions); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginComposeModel( + BinaryData composeRequest, RequestOptions requestOptions) { + return this.serviceClient.beginComposeModelAsync(composeRequest, requestOptions); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param authorizeCopyRequest Authorize copy request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return authorization to copy a document model to the specified target resource and modelId along with {@link + * Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> authorizeModelCopyWithResponse( + BinaryData authorizeCopyRequest, RequestOptions requestOptions) { + return this.serviceClient.authorizeModelCopyWithResponseAsync(authorizeCopyRequest, requestOptions); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCopyModelTo( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return this.serviceClient.beginCopyModelToAsync(modelId, copyToRequest, requestOptions); + } + + /** + * Gets detailed document model information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document model information along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponse(String modelId, RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponseAsync(modelId, requestOptions); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listModels(RequestOptions requestOptions) { + return this.serviceClient.listModelsAsync(requestOptions); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteModelWithResponse(String modelId, RequestOptions requestOptions) { + return this.serviceClient.deleteModelWithResponseAsync(modelId, requestOptions); + } + + /** + * Return information about the current resource. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     customDocumentModels (Required): {
+     *         count: int (Required)
+     *         limit: int (Required)
+     *     }
+     *     customNeuralDocumentModelBuilds (Required): {
+     *         used: int (Required)
+     *         quota: int (Required)
+     *         quotaResetDateTime: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return general information regarding the current resource along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getResourceInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getResourceInfoWithResponseAsync(requestOptions); + } + + /** + * Gets operation info. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param operationId Operation ID. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return operation info along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationWithResponse(String operationId, RequestOptions requestOptions) { + return this.serviceClient.getOperationWithResponseAsync(operationId, requestOptions); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listOperations(RequestOptions requestOptions) { + return this.serviceClient.listOperationsAsync(requestOptions); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildClassifier( + BinaryData buildRequest, RequestOptions requestOptions) { + return this.serviceClient.beginBuildClassifierAsync(buildRequest, requestOptions); + } + + /** + * Gets detailed document classifier information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document classifier information along with {@link Response} on successful completion of {@link + * Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + return this.serviceClient.getClassifierWithResponseAsync(classifierId, requestOptions); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listClassifiers(RequestOptions requestOptions) { + return this.serviceClient.listClassifiersAsync(requestOptions); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + return this.serviceClient.deleteClassifierWithResponseAsync(classifierId, requestOptions); + } + + /** + * Builds a custom document analysis model. + * + * @param buildRequest Build request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildDocumentModel( + BuildDocumentModelRequest buildRequest) { + // Generated convenience method for beginBuildDocumentModelWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginBuildDocumentModelWithModelAsync(BinaryData.fromObject(buildRequest), requestOptions); + } + + /** + * Creates a new document model from document types of existing document models. + * + * @param composeRequest Compose request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginComposeModel(ComposeDocumentModelRequest composeRequest) { + // Generated convenience method for beginComposeModelWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginComposeModelWithModelAsync(BinaryData.fromObject(composeRequest), requestOptions); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + * @param authorizeCopyRequest Authorize copy request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return authorization to copy a document model to the specified target resource and modelId on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono authorizeModelCopy(AuthorizeCopyRequest authorizeCopyRequest) { + // Generated convenience method for authorizeModelCopyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return authorizeModelCopyWithResponse(BinaryData.fromObject(authorizeCopyRequest), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CopyAuthorization.class)); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCopyModelTo( + String modelId, CopyAuthorization copyToRequest) { + // Generated convenience method for beginCopyModelToWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCopyModelToWithModelAsync( + modelId, BinaryData.fromObject(copyToRequest), requestOptions); + } + + /** + * Gets detailed document model information. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed document model information on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getModel(String modelId) { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(modelId, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DocumentModelDetails.class)); + } + + /** + * List all document models. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listModels() { + // Generated convenience method for listModels + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listModels(requestOptions); + return PagedFlux.create( + () -> + (continuationToken, pageSize) -> { + Flux> flux = + (continuationToken == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map( + pagedResponse -> + new PagedResponseBase( + pagedResponse.getRequest(), + pagedResponse.getStatusCode(), + pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map( + protocolMethodData -> + protocolMethodData.toObject( + DocumentModelDetails.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), + null)); + }); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteModel(String modelId) { + // Generated convenience method for deleteModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteModelWithResponse(modelId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Return information about the current resource. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return general information regarding the current resource on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getResourceInfo() { + // Generated convenience method for getResourceInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getResourceInfoWithResponse(requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ResourceDetails.class)); + } + + /** + * Gets operation info. + * + * @param operationId Operation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return operation info on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOperation(String operationId) { + // Generated convenience method for getOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationWithResponse(operationId, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OperationDetails.class)); + } + + /** + * Lists all operations. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of OperationDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listOperations() { + // Generated convenience method for listOperations + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listOperations(requestOptions); + return PagedFlux.create( + () -> + (continuationToken, pageSize) -> { + Flux> flux = + (continuationToken == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map( + pagedResponse -> + new PagedResponseBase( + pagedResponse.getRequest(), + pagedResponse.getStatusCode(), + pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map( + protocolMethodData -> + protocolMethodData.toObject( + OperationDetails.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), + null)); + }); + } + + /** + * Builds a custom document classifier. + * + * @param buildRequest Build request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildClassifier( + BuildDocumentClassifierRequest buildRequest) { + // Generated convenience method for beginBuildClassifierWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginBuildClassifierWithModelAsync(BinaryData.fromObject(buildRequest), requestOptions); + } + + /** + * Gets detailed document classifier information. + * + * @param classifierId Unique document classifier name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed document classifier information on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getClassifier(String classifierId) { + // Generated convenience method for getClassifierWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getClassifierWithResponse(classifierId, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DocumentClassifierDetails.class)); + } + + /** + * List all document classifiers. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listClassifiers() { + // Generated convenience method for listClassifiers + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listClassifiers(requestOptions); + return PagedFlux.create( + () -> + (continuationToken, pageSize) -> { + Flux> flux = + (continuationToken == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map( + pagedResponse -> + new PagedResponseBase( + pagedResponse.getRequest(), + pagedResponse.getStatusCode(), + pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map( + protocolMethodData -> + protocolMethodData.toObject( + DocumentClassifierDetails.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), + null)); + }); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteClassifier(String classifierId) { + // Generated convenience method for deleteClassifierWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteClassifierWithResponse(classifierId, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClient.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClient.java new file mode 100644 index 000000000000..5da532ff2f55 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClient.java @@ -0,0 +1,885 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentModelAdministrationClientImpl; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ComposeDocumentModelRequest; +import com.azure.ai.documentintelligence.models.CopyAuthorization; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.OperationDetails; +import com.azure.ai.documentintelligence.models.ResourceDetails; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.SyncPoller; + +/** Initializes a new instance of the synchronous DocumentModelAdministrationClient type. */ +@ServiceClient(builder = DocumentModelAdministrationClientBuilder.class) +public final class DocumentModelAdministrationClient { + @Generated private final DocumentModelAdministrationClientImpl serviceClient; + + /** + * Initializes an instance of DocumentModelAdministrationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DocumentModelAdministrationClient(DocumentModelAdministrationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildDocumentModel( + BinaryData buildRequest, RequestOptions requestOptions) { + return this.serviceClient.beginBuildDocumentModel(buildRequest, requestOptions); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginComposeModel( + BinaryData composeRequest, RequestOptions requestOptions) { + return this.serviceClient.beginComposeModel(composeRequest, requestOptions); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param authorizeCopyRequest Authorize copy request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return authorization to copy a document model to the specified target resource and modelId along with {@link + * Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response authorizeModelCopyWithResponse( + BinaryData authorizeCopyRequest, RequestOptions requestOptions) { + return this.serviceClient.authorizeModelCopyWithResponse(authorizeCopyRequest, requestOptions); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCopyModelTo( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return this.serviceClient.beginCopyModelTo(modelId, copyToRequest, requestOptions); + } + + /** + * Gets detailed document model information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document model information along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(String modelId, RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(modelId, requestOptions); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listModels(RequestOptions requestOptions) { + return this.serviceClient.listModels(requestOptions); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteModelWithResponse(String modelId, RequestOptions requestOptions) { + return this.serviceClient.deleteModelWithResponse(modelId, requestOptions); + } + + /** + * Return information about the current resource. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     customDocumentModels (Required): {
+     *         count: int (Required)
+     *         limit: int (Required)
+     *     }
+     *     customNeuralDocumentModelBuilds (Required): {
+     *         used: int (Required)
+     *         quota: int (Required)
+     *         quotaResetDateTime: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return general information regarding the current resource along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getResourceInfoWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getResourceInfoWithResponse(requestOptions); + } + + /** + * Gets operation info. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param operationId Operation ID. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return operation info along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationWithResponse(String operationId, RequestOptions requestOptions) { + return this.serviceClient.getOperationWithResponse(operationId, requestOptions); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listOperations(RequestOptions requestOptions) { + return this.serviceClient.listOperations(requestOptions); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildClassifier( + BinaryData buildRequest, RequestOptions requestOptions) { + return this.serviceClient.beginBuildClassifier(buildRequest, requestOptions); + } + + /** + * Gets detailed document classifier information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document classifier information along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + return this.serviceClient.getClassifierWithResponse(classifierId, requestOptions); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listClassifiers(RequestOptions requestOptions) { + return this.serviceClient.listClassifiers(requestOptions); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + return this.serviceClient.deleteClassifierWithResponse(classifierId, requestOptions); + } + + /** + * Builds a custom document analysis model. + * + * @param buildRequest Build request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildDocumentModel( + BuildDocumentModelRequest buildRequest) { + // Generated convenience method for beginBuildDocumentModelWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginBuildDocumentModelWithModel(BinaryData.fromObject(buildRequest), requestOptions); + } + + /** + * Creates a new document model from document types of existing document models. + * + * @param composeRequest Compose request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginComposeModel(ComposeDocumentModelRequest composeRequest) { + // Generated convenience method for beginComposeModelWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginComposeModelWithModel(BinaryData.fromObject(composeRequest), requestOptions); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + * @param authorizeCopyRequest Authorize copy request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return authorization to copy a document model to the specified target resource and modelId. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CopyAuthorization authorizeModelCopy(AuthorizeCopyRequest authorizeCopyRequest) { + // Generated convenience method for authorizeModelCopyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return authorizeModelCopyWithResponse(BinaryData.fromObject(authorizeCopyRequest), requestOptions) + .getValue() + .toObject(CopyAuthorization.class); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCopyModelTo( + String modelId, CopyAuthorization copyToRequest) { + // Generated convenience method for beginCopyModelToWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginCopyModelToWithModel(modelId, BinaryData.fromObject(copyToRequest), requestOptions); + } + + /** + * Gets detailed document model information. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed document model information. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DocumentModelDetails getModel(String modelId) { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(modelId, requestOptions).getValue().toObject(DocumentModelDetails.class); + } + + /** + * List all document models. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listModels() { + // Generated convenience method for listModels + RequestOptions requestOptions = new RequestOptions(); + return serviceClient + .listModels(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(DocumentModelDetails.class)); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteModel(String modelId) { + // Generated convenience method for deleteModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteModelWithResponse(modelId, requestOptions).getValue(); + } + + /** + * Return information about the current resource. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return general information regarding the current resource. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceDetails getResourceInfo() { + // Generated convenience method for getResourceInfoWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getResourceInfoWithResponse(requestOptions).getValue().toObject(ResourceDetails.class); + } + + /** + * Gets operation info. + * + * @param operationId Operation ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return operation info. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OperationDetails getOperation(String operationId) { + // Generated convenience method for getOperationWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOperationWithResponse(operationId, requestOptions).getValue().toObject(OperationDetails.class); + } + + /** + * Lists all operations. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of OperationDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listOperations() { + // Generated convenience method for listOperations + RequestOptions requestOptions = new RequestOptions(); + return serviceClient + .listOperations(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(OperationDetails.class)); + } + + /** + * Builds a custom document classifier. + * + * @param buildRequest Build request parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildClassifier( + BuildDocumentClassifierRequest buildRequest) { + // Generated convenience method for beginBuildClassifierWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginBuildClassifierWithModel(BinaryData.fromObject(buildRequest), requestOptions); + } + + /** + * Gets detailed document classifier information. + * + * @param classifierId Unique document classifier name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed document classifier information. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public DocumentClassifierDetails getClassifier(String classifierId) { + // Generated convenience method for getClassifierWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getClassifierWithResponse(classifierId, requestOptions) + .getValue() + .toObject(DocumentClassifierDetails.class); + } + + /** + * List all document classifiers. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listClassifiers() { + // Generated convenience method for listClassifiers + RequestOptions requestOptions = new RequestOptions(); + return serviceClient + .listClassifiers(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(DocumentClassifierDetails.class)); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteClassifier(String classifierId) { + // Generated convenience method for deleteClassifierWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteClassifierWithResponse(classifierId, requestOptions).getValue(); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClientBuilder.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClientBuilder.java new file mode 100644 index 000000000000..411e65bc7174 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/DocumentModelAdministrationClientBuilder.java @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.implementation.DocumentModelAdministrationClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A builder for creating a new instance of the DocumentModelAdministrationClient type. */ +@ServiceClientBuilder( + serviceClients = {DocumentModelAdministrationClient.class, DocumentModelAdministrationAsyncClient.class}) +public final class DocumentModelAdministrationClientBuilder + implements HttpTrait, + ConfigurationTrait, + TokenCredentialTrait, + KeyCredentialTrait, + EndpointTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] {"https://cognitiveservices.azure.com/.default"}; + + @Generated + private static final Map PROPERTIES = + CoreUtils.getProperties("azure-ai-documentintelligence.properties"); + + @Generated private final List pipelinePolicies; + + /** Create an instance of the DocumentModelAdministrationClientBuilder. */ + @Generated + public DocumentModelAdministrationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated private HttpPipeline pipeline; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated private ClientOptions clientOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated private RetryOptions retryOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated private Configuration configuration; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated private TokenCredential tokenCredential; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated private KeyCredential keyCredential; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated private String endpoint; + + /** {@inheritDoc}. */ + @Generated + @Override + public DocumentModelAdministrationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated private DocumentIntelligenceServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the DocumentModelAdministrationClientBuilder. + */ + @Generated + public DocumentModelAdministrationClientBuilder serviceVersion(DocumentIntelligenceServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the DocumentModelAdministrationClientBuilder. + */ + @Generated + public DocumentModelAdministrationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of DocumentModelAdministrationClientImpl with the provided parameters. + * + * @return an instance of DocumentModelAdministrationClientImpl. + */ + @Generated + private DocumentModelAdministrationClientImpl buildInnerClient() { + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + DocumentIntelligenceServiceVersion localServiceVersion = + (serviceVersion != null) ? serviceVersion : DocumentIntelligenceServiceVersion.getLatest(); + DocumentModelAdministrationClientImpl client = + new DocumentModelAdministrationClientImpl( + localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), + this.endpoint, + localServiceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + localClientOptions + .getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("Ocp-Apim-Subscription-Key", keyCredential)); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of DocumentModelAdministrationAsyncClient class. + * + * @return an instance of DocumentModelAdministrationAsyncClient. + */ + @Generated + public DocumentModelAdministrationAsyncClient buildAsyncClient() { + return new DocumentModelAdministrationAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of DocumentModelAdministrationClient class. + * + * @return an instance of DocumentModelAdministrationClient. + */ + @Generated + public DocumentModelAdministrationClient buildClient() { + return new DocumentModelAdministrationClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DocumentModelAdministrationClientBuilder.class); +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentAnalysisClientImpl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentAnalysisClientImpl.java new file mode 100644 index 000000000000..7d02159da53c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentAnalysisClientImpl.java @@ -0,0 +1,879 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.implementation; + +import com.azure.ai.documentintelligence.DocumentIntelligenceServiceVersion; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.DefaultPollingStrategy; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncDefaultPollingStrategy; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the DocumentAnalysisClient type. */ +public final class DocumentAnalysisClientImpl { + /** The proxy service used to perform REST calls. */ + private final DocumentAnalysisClientService service; + + /** The Document Intelligence service endpoint. */ + private final String endpoint; + + /** + * Gets The Document Intelligence service endpoint. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Service version. */ + private final DocumentIntelligenceServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DocumentIntelligenceServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of DocumentAnalysisClient client. + * + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentAnalysisClientImpl(String endpoint, DocumentIntelligenceServiceVersion serviceVersion) { + this( + new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), + endpoint, + serviceVersion); + } + + /** + * Initializes an instance of DocumentAnalysisClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentAnalysisClientImpl( + HttpPipeline httpPipeline, String endpoint, DocumentIntelligenceServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of DocumentAnalysisClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentAnalysisClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String endpoint, + DocumentIntelligenceServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = + RestProxy.create(DocumentAnalysisClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for DocumentAnalysisClient to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}/documentintelligence") + @ServiceInterface(name = "DocumentAnalysisClie") + public interface DocumentAnalysisClientService { + @Post("/documentModels/{modelId}:analyze") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> analyzeDocument( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("content-type") String contentType, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels/{modelId}:analyze") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response analyzeDocumentSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("content-type") String contentType, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Post("/documentClassifiers/{classifierId}:analyze") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> classifyDocument( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("content-type") String contentType, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData classifyRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentClassifiers/{classifierId}:analyze") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response classifyDocumentSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("content-type") String contentType, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData classifyRequest, + RequestOptions requestOptions, + Context context); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> analyzeDocumentWithResponseAsync(String modelId, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback( + requestLocal -> { + if (requestLocal.getBody() != null + && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return FluxUtil.withContext( + context -> + service.analyzeDocument( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + contentType, + accept, + requestOptionsLocal, + context)); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response analyzeDocumentWithResponse(String modelId, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback( + requestLocal -> { + if (requestLocal.getBody() != null + && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.analyzeDocumentSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + contentType, + accept, + requestOptionsLocal, + Context.NONE); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginAnalyzeDocumentAsync(String modelId, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.analyzeDocumentWithResponseAsync(modelId, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginAnalyzeDocument(String modelId, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.analyzeDocumentWithResponse(modelId, requestOptions), + new SyncDefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginAnalyzeDocumentWithModelAsync( + String modelId, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.analyzeDocumentWithResponseAsync(modelId, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(AnalyzeResultOperation.class), + TypeReference.createInstance(AnalyzeResult.class)); + } + + /** + * Analyzes document with document model. + * + *

Query Parameters + * + * + * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
pagesStringNoList of 1-based page numbers to analyze. Ex. "1-3,5,7-9"
localeStringNoLocale hint for text recognition and document analysis. Value may contain only + * the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
featuresList<String>NoList of optional analysis features. In the form of "," separated string.
queryFieldsList<String>NoList of additional fields to extract. Ex. "NumberOfGuests,StoreNumber". In the form of "," separated string.
outputContentFormatStringNoFormat of the analyze result top-level content. Allowed values: "text", "markdown".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginAnalyzeDocumentWithModel( + String modelId, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.analyzeDocumentWithResponse(modelId, requestOptions), + new SyncDefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(AnalyzeResultOperation.class), + TypeReference.createInstance(AnalyzeResult.class)); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> classifyDocumentWithResponseAsync( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.classifyDocument( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + contentType, + accept, + classifyRequest, + requestOptions, + context)); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response classifyDocumentWithResponse( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.classifyDocumentSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + contentType, + accept, + classifyRequest, + requestOptions, + Context.NONE); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginClassifyDocumentAsync( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.classifyDocumentWithResponseAsync(classifierId, classifyRequest, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginClassifyDocument( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.classifyDocumentWithResponse(classifierId, classifyRequest, requestOptions), + new SyncDefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginClassifyDocumentWithModelAsync( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.classifyDocumentWithResponseAsync(classifierId, classifyRequest, requestOptions), + new DefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(AnalyzeResultOperation.class), + TypeReference.createInstance(AnalyzeResult.class)); + } + + /** + * Classifies document with document classifier. + * + *

Query Parameters + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
stringIndexTypeStringNoMethod used to compute string offset and length. Allowed values: "textElements", "unicodeCodePoint", "utf16CodeUnit".
splitStringNoDocument splitting mode. Allowed values: "auto", "none", "perPage".
+ * + * You can add these to a request with {@link RequestOptions#addQueryParam} + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     urlSource: String (Optional)
+     *     base64Source: byte[] (Optional)
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param classifyRequest Classify request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginClassifyDocumentWithModel( + String classifierId, BinaryData classifyRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.classifyDocumentWithResponse(classifierId, classifyRequest, requestOptions), + new SyncDefaultPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(AnalyzeResultOperation.class), + TypeReference.createInstance(AnalyzeResult.class)); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentModelAdministrationClientImpl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentModelAdministrationClientImpl.java new file mode 100644 index 000000000000..88a6a85bbb17 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentModelAdministrationClientImpl.java @@ -0,0 +1,3675 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.implementation; + +import com.azure.ai.documentintelligence.DocumentIntelligenceServiceVersion; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the DocumentModelAdministrationClient type. */ +public final class DocumentModelAdministrationClientImpl { + /** The proxy service used to perform REST calls. */ + private final DocumentModelAdministrationClientService service; + + /** The Document Intelligence service endpoint. */ + private final String endpoint; + + /** + * Gets The Document Intelligence service endpoint. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Service version. */ + private final DocumentIntelligenceServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public DocumentIntelligenceServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of DocumentModelAdministrationClient client. + * + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentModelAdministrationClientImpl(String endpoint, DocumentIntelligenceServiceVersion serviceVersion) { + this( + new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), + endpoint, + serviceVersion); + } + + /** + * Initializes an instance of DocumentModelAdministrationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentModelAdministrationClientImpl( + HttpPipeline httpPipeline, String endpoint, DocumentIntelligenceServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of DocumentModelAdministrationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint The Document Intelligence service endpoint. + * @param serviceVersion Service version. + */ + public DocumentModelAdministrationClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String endpoint, + DocumentIntelligenceServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.service = + RestProxy.create( + DocumentModelAdministrationClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for DocumentModelAdministrationClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}/documentintelligence") + @ServiceInterface(name = "DocumentModelAdminis") + public interface DocumentModelAdministrationClientService { + @Post("/documentModels:build") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> buildDocumentModel( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData buildRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels:build") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response buildDocumentModelSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData buildRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels:compose") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> composeModel( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData composeRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels:compose") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response composeModelSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData composeRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels:authorizeCopy") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> authorizeModelCopy( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData authorizeCopyRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels:authorizeCopy") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response authorizeModelCopySync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData authorizeCopyRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels/{modelId}:copyTo") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> copyModelTo( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData copyToRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentModels/{modelId}:copyTo") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response copyModelToSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData copyToRequest, + RequestOptions requestOptions, + Context context); + + @Get("/documentModels/{modelId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getModel( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentModels/{modelId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getModelSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentModels") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listModels( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentModels") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listModelsSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Delete("/documentModels/{modelId}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteModel( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Delete("/documentModels/{modelId}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteModelSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("modelId") String modelId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/info") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getResourceInfo( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/info") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getResourceInfoSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/operations/{operationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getOperation( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("operationId") String operationId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/operations/{operationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getOperationSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("operationId") String operationId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listOperations( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listOperationsSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Post("/documentClassifiers:build") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> buildClassifier( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData buildRequest, + RequestOptions requestOptions, + Context context); + + @Post("/documentClassifiers:build") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response buildClassifierSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData buildRequest, + RequestOptions requestOptions, + Context context); + + @Get("/documentClassifiers/{classifierId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getClassifier( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentClassifiers/{classifierId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getClassifierSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentClassifiers") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listClassifiers( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/documentClassifiers") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listClassifiersSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Delete("/documentClassifiers/{classifierId}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteClassifier( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Delete("/documentClassifiers/{classifierId}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteClassifierSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("classifierId") String classifierId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listModelsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listModelsNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listOperationsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listOperationsNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listClassifiersNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listClassifiersNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> buildDocumentModelWithResponseAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.buildDocumentModel( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + buildRequest, + requestOptions, + context)); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response buildDocumentModelWithResponse(BinaryData buildRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.buildDocumentModelSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + buildRequest, + requestOptions, + Context.NONE); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildDocumentModelAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.buildDocumentModelWithResponseAsync(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildDocumentModel( + BinaryData buildRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.buildDocumentModelWithResponse(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildDocumentModelWithModelAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.buildDocumentModelWithResponseAsync(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Builds a custom document analysis model. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     buildMode: String(template/neural) (Required)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildDocumentModelWithModel( + BinaryData buildRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.buildDocumentModelWithResponse(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> composeModelWithResponseAsync( + BinaryData composeRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.composeModel( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + composeRequest, + requestOptions, + context)); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response composeModelWithResponse(BinaryData composeRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.composeModelSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + composeRequest, + requestOptions, + Context.NONE); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginComposeModelAsync( + BinaryData composeRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.composeModelWithResponseAsync(composeRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginComposeModel( + BinaryData composeRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.composeModelWithResponse(composeRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginComposeModelWithModelAsync( + BinaryData composeRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.composeModelWithResponseAsync(composeRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Creates a new document model from document types of existing document models. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     componentModels (Required): [
+     *          (Required){
+     *             modelId: String (Required)
+     *         }
+     *     ]
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + * @param composeRequest Compose request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginComposeModelWithModel( + BinaryData composeRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.composeModelWithResponse(composeRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param authorizeCopyRequest Authorize copy request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return authorization to copy a document model to the specified target resource and modelId along with {@link + * Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> authorizeModelCopyWithResponseAsync( + BinaryData authorizeCopyRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.authorizeModelCopy( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + authorizeCopyRequest, + requestOptions, + context)); + } + + /** + * Generates authorization to copy a document model to this location with specified modelId and optional + * description. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param authorizeCopyRequest Authorize copy request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return authorization to copy a document model to the specified target resource and modelId along with {@link + * Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response authorizeModelCopyWithResponse( + BinaryData authorizeCopyRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.authorizeModelCopySync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + authorizeCopyRequest, + requestOptions, + Context.NONE); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> copyModelToWithResponseAsync( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.copyModelTo( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + copyToRequest, + requestOptions, + context)); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response copyModelToWithResponse( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.copyModelToSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + copyToRequest, + requestOptions, + Context.NONE); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCopyModelToAsync( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.copyModelToWithResponseAsync(modelId, copyToRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCopyModelTo( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.copyModelToWithResponse(modelId, copyToRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginCopyModelToWithModelAsync( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.copyModelToWithResponseAsync(modelId, copyToRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Copies document model to the target resource, region, and modelId. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     targetResourceId: String (Required)
+     *     targetResourceRegion: String (Required)
+     *     targetModelId: String (Required)
+     *     targetModelLocation: String (Required)
+     *     accessToken: String (Required)
+     *     expirationDateTime: OffsetDateTime (Required)
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param copyToRequest Copy to request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginCopyModelToWithModel( + String modelId, BinaryData copyToRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.copyModelToWithResponse(modelId, copyToRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentModelDetails.class)); + } + + /** + * Gets detailed document model information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document model information along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getModelWithResponseAsync(String modelId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getModel( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + requestOptions, + context)); + } + + /** + * Gets detailed document model information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document model information along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getModelWithResponse(String modelId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + requestOptions, + Context.NONE); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listModelsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listModels( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listModelsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedFlux<>( + () -> listModelsSinglePageAsync(requestOptions), + nextLink -> listModelsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listModelsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listModelsSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * List all document models. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listModels(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedIterable<>( + () -> listModelsSinglePage(requestOptions), + nextLink -> listModelsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteModelWithResponseAsync(String modelId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.deleteModel( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + requestOptions, + context)); + } + + /** + * Deletes document model. + * + * @param modelId Unique document model name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteModelWithResponse(String modelId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteModelSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + modelId, + accept, + requestOptions, + Context.NONE); + } + + /** + * Return information about the current resource. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     customDocumentModels (Required): {
+     *         count: int (Required)
+     *         limit: int (Required)
+     *     }
+     *     customNeuralDocumentModelBuilds (Required): {
+     *         used: int (Required)
+     *         quota: int (Required)
+     *         quotaResetDateTime: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return general information regarding the current resource along with {@link Response} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getResourceInfoWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getResourceInfo( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)); + } + + /** + * Return information about the current resource. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     customDocumentModels (Required): {
+     *         count: int (Required)
+     *         limit: int (Required)
+     *     }
+     *     customNeuralDocumentModelBuilds (Required): {
+     *         used: int (Required)
+     *         quota: int (Required)
+     *         quotaResetDateTime: OffsetDateTime (Required)
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return general information regarding the current resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getResourceInfoWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getResourceInfoSync( + this.getEndpoint(), this.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + } + + /** + * Gets operation info. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param operationId Operation ID. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return operation info along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOperationWithResponseAsync(String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getOperation( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + operationId, + accept, + requestOptions, + context)); + } + + /** + * Gets operation info. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param operationId Operation ID. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return operation info along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getOperationWithResponse(String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getOperationSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + operationId, + accept, + requestOptions, + Context.NONE); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listOperationsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listOperations( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listOperationsAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedFlux<>( + () -> listOperationsSinglePageAsync(requestOptions), + nextLink -> listOperationsNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listOperationsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listOperationsSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * Lists all operations. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listOperations(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedIterable<>( + () -> listOperationsSinglePage(requestOptions), + nextLink -> listOperationsNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> buildClassifierWithResponseAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.buildClassifier( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + buildRequest, + requestOptions, + context)); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response buildClassifierWithResponse(BinaryData buildRequest, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.buildClassifierSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + buildRequest, + requestOptions, + Context.NONE); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildClassifierAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.buildClassifierWithResponseAsync(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildClassifier( + BinaryData buildRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.buildClassifierWithResponse(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginBuildClassifierWithModelAsync( + BinaryData buildRequest, RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> this.buildClassifierWithResponseAsync(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentClassifierDetails.class)); + } + + /** + * Builds a custom document classifier. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param buildRequest Build request parameters. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginBuildClassifierWithModel( + BinaryData buildRequest, RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.buildClassifierWithResponse(buildRequest, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint( + "{endpoint}/documentintelligence".replace("{endpoint}", this.getEndpoint())) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE) + .setServiceVersion(this.getServiceVersion().getVersion())), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(DocumentClassifierDetails.class)); + } + + /** + * Gets detailed document classifier information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document classifier information along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getClassifierWithResponseAsync( + String classifierId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getClassifier( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + accept, + requestOptions, + context)); + } + + /** + * Gets detailed document classifier information. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed document classifier information along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getClassifierSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + accept, + requestOptions, + Context.NONE); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listClassifiersSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listClassifiers( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listClassifiersAsync(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedFlux<>( + () -> listClassifiersSinglePageAsync(requestOptions), + nextLink -> listClassifiersNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listClassifiersSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listClassifiersSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + requestOptions, + Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * List all document classifiers. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listClassifiers(RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedIterable<>( + () -> listClassifiersSinglePage(requestOptions), + nextLink -> listClassifiersNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteClassifierWithResponseAsync(String classifierId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.deleteClassifier( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + accept, + requestOptions, + context)); + } + + /** + * Deletes document classifier. + * + * @param classifierId Unique document classifier name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteClassifierWithResponse(String classifierId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteClassifierSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + classifierId, + accept, + requestOptions, + Context.NONE); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listModelsNextSinglePageAsync( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listModelsNext(nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     modelId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     buildMode: String(template/neural) (Optional)
+     *     azureBlobSource (Optional): {
+     *         containerUrl: String (Required)
+     *         prefix: String (Optional)
+     *     }
+     *     azureBlobFileListSource (Optional): {
+     *         containerUrl: String (Required)
+     *         fileList: String (Required)
+     *     }
+     *     docTypes (Optional): {
+     *         String (Optional): {
+     *             description: String (Optional)
+     *             buildMode: String(template/neural) (Optional)
+     *             fieldSchema (Required): {
+     *                 String (Required): {
+     *                     type: String(string/date/time/phoneNumber/number/integer/selectionMark/countryRegion/signature/array/object/currency/address/boolean) (Required)
+     *                     description: String (Optional)
+     *                     example: String (Optional)
+     *                     items (Optional): (recursive schema, see items above)
+     *                     properties (Optional): {
+     *                         String (Optional): (recursive schema, see String above)
+     *                     }
+     *                 }
+     *             }
+     *             fieldConfidence (Optional): {
+     *                 String: double (Optional)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentModelDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listModelsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listModelsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listOperationsNextSinglePageAsync( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listOperationsNext( + nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     operationId: String (Required)
+     *     status: String(notStarted/running/failed/succeeded/canceled) (Required)
+     *     percentCompleted: Integer (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     lastUpdatedDateTime: OffsetDateTime (Required)
+     *     resourceLocation: String (Required)
+     *     apiVersion: String (Optional)
+     *     tags (Optional): {
+     *         String: String (Optional)
+     *     }
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             message: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of OperationDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listOperationsNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listOperationsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listClassifiersNextSinglePageAsync( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listClassifiersNext( + nextLink, this.getEndpoint(), accept, requestOptions, context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     classifierId: String (Required)
+     *     description: String (Optional)
+     *     createdDateTime: OffsetDateTime (Required)
+     *     expirationDateTime: OffsetDateTime (Optional)
+     *     apiVersion: String (Required)
+     *     docTypes (Required): {
+     *         String (Required): {
+     *             sourceKind: String(url/base64/azureBlob/azureBlobFileList) (Optional)
+     *             azureBlobSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 prefix: String (Optional)
+     *             }
+     *             azureBlobFileListSource (Optional): {
+     *                 containerUrl: String (Required)
+     *                 fileList: String (Required)
+     *             }
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of DocumentClassifierDetails items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listClassifiersNextSinglePage(String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listClassifiersNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/package-info.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/package-info.java new file mode 100644 index 000000000000..6722303da5d4 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for DocumentIntelligence. Extracts content, layout, and structured data from + * documents. + */ +package com.azure.ai.documentintelligence.implementation; diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AddressValue.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AddressValue.java new file mode 100644 index 000000000000..a4131e3c6c9b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AddressValue.java @@ -0,0 +1,257 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Address field value. */ +@Immutable +public final class AddressValue { + /* + * House or building number. + */ + @Generated + @JsonProperty(value = "houseNumber") + private String houseNumber; + + /* + * Post office box number. + */ + @Generated + @JsonProperty(value = "poBox") + private String poBox; + + /* + * Street name. + */ + @Generated + @JsonProperty(value = "road") + private String road; + + /* + * Name of city, town, village, etc. + */ + @Generated + @JsonProperty(value = "city") + private String city; + + /* + * First-level administrative division. + */ + @Generated + @JsonProperty(value = "state") + private String state; + + /* + * Postal code used for mail sorting. + */ + @Generated + @JsonProperty(value = "postalCode") + private String postalCode; + + /* + * Country/region. + */ + @Generated + @JsonProperty(value = "countryRegion") + private String countryRegion; + + /* + * Street-level address, excluding city, state, countryRegion, and postalCode. + */ + @Generated + @JsonProperty(value = "streetAddress") + private String streetAddress; + + /* + * Apartment or office number + */ + @Generated + @JsonProperty(value = "unit") + private String unit; + + /* + * Districts or boroughs within a city, such as Brooklyn in New York City or City + * of Westminster in London. + */ + @Generated + @JsonProperty(value = "cityDistrict") + private String cityDistrict; + + /* + * Second-level administrative division used in certain locales. + */ + @Generated + @JsonProperty(value = "stateDistrict") + private String stateDistrict; + + /* + * Unofficial neighborhood name, like Chinatown. + */ + @Generated + @JsonProperty(value = "suburb") + private String suburb; + + /* + * Build name, such as World Trade Center. + */ + @Generated + @JsonProperty(value = "house") + private String house; + + /* + * Floor number, such as 3F. + */ + @Generated + @JsonProperty(value = "level") + private String level; + + /** Creates an instance of AddressValue class. */ + @Generated + private AddressValue() {} + + /** + * Get the houseNumber property: House or building number. + * + * @return the houseNumber value. + */ + @Generated + public String getHouseNumber() { + return this.houseNumber; + } + + /** + * Get the poBox property: Post office box number. + * + * @return the poBox value. + */ + @Generated + public String getPoBox() { + return this.poBox; + } + + /** + * Get the road property: Street name. + * + * @return the road value. + */ + @Generated + public String getRoad() { + return this.road; + } + + /** + * Get the city property: Name of city, town, village, etc. + * + * @return the city value. + */ + @Generated + public String getCity() { + return this.city; + } + + /** + * Get the state property: First-level administrative division. + * + * @return the state value. + */ + @Generated + public String getState() { + return this.state; + } + + /** + * Get the postalCode property: Postal code used for mail sorting. + * + * @return the postalCode value. + */ + @Generated + public String getPostalCode() { + return this.postalCode; + } + + /** + * Get the countryRegion property: Country/region. + * + * @return the countryRegion value. + */ + @Generated + public String getCountryRegion() { + return this.countryRegion; + } + + /** + * Get the streetAddress property: Street-level address, excluding city, state, countryRegion, and postalCode. + * + * @return the streetAddress value. + */ + @Generated + public String getStreetAddress() { + return this.streetAddress; + } + + /** + * Get the unit property: Apartment or office number. + * + * @return the unit value. + */ + @Generated + public String getUnit() { + return this.unit; + } + + /** + * Get the cityDistrict property: Districts or boroughs within a city, such as Brooklyn in New York City or City of + * Westminster in London. + * + * @return the cityDistrict value. + */ + @Generated + public String getCityDistrict() { + return this.cityDistrict; + } + + /** + * Get the stateDistrict property: Second-level administrative division used in certain locales. + * + * @return the stateDistrict value. + */ + @Generated + public String getStateDistrict() { + return this.stateDistrict; + } + + /** + * Get the suburb property: Unofficial neighborhood name, like Chinatown. + * + * @return the suburb value. + */ + @Generated + public String getSuburb() { + return this.suburb; + } + + /** + * Get the house property: Build name, such as World Trade Center. + * + * @return the house value. + */ + @Generated + public String getHouse() { + return this.house; + } + + /** + * Get the level property: Floor number, such as 3F. + * + * @return the level value. + */ + @Generated + public String getLevel() { + return this.level; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeDocumentRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeDocumentRequest.java new file mode 100644 index 000000000000..09871604c8ea --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeDocumentRequest.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Document analysis parameters. */ +@Fluent +public final class AnalyzeDocumentRequest { + /* + * Document URL to analyze. Either urlSource or base64Source must be specified. + */ + @Generated + @JsonProperty(value = "urlSource") + private String urlSource; + + /* + * Base64 encoding of the document to analyze. Either urlSource or base64Source + * must be specified. + */ + @Generated + @JsonProperty(value = "base64Source") + private byte[] base64Source; + + /** Creates an instance of AnalyzeDocumentRequest class. */ + @Generated + public AnalyzeDocumentRequest() {} + + /** + * Get the urlSource property: Document URL to analyze. Either urlSource or base64Source must be specified. + * + * @return the urlSource value. + */ + @Generated + public String getUrlSource() { + return this.urlSource; + } + + /** + * Set the urlSource property: Document URL to analyze. Either urlSource or base64Source must be specified. + * + * @param urlSource the urlSource value to set. + * @return the AnalyzeDocumentRequest object itself. + */ + @Generated + public AnalyzeDocumentRequest setUrlSource(String urlSource) { + this.urlSource = urlSource; + return this; + } + + /** + * Get the base64Source property: Base64 encoding of the document to analyze. Either urlSource or base64Source must + * be specified. + * + * @return the base64Source value. + */ + @Generated + public byte[] getBase64Source() { + return CoreUtils.clone(this.base64Source); + } + + /** + * Set the base64Source property: Base64 encoding of the document to analyze. Either urlSource or base64Source must + * be specified. + * + * @param base64Source the base64Source value to set. + * @return the AnalyzeDocumentRequest object itself. + */ + @Generated + public AnalyzeDocumentRequest setBase64Source(byte[] base64Source) { + this.base64Source = CoreUtils.clone(base64Source); + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResult.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResult.java new file mode 100644 index 000000000000..bd34022507d0 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResult.java @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Document analysis result. */ +@Immutable +public final class AnalyzeResult { + /* + * API version used to produce this result. + */ + @Generated + @JsonProperty(value = "apiVersion") + private String apiVersion; + + /* + * Document model ID used to produce this result. + */ + @Generated + @JsonProperty(value = "modelId") + private String modelId; + + /* + * Method used to compute string offset and length. + */ + @Generated + @JsonProperty(value = "stringIndexType") + private StringIndexType stringIndexType; + + /* + * Format of the analyze result top-level content. + */ + @Generated + @JsonProperty(value = "contentFormat") + private ContentFormat contentFormat; + + /* + * Concatenate string representation of all textual and visual elements in reading + * order. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Analyzed pages. + */ + @Generated + @JsonProperty(value = "pages") + private List pages; + + /* + * Extracted paragraphs. + */ + @Generated + @JsonProperty(value = "paragraphs") + private List paragraphs; + + /* + * Extracted tables. + */ + @Generated + @JsonProperty(value = "tables") + private List tables; + + /* + * Extracted figures. + */ + @Generated + @JsonProperty(value = "figures") + private List figures; + + /* + * Extracted lists. + */ + @Generated + @JsonProperty(value = "lists") + private List lists; + + /* + * Extracted sections. + */ + @Generated + @JsonProperty(value = "sections") + private List sections; + + /* + * Extracted key-value pairs. + */ + @Generated + @JsonProperty(value = "keyValuePairs") + private List keyValuePairs; + + /* + * Extracted font styles. + */ + @Generated + @JsonProperty(value = "styles") + private List styles; + + /* + * Detected languages. + */ + @Generated + @JsonProperty(value = "languages") + private List languages; + + /* + * Extracted documents. + */ + @Generated + @JsonProperty(value = "documents") + private List documents; + + /** + * Creates an instance of AnalyzeResult class. + * + * @param apiVersion the apiVersion value to set. + * @param modelId the modelId value to set. + * @param stringIndexType the stringIndexType value to set. + * @param content the content value to set. + * @param pages the pages value to set. + */ + @Generated + @JsonCreator + private AnalyzeResult( + @JsonProperty(value = "apiVersion") String apiVersion, + @JsonProperty(value = "modelId") String modelId, + @JsonProperty(value = "stringIndexType") StringIndexType stringIndexType, + @JsonProperty(value = "content") String content, + @JsonProperty(value = "pages") List pages) { + this.apiVersion = apiVersion; + this.modelId = modelId; + this.stringIndexType = stringIndexType; + this.content = content; + this.pages = pages; + } + + /** + * Get the apiVersion property: API version used to produce this result. + * + * @return the apiVersion value. + */ + @Generated + public String getApiVersion() { + return this.apiVersion; + } + + /** + * Get the modelId property: Document model ID used to produce this result. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } + + /** + * Get the stringIndexType property: Method used to compute string offset and length. + * + * @return the stringIndexType value. + */ + @Generated + public StringIndexType getStringIndexType() { + return this.stringIndexType; + } + + /** + * Get the contentFormat property: Format of the analyze result top-level content. + * + * @return the contentFormat value. + */ + @Generated + public ContentFormat getContentFormat() { + return this.contentFormat; + } + + /** + * Get the content property: Concatenate string representation of all textual and visual elements in reading order. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the pages property: Analyzed pages. + * + * @return the pages value. + */ + @Generated + public List getPages() { + return this.pages; + } + + /** + * Get the paragraphs property: Extracted paragraphs. + * + * @return the paragraphs value. + */ + @Generated + public List getParagraphs() { + return this.paragraphs; + } + + /** + * Get the tables property: Extracted tables. + * + * @return the tables value. + */ + @Generated + public List getTables() { + return this.tables; + } + + /** + * Get the figures property: Extracted figures. + * + * @return the figures value. + */ + @Generated + public List getFigures() { + return this.figures; + } + + /** + * Get the lists property: Extracted lists. + * + * @return the lists value. + */ + @Generated + public List getLists() { + return this.lists; + } + + /** + * Get the sections property: Extracted sections. + * + * @return the sections value. + */ + @Generated + public List getSections() { + return this.sections; + } + + /** + * Get the keyValuePairs property: Extracted key-value pairs. + * + * @return the keyValuePairs value. + */ + @Generated + public List getKeyValuePairs() { + return this.keyValuePairs; + } + + /** + * Get the styles property: Extracted font styles. + * + * @return the styles value. + */ + @Generated + public List getStyles() { + return this.styles; + } + + /** + * Get the languages property: Detected languages. + * + * @return the languages value. + */ + @Generated + public List getLanguages() { + return this.languages; + } + + /** + * Get the documents property: Extracted documents. + * + * @return the documents value. + */ + @Generated + public List getDocuments() { + return this.documents; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResultOperation.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResultOperation.java new file mode 100644 index 000000000000..9ed4aa7df51b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AnalyzeResultOperation.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Status and result of the analyze operation. */ +@Immutable +public final class AnalyzeResultOperation { + /* + * Operation status. + */ + @Generated + @JsonProperty(value = "status") + private OperationStatus status; + + /* + * Date and time (UTC) when the analyze operation was submitted. + */ + @Generated + @JsonProperty(value = "createdDateTime") + private OffsetDateTime createdDateTime; + + /* + * Date and time (UTC) when the status was last updated. + */ + @Generated + @JsonProperty(value = "lastUpdatedDateTime") + private OffsetDateTime lastUpdatedDateTime; + + /* + * Encountered error during document analysis. + */ + @Generated + @JsonProperty(value = "error") + private Error error; + + /* + * Document analysis result. + */ + @Generated + @JsonProperty(value = "analyzeResult") + private AnalyzeResult analyzeResult; + + /** + * Creates an instance of AnalyzeResultOperation class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + */ + @Generated + @JsonCreator + private AnalyzeResultOperation( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime) { + this.status = status; + this.createdDateTime = createdDateTime; + this.lastUpdatedDateTime = lastUpdatedDateTime; + } + + /** + * Get the status property: Operation status. + * + * @return the status value. + */ + @Generated + public OperationStatus getStatus() { + return this.status; + } + + /** + * Get the createdDateTime property: Date and time (UTC) when the analyze operation was submitted. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the lastUpdatedDateTime property: Date and time (UTC) when the status was last updated. + * + * @return the lastUpdatedDateTime value. + */ + @Generated + public OffsetDateTime getLastUpdatedDateTime() { + return this.lastUpdatedDateTime; + } + + /** + * Get the error property: Encountered error during document analysis. + * + * @return the error value. + */ + @Generated + public Error getError() { + return this.error; + } + + /** + * Get the analyzeResult property: Document analysis result. + * + * @return the analyzeResult value. + */ + @Generated + public AnalyzeResult getAnalyzeResult() { + return this.analyzeResult; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AuthorizeCopyRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AuthorizeCopyRequest.java new file mode 100644 index 000000000000..47fae46c6d64 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AuthorizeCopyRequest.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Request body to authorize document model copy. */ +@Fluent +public final class AuthorizeCopyRequest { + /* + * Unique document model name. + */ + @Generated + @JsonProperty(value = "modelId") + private String modelId; + + /* + * Document model description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * List of key-value tag attributes associated with the document model. + */ + @Generated + @JsonProperty(value = "tags") + private Map tags; + + /** + * Creates an instance of AuthorizeCopyRequest class. + * + * @param modelId the modelId value to set. + */ + @Generated + @JsonCreator + public AuthorizeCopyRequest(@JsonProperty(value = "modelId") String modelId) { + this.modelId = modelId; + } + + /** + * Get the modelId property: Unique document model name. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } + + /** + * Get the description property: Document model description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: Document model description. + * + * @param description the description value to set. + * @return the AuthorizeCopyRequest object itself. + */ + @Generated + public AuthorizeCopyRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the tags property: List of key-value tag attributes associated with the document model. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Set the tags property: List of key-value tag attributes associated with the document model. + * + * @param tags the tags value to set. + * @return the AuthorizeCopyRequest object itself. + */ + @Generated + public AuthorizeCopyRequest setTags(Map tags) { + this.tags = tags; + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobContentSource.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobContentSource.java new file mode 100644 index 000000000000..124f37ec6528 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobContentSource.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Azure Blob Storage content. */ +@Fluent +public final class AzureBlobContentSource { + /* + * Azure Blob Storage container URL. + */ + @Generated + @JsonProperty(value = "containerUrl") + private String containerUrl; + + /* + * Blob name prefix. + */ + @Generated + @JsonProperty(value = "prefix") + private String prefix; + + /** + * Creates an instance of AzureBlobContentSource class. + * + * @param containerUrl the containerUrl value to set. + */ + @Generated + @JsonCreator + public AzureBlobContentSource(@JsonProperty(value = "containerUrl") String containerUrl) { + this.containerUrl = containerUrl; + } + + /** + * Get the containerUrl property: Azure Blob Storage container URL. + * + * @return the containerUrl value. + */ + @Generated + public String getContainerUrl() { + return this.containerUrl; + } + + /** + * Get the prefix property: Blob name prefix. + * + * @return the prefix value. + */ + @Generated + public String getPrefix() { + return this.prefix; + } + + /** + * Set the prefix property: Blob name prefix. + * + * @param prefix the prefix value to set. + * @return the AzureBlobContentSource object itself. + */ + @Generated + public AzureBlobContentSource setPrefix(String prefix) { + this.prefix = prefix; + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobFileListContentSource.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobFileListContentSource.java new file mode 100644 index 000000000000..7acd63a3fe41 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/AzureBlobFileListContentSource.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** File list in Azure Blob Storage. */ +@Immutable +public final class AzureBlobFileListContentSource { + /* + * Azure Blob Storage container URL. + */ + @Generated + @JsonProperty(value = "containerUrl") + private String containerUrl; + + /* + * Path to a JSONL file within the container specifying a subset of documents. + */ + @Generated + @JsonProperty(value = "fileList") + private String fileList; + + /** + * Creates an instance of AzureBlobFileListContentSource class. + * + * @param containerUrl the containerUrl value to set. + * @param fileList the fileList value to set. + */ + @Generated + @JsonCreator + public AzureBlobFileListContentSource( + @JsonProperty(value = "containerUrl") String containerUrl, + @JsonProperty(value = "fileList") String fileList) { + this.containerUrl = containerUrl; + this.fileList = fileList; + } + + /** + * Get the containerUrl property: Azure Blob Storage container URL. + * + * @return the containerUrl value. + */ + @Generated + public String getContainerUrl() { + return this.containerUrl; + } + + /** + * Get the fileList property: Path to a JSONL file within the container specifying a subset of documents. + * + * @return the fileList value. + */ + @Generated + public String getFileList() { + return this.fileList; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BoundingRegion.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BoundingRegion.java new file mode 100644 index 000000000000..b67dc31612bd --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BoundingRegion.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Bounding polygon on a specific page of the input. */ +@Immutable +public final class BoundingRegion { + /* + * 1-based page number of page containing the bounding region. + */ + @Generated + @JsonProperty(value = "pageNumber") + private int pageNumber; + + /* + * Bounding polygon on the page, or the entire page if not specified. + * Coordinates specified relative to the top-left of the page. The numbers + * represent the x, y values of the polygon vertices, clockwise from the left + * (-180 degrees inclusive) relative to the element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /** + * Creates an instance of BoundingRegion class. + * + * @param pageNumber the pageNumber value to set. + * @param polygon the polygon value to set. + */ + @Generated + @JsonCreator + private BoundingRegion( + @JsonProperty(value = "pageNumber") int pageNumber, @JsonProperty(value = "polygon") List polygon) { + this.pageNumber = pageNumber; + this.polygon = polygon; + } + + /** + * Get the pageNumber property: 1-based page number of page containing the bounding region. + * + * @return the pageNumber value. + */ + @Generated + public int getPageNumber() { + return this.pageNumber; + } + + /** + * Get the polygon property: Bounding polygon on the page, or the entire page if not specified. Coordinates + * specified relative to the top-left of the page. The numbers represent the x, y values of the polygon vertices, + * clockwise from the left (-180 degrees inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentClassifierRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentClassifierRequest.java new file mode 100644 index 000000000000..0ce31d48258a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentClassifierRequest.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Request body to build a new custom document classifier. */ +@Fluent +public final class BuildDocumentClassifierRequest { + /* + * Unique document classifier name. + */ + @Generated + @JsonProperty(value = "classifierId") + private String classifierId; + + /* + * Document classifier description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * List of document types to classify against. + */ + @Generated + @JsonProperty(value = "docTypes") + private Map docTypes; + + /** + * Creates an instance of BuildDocumentClassifierRequest class. + * + * @param classifierId the classifierId value to set. + * @param docTypes the docTypes value to set. + */ + @Generated + @JsonCreator + public BuildDocumentClassifierRequest( + @JsonProperty(value = "classifierId") String classifierId, + @JsonProperty(value = "docTypes") Map docTypes) { + this.classifierId = classifierId; + this.docTypes = docTypes; + } + + /** + * Get the classifierId property: Unique document classifier name. + * + * @return the classifierId value. + */ + @Generated + public String getClassifierId() { + return this.classifierId; + } + + /** + * Get the description property: Document classifier description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: Document classifier description. + * + * @param description the description value to set. + * @return the BuildDocumentClassifierRequest object itself. + */ + @Generated + public BuildDocumentClassifierRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the docTypes property: List of document types to classify against. + * + * @return the docTypes value. + */ + @Generated + public Map getDocTypes() { + return this.docTypes; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentModelRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentModelRequest.java new file mode 100644 index 000000000000..433bb7baf805 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/BuildDocumentModelRequest.java @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Request body to build a new custom document model. */ +@Fluent +public final class BuildDocumentModelRequest { + /* + * Unique document model name. + */ + @Generated + @JsonProperty(value = "modelId") + private String modelId; + + /* + * Document model description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * Custom document model build mode. + */ + @Generated + @JsonProperty(value = "buildMode") + private DocumentBuildMode buildMode; + + /* + * Azure Blob Storage location containing the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + */ + @Generated + @JsonProperty(value = "azureBlobSource") + private AzureBlobContentSource azureBlobSource; + + /* + * Azure Blob Storage file list specifying the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + */ + @Generated + @JsonProperty(value = "azureBlobFileListSource") + private AzureBlobFileListContentSource azureBlobFileListSource; + + /* + * List of key-value tag attributes associated with the document model. + */ + @Generated + @JsonProperty(value = "tags") + private Map tags; + + /** + * Creates an instance of BuildDocumentModelRequest class. + * + * @param modelId the modelId value to set. + * @param buildMode the buildMode value to set. + */ + @Generated + @JsonCreator + public BuildDocumentModelRequest( + @JsonProperty(value = "modelId") String modelId, + @JsonProperty(value = "buildMode") DocumentBuildMode buildMode) { + this.modelId = modelId; + this.buildMode = buildMode; + } + + /** + * Get the modelId property: Unique document model name. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } + + /** + * Get the description property: Document model description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: Document model description. + * + * @param description the description value to set. + * @return the BuildDocumentModelRequest object itself. + */ + @Generated + public BuildDocumentModelRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the buildMode property: Custom document model build mode. + * + * @return the buildMode value. + */ + @Generated + public DocumentBuildMode getBuildMode() { + return this.buildMode; + } + + /** + * Get the azureBlobSource property: Azure Blob Storage location containing the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobSource value. + */ + @Generated + public AzureBlobContentSource getAzureBlobSource() { + return this.azureBlobSource; + } + + /** + * Set the azureBlobSource property: Azure Blob Storage location containing the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @param azureBlobSource the azureBlobSource value to set. + * @return the BuildDocumentModelRequest object itself. + */ + @Generated + public BuildDocumentModelRequest setAzureBlobSource(AzureBlobContentSource azureBlobSource) { + this.azureBlobSource = azureBlobSource; + return this; + } + + /** + * Get the azureBlobFileListSource property: Azure Blob Storage file list specifying the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobFileListSource value. + */ + @Generated + public AzureBlobFileListContentSource getAzureBlobFileListSource() { + return this.azureBlobFileListSource; + } + + /** + * Set the azureBlobFileListSource property: Azure Blob Storage file list specifying the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @param azureBlobFileListSource the azureBlobFileListSource value to set. + * @return the BuildDocumentModelRequest object itself. + */ + @Generated + public BuildDocumentModelRequest setAzureBlobFileListSource( + AzureBlobFileListContentSource azureBlobFileListSource) { + this.azureBlobFileListSource = azureBlobFileListSource; + return this; + } + + /** + * Get the tags property: List of key-value tag attributes associated with the document model. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Set the tags property: List of key-value tag attributes associated with the document model. + * + * @param tags the tags value to set. + * @return the BuildDocumentModelRequest object itself. + */ + @Generated + public BuildDocumentModelRequest setTags(Map tags) { + this.tags = tags; + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifierDocumentTypeDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifierDocumentTypeDetails.java new file mode 100644 index 000000000000..c1257327fe97 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifierDocumentTypeDetails.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Classifier document type info. */ +@Fluent +public final class ClassifierDocumentTypeDetails { + /* + * Type of training data source. + */ + @Generated + @JsonProperty(value = "sourceKind") + private ContentSourceKind sourceKind; + + /* + * Azure Blob Storage location containing the training data for a classifier + * document type. Either azureBlobSource or azureBlobFileListSource must be + * specified. + */ + @Generated + @JsonProperty(value = "azureBlobSource") + private AzureBlobContentSource azureBlobSource; + + /* + * Azure Blob Storage file list specifying the training data for a classifier + * document type. Either azureBlobSource or azureBlobFileListSource must be + * specified. + */ + @Generated + @JsonProperty(value = "azureBlobFileListSource") + private AzureBlobFileListContentSource azureBlobFileListSource; + + /** Creates an instance of ClassifierDocumentTypeDetails class. */ + @Generated + public ClassifierDocumentTypeDetails() {} + + /** + * Get the sourceKind property: Type of training data source. + * + * @return the sourceKind value. + */ + @Generated + public ContentSourceKind getSourceKind() { + return this.sourceKind; + } + + /** + * Set the sourceKind property: Type of training data source. + * + * @param sourceKind the sourceKind value to set. + * @return the ClassifierDocumentTypeDetails object itself. + */ + @Generated + public ClassifierDocumentTypeDetails setSourceKind(ContentSourceKind sourceKind) { + this.sourceKind = sourceKind; + return this; + } + + /** + * Get the azureBlobSource property: Azure Blob Storage location containing the training data for a classifier + * document type. Either azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobSource value. + */ + @Generated + public AzureBlobContentSource getAzureBlobSource() { + return this.azureBlobSource; + } + + /** + * Set the azureBlobSource property: Azure Blob Storage location containing the training data for a classifier + * document type. Either azureBlobSource or azureBlobFileListSource must be specified. + * + * @param azureBlobSource the azureBlobSource value to set. + * @return the ClassifierDocumentTypeDetails object itself. + */ + @Generated + public ClassifierDocumentTypeDetails setAzureBlobSource(AzureBlobContentSource azureBlobSource) { + this.azureBlobSource = azureBlobSource; + return this; + } + + /** + * Get the azureBlobFileListSource property: Azure Blob Storage file list specifying the training data for a + * classifier document type. Either azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobFileListSource value. + */ + @Generated + public AzureBlobFileListContentSource getAzureBlobFileListSource() { + return this.azureBlobFileListSource; + } + + /** + * Set the azureBlobFileListSource property: Azure Blob Storage file list specifying the training data for a + * classifier document type. Either azureBlobSource or azureBlobFileListSource must be specified. + * + * @param azureBlobFileListSource the azureBlobFileListSource value to set. + * @return the ClassifierDocumentTypeDetails object itself. + */ + @Generated + public ClassifierDocumentTypeDetails setAzureBlobFileListSource( + AzureBlobFileListContentSource azureBlobFileListSource) { + this.azureBlobFileListSource = azureBlobFileListSource; + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifyDocumentRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifyDocumentRequest.java new file mode 100644 index 000000000000..831ded860be6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ClassifyDocumentRequest.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Document classification parameters. */ +@Fluent +public final class ClassifyDocumentRequest { + /* + * Document URL to classify. Either urlSource or base64Source must be specified. + */ + @Generated + @JsonProperty(value = "urlSource") + private String urlSource; + + /* + * Base64 encoding of the document to classify. Either urlSource or base64Source + * must be specified. + */ + @Generated + @JsonProperty(value = "base64Source") + private byte[] base64Source; + + /** Creates an instance of ClassifyDocumentRequest class. */ + @Generated + public ClassifyDocumentRequest() {} + + /** + * Get the urlSource property: Document URL to classify. Either urlSource or base64Source must be specified. + * + * @return the urlSource value. + */ + @Generated + public String getUrlSource() { + return this.urlSource; + } + + /** + * Set the urlSource property: Document URL to classify. Either urlSource or base64Source must be specified. + * + * @param urlSource the urlSource value to set. + * @return the ClassifyDocumentRequest object itself. + */ + @Generated + public ClassifyDocumentRequest setUrlSource(String urlSource) { + this.urlSource = urlSource; + return this; + } + + /** + * Get the base64Source property: Base64 encoding of the document to classify. Either urlSource or base64Source must + * be specified. + * + * @return the base64Source value. + */ + @Generated + public byte[] getBase64Source() { + return CoreUtils.clone(this.base64Source); + } + + /** + * Set the base64Source property: Base64 encoding of the document to classify. Either urlSource or base64Source must + * be specified. + * + * @param base64Source the base64Source value to set. + * @return the ClassifyDocumentRequest object itself. + */ + @Generated + public ClassifyDocumentRequest setBase64Source(byte[] base64Source) { + this.base64Source = CoreUtils.clone(base64Source); + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComponentDocumentModelDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComponentDocumentModelDetails.java new file mode 100644 index 000000000000..c2b275961514 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComponentDocumentModelDetails.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A component of a composed document model. */ +@Immutable +public final class ComponentDocumentModelDetails { + /* + * Unique document model name. + */ + @Generated + @JsonProperty(value = "modelId") + private String modelId; + + /** + * Creates an instance of ComponentDocumentModelDetails class. + * + * @param modelId the modelId value to set. + */ + @Generated + @JsonCreator + public ComponentDocumentModelDetails(@JsonProperty(value = "modelId") String modelId) { + this.modelId = modelId; + } + + /** + * Get the modelId property: Unique document model name. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComposeDocumentModelRequest.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComposeDocumentModelRequest.java new file mode 100644 index 000000000000..1d3b3ae7b4e2 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ComposeDocumentModelRequest.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Map; + +/** Request body to create a composed document model from component document models. */ +@Fluent +public final class ComposeDocumentModelRequest { + /* + * Unique document model name. + */ + @Generated + @JsonProperty(value = "modelId") + private String modelId; + + /* + * Document model description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * List of component document models to compose. + */ + @Generated + @JsonProperty(value = "componentModels") + private List componentModels; + + /* + * List of key-value tag attributes associated with the document model. + */ + @Generated + @JsonProperty(value = "tags") + private Map tags; + + /** + * Creates an instance of ComposeDocumentModelRequest class. + * + * @param modelId the modelId value to set. + * @param componentModels the componentModels value to set. + */ + @Generated + @JsonCreator + public ComposeDocumentModelRequest( + @JsonProperty(value = "modelId") String modelId, + @JsonProperty(value = "componentModels") List componentModels) { + this.modelId = modelId; + this.componentModels = componentModels; + } + + /** + * Get the modelId property: Unique document model name. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } + + /** + * Get the description property: Document model description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: Document model description. + * + * @param description the description value to set. + * @return the ComposeDocumentModelRequest object itself. + */ + @Generated + public ComposeDocumentModelRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the componentModels property: List of component document models to compose. + * + * @return the componentModels value. + */ + @Generated + public List getComponentModels() { + return this.componentModels; + } + + /** + * Get the tags property: List of key-value tag attributes associated with the document model. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Set the tags property: List of key-value tag attributes associated with the document model. + * + * @param tags the tags value to set. + * @return the ComposeDocumentModelRequest object itself. + */ + @Generated + public ComposeDocumentModelRequest setTags(Map tags) { + this.tags = tags; + return this; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentFormat.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentFormat.java new file mode 100644 index 000000000000..4cb060b4cdf6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentFormat.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Format of the content in analyzed result. */ +public final class ContentFormat extends ExpandableStringEnum { + /** Plain text representation of the document content without any formatting. */ + @Generated public static final ContentFormat TEXT = fromString("text"); + + /** Markdown representation of the document content with section headings, tables, etc. */ + @Generated public static final ContentFormat MARKDOWN = fromString("markdown"); + + /** + * Creates a new instance of ContentFormat value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ContentFormat() {} + + /** + * Creates or finds a ContentFormat from its string representation. + * + * @param name a name to look for. + * @return the corresponding ContentFormat. + */ + @Generated + @JsonCreator + public static ContentFormat fromString(String name) { + return fromString(name, ContentFormat.class); + } + + /** + * Gets known ContentFormat values. + * + * @return known ContentFormat values. + */ + @Generated + public static Collection values() { + return values(ContentFormat.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentSourceKind.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentSourceKind.java new file mode 100644 index 000000000000..fa8ca4ffed93 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ContentSourceKind.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Type of content source. */ +public final class ContentSourceKind extends ExpandableStringEnum { + /** Content at a specific URL. */ + @Generated public static final ContentSourceKind URL = fromString("url"); + + /** Content represented via Base64 encoding. */ + @Generated public static final ContentSourceKind BASE64 = fromString("base64"); + + /** Files in a path within an Azure Blob Storage container. */ + @Generated public static final ContentSourceKind AZURE_BLOB = fromString("azureBlob"); + + /** A file list specifying individual files in an Azure Blob Storage container. */ + @Generated public static final ContentSourceKind AZURE_BLOB_FILE_LIST = fromString("azureBlobFileList"); + + /** + * Creates a new instance of ContentSourceKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ContentSourceKind() {} + + /** + * Creates or finds a ContentSourceKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding ContentSourceKind. + */ + @Generated + @JsonCreator + public static ContentSourceKind fromString(String name) { + return fromString(name, ContentSourceKind.class); + } + + /** + * Gets known ContentSourceKind values. + * + * @return known ContentSourceKind values. + */ + @Generated + public static Collection values() { + return values(ContentSourceKind.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CopyAuthorization.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CopyAuthorization.java new file mode 100644 index 000000000000..207372671138 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CopyAuthorization.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Authorization to copy a document model to the specified target resource and modelId. */ +@Immutable +public final class CopyAuthorization { + /* + * ID of the target Azure resource where the document model should be copied to. + */ + @Generated + @JsonProperty(value = "targetResourceId") + private String targetResourceId; + + /* + * Location of the target Azure resource where the document model should be copied + * to. + */ + @Generated + @JsonProperty(value = "targetResourceRegion") + private String targetResourceRegion; + + /* + * Identifier of the target document model. + */ + @Generated + @JsonProperty(value = "targetModelId") + private String targetModelId; + + /* + * URL of the copied document model in the target account. + */ + @Generated + @JsonProperty(value = "targetModelLocation") + private String targetModelLocation; + + /* + * Token used to authorize the request. + */ + @Generated + @JsonProperty(value = "accessToken") + private String accessToken; + + /* + * Date/time when the access token expires. + */ + @Generated + @JsonProperty(value = "expirationDateTime") + private OffsetDateTime expirationDateTime; + + /** + * Creates an instance of CopyAuthorization class. + * + * @param targetResourceId the targetResourceId value to set. + * @param targetResourceRegion the targetResourceRegion value to set. + * @param targetModelId the targetModelId value to set. + * @param targetModelLocation the targetModelLocation value to set. + * @param accessToken the accessToken value to set. + * @param expirationDateTime the expirationDateTime value to set. + */ + @Generated + @JsonCreator + public CopyAuthorization( + @JsonProperty(value = "targetResourceId") String targetResourceId, + @JsonProperty(value = "targetResourceRegion") String targetResourceRegion, + @JsonProperty(value = "targetModelId") String targetModelId, + @JsonProperty(value = "targetModelLocation") String targetModelLocation, + @JsonProperty(value = "accessToken") String accessToken, + @JsonProperty(value = "expirationDateTime") OffsetDateTime expirationDateTime) { + this.targetResourceId = targetResourceId; + this.targetResourceRegion = targetResourceRegion; + this.targetModelId = targetModelId; + this.targetModelLocation = targetModelLocation; + this.accessToken = accessToken; + this.expirationDateTime = expirationDateTime; + } + + /** + * Get the targetResourceId property: ID of the target Azure resource where the document model should be copied to. + * + * @return the targetResourceId value. + */ + @Generated + public String getTargetResourceId() { + return this.targetResourceId; + } + + /** + * Get the targetResourceRegion property: Location of the target Azure resource where the document model should be + * copied to. + * + * @return the targetResourceRegion value. + */ + @Generated + public String getTargetResourceRegion() { + return this.targetResourceRegion; + } + + /** + * Get the targetModelId property: Identifier of the target document model. + * + * @return the targetModelId value. + */ + @Generated + public String getTargetModelId() { + return this.targetModelId; + } + + /** + * Get the targetModelLocation property: URL of the copied document model in the target account. + * + * @return the targetModelLocation value. + */ + @Generated + public String getTargetModelLocation() { + return this.targetModelLocation; + } + + /** + * Get the accessToken property: Token used to authorize the request. + * + * @return the accessToken value. + */ + @Generated + public String getAccessToken() { + return this.accessToken; + } + + /** + * Get the expirationDateTime property: Date/time when the access token expires. + * + * @return the expirationDateTime value. + */ + @Generated + public OffsetDateTime getExpirationDateTime() { + return this.expirationDateTime; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CurrencyValue.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CurrencyValue.java new file mode 100644 index 000000000000..f3da4c2abeab --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CurrencyValue.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Currency field value. */ +@Immutable +public final class CurrencyValue { + /* + * Currency amount. + */ + @Generated + @JsonProperty(value = "amount") + private double amount; + + /* + * Currency symbol label, if any. + */ + @Generated + @JsonProperty(value = "currencySymbol") + private String currencySymbol; + + /* + * Resolved currency code (ISO 4217), if any. + */ + @Generated + @JsonProperty(value = "currencyCode") + private String currencyCode; + + /** + * Creates an instance of CurrencyValue class. + * + * @param amount the amount value to set. + */ + @Generated + @JsonCreator + private CurrencyValue(@JsonProperty(value = "amount") double amount) { + this.amount = amount; + } + + /** + * Get the amount property: Currency amount. + * + * @return the amount value. + */ + @Generated + public double getAmount() { + return this.amount; + } + + /** + * Get the currencySymbol property: Currency symbol label, if any. + * + * @return the currencySymbol value. + */ + @Generated + public String getCurrencySymbol() { + return this.currencySymbol; + } + + /** + * Get the currencyCode property: Resolved currency code (ISO 4217), if any. + * + * @return the currencyCode value. + */ + @Generated + public String getCurrencyCode() { + return this.currencyCode; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CustomDocumentModelsDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CustomDocumentModelsDetails.java new file mode 100644 index 000000000000..5ce09fb67ed5 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/CustomDocumentModelsDetails.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Details regarding custom document models. */ +@Immutable +public final class CustomDocumentModelsDetails { + /* + * Number of custom document models in the current resource. + */ + @Generated + @JsonProperty(value = "count") + private int count; + + /* + * Maximum number of custom document models supported in the current resource. + */ + @Generated + @JsonProperty(value = "limit") + private int limit; + + /** + * Creates an instance of CustomDocumentModelsDetails class. + * + * @param count the count value to set. + * @param limit the limit value to set. + */ + @Generated + @JsonCreator + private CustomDocumentModelsDetails( + @JsonProperty(value = "count") int count, @JsonProperty(value = "limit") int limit) { + this.count = count; + this.limit = limit; + } + + /** + * Get the count property: Number of custom document models in the current resource. + * + * @return the count value. + */ + @Generated + public int getCount() { + return this.count; + } + + /** + * Get the limit property: Maximum number of custom document models supported in the current resource. + * + * @return the limit value. + */ + @Generated + public int getLimit() { + return this.limit; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Document.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Document.java new file mode 100644 index 000000000000..05900113f246 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Document.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Map; + +/** An object describing the location and semantic content of a document. */ +@Immutable +public final class Document { + /* + * Document type. + */ + @Generated + @JsonProperty(value = "docType") + private String docType; + + /* + * Bounding regions covering the document. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the document in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Dictionary of named field values. + */ + @Generated + @JsonProperty(value = "fields") + private Map fields; + + /* + * Confidence of correctly extracting the document. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of Document class. + * + * @param docType the docType value to set. + * @param spans the spans value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private Document( + @JsonProperty(value = "docType") String docType, + @JsonProperty(value = "spans") List spans, + @JsonProperty(value = "confidence") double confidence) { + this.docType = docType; + this.spans = spans; + this.confidence = confidence; + } + + /** + * Get the docType property: Document type. + * + * @return the docType value. + */ + @Generated + public String getDocType() { + return this.docType; + } + + /** + * Get the boundingRegions property: Bounding regions covering the document. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the document in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the fields property: Dictionary of named field values. + * + * @return the fields value. + */ + @Generated + public Map getFields() { + return this.fields; + } + + /** + * Get the confidence property: Confidence of correctly extracting the document. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentAnalysisFeature.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentAnalysisFeature.java new file mode 100644 index 000000000000..969c00e1f18e --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentAnalysisFeature.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Document analysis features to enable. */ +public final class DocumentAnalysisFeature extends ExpandableStringEnum { + /** Perform OCR at a higher resolution to handle documents with fine print. */ + @Generated public static final DocumentAnalysisFeature OCR_HIGH_RESOLUTION = fromString("ocrHighResolution"); + + /** Enable the detection of the text content language. */ + @Generated public static final DocumentAnalysisFeature LANGUAGES = fromString("languages"); + + /** Enable the detection of barcodes in the document. */ + @Generated public static final DocumentAnalysisFeature BARCODES = fromString("barcodes"); + + /** Enable the detection of mathematical expressions in the document. */ + @Generated public static final DocumentAnalysisFeature FORMULAS = fromString("formulas"); + + /** Enable the detection of general key value pairs (form fields) in the document. */ + @Generated public static final DocumentAnalysisFeature KEY_VALUE_PAIRS = fromString("keyValuePairs"); + + /** Enable the recognition of various font styles. */ + @Generated public static final DocumentAnalysisFeature STYLE_FONT = fromString("styleFont"); + + /** Enable the extraction of additional fields via the queryFields query parameter. */ + @Generated public static final DocumentAnalysisFeature QUERY_FIELDS = fromString("queryFields"); + + /** + * Creates a new instance of DocumentAnalysisFeature value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentAnalysisFeature() {} + + /** + * Creates or finds a DocumentAnalysisFeature from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentAnalysisFeature. + */ + @Generated + @JsonCreator + public static DocumentAnalysisFeature fromString(String name) { + return fromString(name, DocumentAnalysisFeature.class); + } + + /** + * Gets known DocumentAnalysisFeature values. + * + * @return known DocumentAnalysisFeature values. + */ + @Generated + public static Collection values() { + return values(DocumentAnalysisFeature.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcode.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcode.java new file mode 100644 index 000000000000..06515314be5e --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcode.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A barcode object. */ +@Immutable +public final class DocumentBarcode { + /* + * Barcode kind. + */ + @Generated + @JsonProperty(value = "kind") + private DocumentBarcodeKind kind; + + /* + * Barcode value. + */ + @Generated + @JsonProperty(value = "value") + private String value; + + /* + * Bounding polygon of the barcode, with coordinates specified relative to the + * top-left of the page. The numbers represent the x, y values of the polygon + * vertices, clockwise from the left (-180 degrees inclusive) relative to the + * element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /* + * Location of the barcode in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "span") + private DocumentSpan span; + + /* + * Confidence of correctly extracting the barcode. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentBarcode class. + * + * @param kind the kind value to set. + * @param value the value value to set. + * @param span the span value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentBarcode( + @JsonProperty(value = "kind") DocumentBarcodeKind kind, + @JsonProperty(value = "value") String value, + @JsonProperty(value = "span") DocumentSpan span, + @JsonProperty(value = "confidence") double confidence) { + this.kind = kind; + this.value = value; + this.span = span; + this.confidence = confidence; + } + + /** + * Get the kind property: Barcode kind. + * + * @return the kind value. + */ + @Generated + public DocumentBarcodeKind getKind() { + return this.kind; + } + + /** + * Get the value property: Barcode value. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * Get the polygon property: Bounding polygon of the barcode, with coordinates specified relative to the top-left of + * the page. The numbers represent the x, y values of the polygon vertices, clockwise from the left (-180 degrees + * inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } + + /** + * Get the span property: Location of the barcode in the reading order concatenated content. + * + * @return the span value. + */ + @Generated + public DocumentSpan getSpan() { + return this.span; + } + + /** + * Get the confidence property: Confidence of correctly extracting the barcode. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcodeKind.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcodeKind.java new file mode 100644 index 000000000000..66172fffa3e3 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBarcodeKind.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Barcode kind. */ +public final class DocumentBarcodeKind extends ExpandableStringEnum { + /** QR code, as defined in ISO/IEC 18004:2015. */ + @Generated public static final DocumentBarcodeKind QRCODE = fromString("QRCode"); + + /** PDF417, as defined in ISO 15438. */ + @Generated public static final DocumentBarcodeKind PDF417 = fromString("PDF417"); + + /** GS1 12-digit Universal Product Code. */ + @Generated public static final DocumentBarcodeKind UPCA = fromString("UPCA"); + + /** GS1 6-digit Universal Product Code. */ + @Generated public static final DocumentBarcodeKind UPCE = fromString("UPCE"); + + /** Code 39 barcode, as defined in ISO/IEC 16388:2007. */ + @Generated public static final DocumentBarcodeKind CODE39 = fromString("Code39"); + + /** Code 128 barcode, as defined in ISO/IEC 15417:2007. */ + @Generated public static final DocumentBarcodeKind CODE128 = fromString("Code128"); + + /** GS1 8-digit International Article Number (European Article Number). */ + @Generated public static final DocumentBarcodeKind EAN8 = fromString("EAN8"); + + /** GS1 13-digit International Article Number (European Article Number). */ + @Generated public static final DocumentBarcodeKind EAN13 = fromString("EAN13"); + + /** GS1 DataBar barcode. */ + @Generated public static final DocumentBarcodeKind DATA_BAR = fromString("DataBar"); + + /** Code 93 barcode, as defined in ANSI/AIM BC5-1995. */ + @Generated public static final DocumentBarcodeKind CODE93 = fromString("Code93"); + + /** Codabar barcode, as defined in ANSI/AIM BC3-1995. */ + @Generated public static final DocumentBarcodeKind CODABAR = fromString("Codabar"); + + /** GS1 DataBar Expanded barcode. */ + @Generated public static final DocumentBarcodeKind DATA_BAR_EXPANDED = fromString("DataBarExpanded"); + + /** Interleaved 2 of 5 barcode, as defined in ANSI/AIM BC2-1995. */ + @Generated public static final DocumentBarcodeKind ITF = fromString("ITF"); + + /** Micro QR code, as defined in ISO/IEC 23941:2022. */ + @Generated public static final DocumentBarcodeKind MICRO_QRCODE = fromString("MicroQRCode"); + + /** Aztec code, as defined in ISO/IEC 24778:2008. */ + @Generated public static final DocumentBarcodeKind AZTEC = fromString("Aztec"); + + /** Data matrix code, as defined in ISO/IEC 16022:2006. */ + @Generated public static final DocumentBarcodeKind DATA_MATRIX = fromString("DataMatrix"); + + /** MaxiCode, as defined in ISO/IEC 16023:2000. */ + @Generated public static final DocumentBarcodeKind MAXI_CODE = fromString("MaxiCode"); + + /** + * Creates a new instance of DocumentBarcodeKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentBarcodeKind() {} + + /** + * Creates or finds a DocumentBarcodeKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentBarcodeKind. + */ + @Generated + @JsonCreator + public static DocumentBarcodeKind fromString(String name) { + return fromString(name, DocumentBarcodeKind.class); + } + + /** + * Gets known DocumentBarcodeKind values. + * + * @return known DocumentBarcodeKind values. + */ + @Generated + public static Collection values() { + return values(DocumentBarcodeKind.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBuildMode.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBuildMode.java new file mode 100644 index 000000000000..2d511828e503 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentBuildMode.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Custom document model build mode. */ +public final class DocumentBuildMode extends ExpandableStringEnum { + /** Target documents with similar visual templates. */ + @Generated public static final DocumentBuildMode TEMPLATE = fromString("template"); + + /** Support documents with diverse visual templates. */ + @Generated public static final DocumentBuildMode NEURAL = fromString("neural"); + + /** + * Creates a new instance of DocumentBuildMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentBuildMode() {} + + /** + * Creates or finds a DocumentBuildMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentBuildMode. + */ + @Generated + @JsonCreator + public static DocumentBuildMode fromString(String name) { + return fromString(name, DocumentBuildMode.class); + } + + /** + * Gets known DocumentBuildMode values. + * + * @return known DocumentBuildMode values. + */ + @Generated + public static Collection values() { + return values(DocumentBuildMode.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentCaption.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentCaption.java new file mode 100644 index 000000000000..8c96345fed8d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentCaption.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A caption object describing a table or figure. */ +@Immutable +public final class DocumentCaption { + /* + * Content of the caption. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the caption. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the caption in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the caption. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /** + * Creates an instance of DocumentCaption class. + * + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentCaption( + @JsonProperty(value = "content") String content, @JsonProperty(value = "spans") List spans) { + this.content = content; + this.spans = spans; + } + + /** + * Get the content property: Content of the caption. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the caption. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the caption in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the caption. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierBuildOperationDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierBuildOperationDetails.java new file mode 100644 index 000000000000..5420294fb57e --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierBuildOperationDetails.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; + +/** Get Operation response object. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("documentClassifierBuild") +@Immutable +public final class DocumentClassifierBuildOperationDetails extends OperationDetails { + /* + * Operation result upon success. + */ + @Generated + @JsonProperty(value = "result") + private DocumentClassifierDetails result; + + /** + * Creates an instance of DocumentClassifierBuildOperationDetails class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + * @param resourceLocation the resourceLocation value to set. + */ + @Generated + @JsonCreator + private DocumentClassifierBuildOperationDetails( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime, + @JsonProperty(value = "resourceLocation") String resourceLocation) { + super(status, createdDateTime, lastUpdatedDateTime, resourceLocation); + } + + /** + * Get the result property: Operation result upon success. + * + * @return the result value. + */ + @Generated + public DocumentClassifierDetails getResult() { + return this.result; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierDetails.java new file mode 100644 index 000000000000..a8c5bff585e1 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentClassifierDetails.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.Map; + +/** Document classifier info. */ +@Immutable +public final class DocumentClassifierDetails { + /* + * Unique document classifier name. + */ + @Generated + @JsonProperty(value = "classifierId", access = JsonProperty.Access.WRITE_ONLY) + private String classifierId; + + /* + * Document classifier description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * Date and time (UTC) when the document classifier was created. + */ + @Generated + @JsonProperty(value = "createdDateTime") + private OffsetDateTime createdDateTime; + + /* + * Date and time (UTC) when the document classifier will expire. + */ + @Generated + @JsonProperty(value = "expirationDateTime") + private OffsetDateTime expirationDateTime; + + /* + * API version used to create this document classifier. + */ + @Generated + @JsonProperty(value = "apiVersion") + private String apiVersion; + + /* + * List of document types to classify against. + */ + @Generated + @JsonProperty(value = "docTypes") + private Map docTypes; + + /** + * Creates an instance of DocumentClassifierDetails class. + * + * @param createdDateTime the createdDateTime value to set. + * @param apiVersion the apiVersion value to set. + * @param docTypes the docTypes value to set. + */ + @Generated + @JsonCreator + private DocumentClassifierDetails( + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "apiVersion") String apiVersion, + @JsonProperty(value = "docTypes") Map docTypes) { + this.createdDateTime = createdDateTime; + this.apiVersion = apiVersion; + this.docTypes = docTypes; + } + + /** + * Get the classifierId property: Unique document classifier name. + * + * @return the classifierId value. + */ + @Generated + public String getClassifierId() { + return this.classifierId; + } + + /** + * Get the description property: Document classifier description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the createdDateTime property: Date and time (UTC) when the document classifier was created. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the expirationDateTime property: Date and time (UTC) when the document classifier will expire. + * + * @return the expirationDateTime value. + */ + @Generated + public OffsetDateTime getExpirationDateTime() { + return this.expirationDateTime; + } + + /** + * Get the apiVersion property: API version used to create this document classifier. + * + * @return the apiVersion value. + */ + @Generated + public String getApiVersion() { + return this.apiVersion; + } + + /** + * Get the docTypes property: List of document types to classify against. + * + * @return the docTypes value. + */ + @Generated + public Map getDocTypes() { + return this.docTypes; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentField.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentField.java new file mode 100644 index 000000000000..7b2567bfb215 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentField.java @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +/** An object representing the content and location of a field value. */ +@Immutable +public final class DocumentField { + /* + * Data type of the field value. + */ + @Generated + @JsonProperty(value = "type") + private DocumentFieldType type; + + /* + * String value. + */ + @Generated + @JsonProperty(value = "valueString") + private String valueString; + + /* + * Date value in YYYY-MM-DD format (ISO 8601). + */ + @Generated + @JsonProperty(value = "valueDate") + private LocalDate valueDate; + + /* + * Time value in hh:mm:ss format (ISO 8601). + */ + @Generated + @JsonProperty(value = "valueTime") + private String valueTime; + + /* + * Phone number value in E.164 format (ex. +19876543210). + */ + @Generated + @JsonProperty(value = "valuePhoneNumber") + private String valuePhoneNumber; + + /* + * Floating point value. + */ + @Generated + @JsonProperty(value = "valueNumber") + private Double valueNumber; + + /* + * Integer value. + */ + @Generated + @JsonProperty(value = "valueInteger") + private Long valueInteger; + + /* + * Selection mark value. + */ + @Generated + @JsonProperty(value = "valueSelectionMark") + private DocumentSelectionMarkState valueSelectionMark; + + /* + * Presence of signature. + */ + @Generated + @JsonProperty(value = "valueSignature") + private DocumentSignatureType valueSignature; + + /* + * 3-letter country code value (ISO 3166-1 alpha-3). + */ + @Generated + @JsonProperty(value = "valueCountryRegion") + private String valueCountryRegion; + + /* + * Array of field values. + */ + @Generated + @JsonProperty(value = "valueArray") + private List valueArray; + + /* + * Dictionary of named field values. + */ + @Generated + @JsonProperty(value = "valueObject") + private Map valueObject; + + /* + * Currency value. + */ + @Generated + @JsonProperty(value = "valueCurrency") + private CurrencyValue valueCurrency; + + /* + * Address value. + */ + @Generated + @JsonProperty(value = "valueAddress") + private AddressValue valueAddress; + + /* + * Boolean value. + */ + @Generated + @JsonProperty(value = "valueBoolean") + private Boolean valueBoolean; + + /* + * Field content. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the field. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the field in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Confidence of correctly extracting the field. + */ + @Generated + @JsonProperty(value = "confidence") + private Double confidence; + + /** + * Creates an instance of DocumentField class. + * + * @param type the type value to set. + */ + @Generated + @JsonCreator + private DocumentField(@JsonProperty(value = "type") DocumentFieldType type) { + this.type = type; + } + + /** + * Get the type property: Data type of the field value. + * + * @return the type value. + */ + @Generated + public DocumentFieldType getType() { + return this.type; + } + + /** + * Get the valueString property: String value. + * + * @return the valueString value. + */ + @Generated + public String getValueString() { + return this.valueString; + } + + /** + * Get the valueDate property: Date value in YYYY-MM-DD format (ISO 8601). + * + * @return the valueDate value. + */ + @Generated + public LocalDate getValueDate() { + return this.valueDate; + } + + /** + * Get the valueTime property: Time value in hh:mm:ss format (ISO 8601). + * + * @return the valueTime value. + */ + @Generated + public String getValueTime() { + return this.valueTime; + } + + /** + * Get the valuePhoneNumber property: Phone number value in E.164 format (ex. +19876543210). + * + * @return the valuePhoneNumber value. + */ + @Generated + public String getValuePhoneNumber() { + return this.valuePhoneNumber; + } + + /** + * Get the valueNumber property: Floating point value. + * + * @return the valueNumber value. + */ + @Generated + public Double getValueNumber() { + return this.valueNumber; + } + + /** + * Get the valueInteger property: Integer value. + * + * @return the valueInteger value. + */ + @Generated + public Long getValueInteger() { + return this.valueInteger; + } + + /** + * Get the valueSelectionMark property: Selection mark value. + * + * @return the valueSelectionMark value. + */ + @Generated + public DocumentSelectionMarkState getValueSelectionMark() { + return this.valueSelectionMark; + } + + /** + * Get the valueSignature property: Presence of signature. + * + * @return the valueSignature value. + */ + @Generated + public DocumentSignatureType getValueSignature() { + return this.valueSignature; + } + + /** + * Get the valueCountryRegion property: 3-letter country code value (ISO 3166-1 alpha-3). + * + * @return the valueCountryRegion value. + */ + @Generated + public String getValueCountryRegion() { + return this.valueCountryRegion; + } + + /** + * Get the valueArray property: Array of field values. + * + * @return the valueArray value. + */ + @Generated + public List getValueArray() { + return this.valueArray; + } + + /** + * Get the valueObject property: Dictionary of named field values. + * + * @return the valueObject value. + */ + @Generated + public Map getValueObject() { + return this.valueObject; + } + + /** + * Get the valueCurrency property: Currency value. + * + * @return the valueCurrency value. + */ + @Generated + public CurrencyValue getValueCurrency() { + return this.valueCurrency; + } + + /** + * Get the valueAddress property: Address value. + * + * @return the valueAddress value. + */ + @Generated + public AddressValue getValueAddress() { + return this.valueAddress; + } + + /** + * Get the valueBoolean property: Boolean value. + * + * @return the valueBoolean value. + */ + @Generated + public Boolean isValueBoolean() { + return this.valueBoolean; + } + + /** + * Get the content property: Field content. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the field. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the field in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the confidence property: Confidence of correctly extracting the field. + * + * @return the confidence value. + */ + @Generated + public Double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldSchema.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldSchema.java new file mode 100644 index 000000000000..52f7cf1d52a1 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldSchema.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Description of the field semantic schema using a JSON Schema style syntax. */ +@Immutable +public final class DocumentFieldSchema { + /* + * Semantic data type of the field value. + */ + @Generated + @JsonProperty(value = "type") + private DocumentFieldType type; + + /* + * Field description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * Example field content. + */ + @Generated + @JsonProperty(value = "example") + private String example; + + /* + * Field type schema of each array element. + */ + @Generated + @JsonProperty(value = "items") + private DocumentFieldSchema items; + + /* + * Named sub-fields of the object field. + */ + @Generated + @JsonProperty(value = "properties") + private Map properties; + + /** + * Creates an instance of DocumentFieldSchema class. + * + * @param type the type value to set. + */ + @Generated + @JsonCreator + private DocumentFieldSchema(@JsonProperty(value = "type") DocumentFieldType type) { + this.type = type; + } + + /** + * Get the type property: Semantic data type of the field value. + * + * @return the type value. + */ + @Generated + public DocumentFieldType getType() { + return this.type; + } + + /** + * Get the description property: Field description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the example property: Example field content. + * + * @return the example value. + */ + @Generated + public String getExample() { + return this.example; + } + + /** + * Get the items property: Field type schema of each array element. + * + * @return the items value. + */ + @Generated + public DocumentFieldSchema getItems() { + return this.items; + } + + /** + * Get the properties property: Named sub-fields of the object field. + * + * @return the properties value. + */ + @Generated + public Map getProperties() { + return this.properties; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldType.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldType.java new file mode 100644 index 000000000000..f0a87931fc8e --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFieldType.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Semantic data type of the field value. */ +public final class DocumentFieldType extends ExpandableStringEnum { + /** Plain text. */ + @Generated public static final DocumentFieldType STRING = fromString("string"); + + /** Date, normalized to ISO 8601 (YYYY-MM-DD) format. */ + @Generated public static final DocumentFieldType DATE = fromString("date"); + + /** Time, normalized to ISO 8601 (hh:mm:ss) format. */ + @Generated public static final DocumentFieldType TIME = fromString("time"); + + /** Phone number, normalized to E.164 (+{CountryCode}{SubscriberNumber}) format. */ + @Generated public static final DocumentFieldType PHONE_NUMBER = fromString("phoneNumber"); + + /** Floating point number, normalized to double precision floating point. */ + @Generated public static final DocumentFieldType NUMBER = fromString("number"); + + /** Integer number, normalized to 64-bit signed integer. */ + @Generated public static final DocumentFieldType INTEGER = fromString("integer"); + + /** Is field selected?. */ + @Generated public static final DocumentFieldType SELECTION_MARK = fromString("selectionMark"); + + /** Country/region, normalized to ISO 3166-1 alpha-3 format (ex. USA). */ + @Generated public static final DocumentFieldType COUNTRY_REGION = fromString("countryRegion"); + + /** Is signature present?. */ + @Generated public static final DocumentFieldType SIGNATURE = fromString("signature"); + + /** List of subfields of the same type. */ + @Generated public static final DocumentFieldType ARRAY = fromString("array"); + + /** Named list of subfields of potentially different types. */ + @Generated public static final DocumentFieldType OBJECT = fromString("object"); + + /** Currency amount with optional currency symbol and unit. */ + @Generated public static final DocumentFieldType CURRENCY = fromString("currency"); + + /** Parsed address. */ + @Generated public static final DocumentFieldType ADDRESS = fromString("address"); + + /** Boolean value, normalized to true or false. */ + @Generated public static final DocumentFieldType BOOLEAN = fromString("boolean"); + + /** + * Creates a new instance of DocumentFieldType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentFieldType() {} + + /** + * Creates or finds a DocumentFieldType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentFieldType. + */ + @Generated + @JsonCreator + public static DocumentFieldType fromString(String name) { + return fromString(name, DocumentFieldType.class); + } + + /** + * Gets known DocumentFieldType values. + * + * @return known DocumentFieldType values. + */ + @Generated + public static Collection values() { + return values(DocumentFieldType.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFigure.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFigure.java new file mode 100644 index 000000000000..5b69f6aa2908 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFigure.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing a figure in the document. */ +@Immutable +public final class DocumentFigure { + /* + * Bounding regions covering the figure. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the figure in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the figure, excluding any caption or footnotes. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /* + * Caption associated with the figure. + */ + @Generated + @JsonProperty(value = "caption") + private DocumentCaption caption; + + /* + * List of footnotes associated with the figure. + */ + @Generated + @JsonProperty(value = "footnotes") + private List footnotes; + + /** + * Creates an instance of DocumentFigure class. + * + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentFigure(@JsonProperty(value = "spans") List spans) { + this.spans = spans; + } + + /** + * Get the boundingRegions property: Bounding regions covering the figure. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the figure in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the figure, excluding any caption or footnotes. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } + + /** + * Get the caption property: Caption associated with the figure. + * + * @return the caption value. + */ + @Generated + public DocumentCaption getCaption() { + return this.caption; + } + + /** + * Get the footnotes property: List of footnotes associated with the figure. + * + * @return the footnotes value. + */ + @Generated + public List getFootnotes() { + return this.footnotes; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFootnote.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFootnote.java new file mode 100644 index 000000000000..3697a4287547 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFootnote.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A footnote object describing a table or figure. */ +@Immutable +public final class DocumentFootnote { + /* + * Content of the footnote. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the footnote. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the footnote in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the footnote. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /** + * Creates an instance of DocumentFootnote class. + * + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentFootnote( + @JsonProperty(value = "content") String content, @JsonProperty(value = "spans") List spans) { + this.content = content; + this.spans = spans; + } + + /** + * Get the content property: Content of the footnote. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the footnote. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the footnote in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the footnote. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormula.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormula.java new file mode 100644 index 000000000000..436fdf28a213 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormula.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A formula object. */ +@Immutable +public final class DocumentFormula { + /* + * Formula kind. + */ + @Generated + @JsonProperty(value = "kind") + private DocumentFormulaKind kind; + + /* + * LaTex expression describing the formula. + */ + @Generated + @JsonProperty(value = "value") + private String value; + + /* + * Bounding polygon of the formula, with coordinates specified relative to the + * top-left of the page. The numbers represent the x, y values of the polygon + * vertices, clockwise from the left (-180 degrees inclusive) relative to the + * element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /* + * Location of the formula in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "span") + private DocumentSpan span; + + /* + * Confidence of correctly extracting the formula. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentFormula class. + * + * @param kind the kind value to set. + * @param value the value value to set. + * @param span the span value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentFormula( + @JsonProperty(value = "kind") DocumentFormulaKind kind, + @JsonProperty(value = "value") String value, + @JsonProperty(value = "span") DocumentSpan span, + @JsonProperty(value = "confidence") double confidence) { + this.kind = kind; + this.value = value; + this.span = span; + this.confidence = confidence; + } + + /** + * Get the kind property: Formula kind. + * + * @return the kind value. + */ + @Generated + public DocumentFormulaKind getKind() { + return this.kind; + } + + /** + * Get the value property: LaTex expression describing the formula. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * Get the polygon property: Bounding polygon of the formula, with coordinates specified relative to the top-left of + * the page. The numbers represent the x, y values of the polygon vertices, clockwise from the left (-180 degrees + * inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } + + /** + * Get the span property: Location of the formula in the reading order concatenated content. + * + * @return the span value. + */ + @Generated + public DocumentSpan getSpan() { + return this.span; + } + + /** + * Get the confidence property: Confidence of correctly extracting the formula. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormulaKind.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormulaKind.java new file mode 100644 index 000000000000..48e871a16c36 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentFormulaKind.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Formula kind. */ +public final class DocumentFormulaKind extends ExpandableStringEnum { + /** A formula embedded within the content of a paragraph. */ + @Generated public static final DocumentFormulaKind INLINE = fromString("inline"); + + /** A formula in display mode that takes up an entire line. */ + @Generated public static final DocumentFormulaKind DISPLAY = fromString("display"); + + /** + * Creates a new instance of DocumentFormulaKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentFormulaKind() {} + + /** + * Creates or finds a DocumentFormulaKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentFormulaKind. + */ + @Generated + @JsonCreator + public static DocumentFormulaKind fromString(String name) { + return fromString(name, DocumentFormulaKind.class); + } + + /** + * Gets known DocumentFormulaKind values. + * + * @return known DocumentFormulaKind values. + */ + @Generated + public static Collection values() { + return values(DocumentFormulaKind.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValueElement.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValueElement.java new file mode 100644 index 000000000000..7f2eaabe8052 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValueElement.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing the field key or value in a key-value pair. */ +@Immutable +public final class DocumentKeyValueElement { + /* + * Concatenated content of the key-value element in reading order. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the key-value element. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the key-value element in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /** + * Creates an instance of DocumentKeyValueElement class. + * + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentKeyValueElement( + @JsonProperty(value = "content") String content, @JsonProperty(value = "spans") List spans) { + this.content = content; + this.spans = spans; + } + + /** + * Get the content property: Concatenated content of the key-value element in reading order. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the key-value element. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the key-value element in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValuePair.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValuePair.java new file mode 100644 index 000000000000..b534734f1c99 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentKeyValuePair.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** An object representing a form field with distinct field label (key) and field value (may be empty). */ +@Immutable +public final class DocumentKeyValuePair { + /* + * Field label of the key-value pair. + */ + @Generated + @JsonProperty(value = "key") + private DocumentKeyValueElement key; + + /* + * Field value of the key-value pair. + */ + @Generated + @JsonProperty(value = "value") + private DocumentKeyValueElement value; + + /* + * Confidence of correctly extracting the key-value pair. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentKeyValuePair class. + * + * @param key the key value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentKeyValuePair( + @JsonProperty(value = "key") DocumentKeyValueElement key, + @JsonProperty(value = "confidence") double confidence) { + this.key = key; + this.confidence = confidence; + } + + /** + * Get the key property: Field label of the key-value pair. + * + * @return the key value. + */ + @Generated + public DocumentKeyValueElement getKey() { + return this.key; + } + + /** + * Get the value property: Field value of the key-value pair. + * + * @return the value value. + */ + @Generated + public DocumentKeyValueElement getValue() { + return this.value; + } + + /** + * Get the confidence property: Confidence of correctly extracting the key-value pair. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLanguage.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLanguage.java new file mode 100644 index 000000000000..0c7a005da1fc --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLanguage.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing the detected language for a given text span. */ +@Immutable +public final class DocumentLanguage { + /* + * Detected language. Value may an ISO 639-1 language code (ex. "en", "fr") + * or BCP 47 language tag (ex. "zh-Hans"). + */ + @Generated + @JsonProperty(value = "locale") + private String locale; + + /* + * Location of the text elements in the concatenated content the language applies + * to. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Confidence of correctly identifying the language. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentLanguage class. + * + * @param locale the locale value to set. + * @param spans the spans value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentLanguage( + @JsonProperty(value = "locale") String locale, + @JsonProperty(value = "spans") List spans, + @JsonProperty(value = "confidence") double confidence) { + this.locale = locale; + this.spans = spans; + this.confidence = confidence; + } + + /** + * Get the locale property: Detected language. Value may an ISO 639-1 language code (ex. "en", "fr") or BCP 47 + * language tag (ex. "zh-Hans"). + * + * @return the locale value. + */ + @Generated + public String getLocale() { + return this.locale; + } + + /** + * Get the spans property: Location of the text elements in the concatenated content the language applies to. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the confidence property: Confidence of correctly identifying the language. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLine.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLine.java new file mode 100644 index 000000000000..0a7c5bf5c8cb --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentLine.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A content line object consisting of an adjacent sequence of content elements, such as words and selection marks. */ +@Immutable +public final class DocumentLine { + /* + * Concatenated content of the contained elements in reading order. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding polygon of the line, with coordinates specified relative to the + * top-left of the page. The numbers represent the x, y values of the polygon + * vertices, clockwise from the left (-180 degrees inclusive) relative to the + * element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /* + * Location of the line in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /** + * Creates an instance of DocumentLine class. + * + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentLine( + @JsonProperty(value = "content") String content, @JsonProperty(value = "spans") List spans) { + this.content = content; + this.spans = spans; + } + + /** + * Get the content property: Concatenated content of the contained elements in reading order. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the polygon property: Bounding polygon of the line, with coordinates specified relative to the top-left of + * the page. The numbers represent the x, y values of the polygon vertices, clockwise from the left (-180 degrees + * inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } + + /** + * Get the spans property: Location of the line in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentList.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentList.java new file mode 100644 index 000000000000..35c684361324 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentList.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing a list in the document. */ +@Immutable +public final class DocumentList { + /* + * Location of the list in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Items in the list. + */ + @Generated + @JsonProperty(value = "items") + private List items; + + /** + * Creates an instance of DocumentList class. + * + * @param spans the spans value to set. + * @param items the items value to set. + */ + @Generated + @JsonCreator + private DocumentList( + @JsonProperty(value = "spans") List spans, + @JsonProperty(value = "items") List items) { + this.spans = spans; + this.items = items; + } + + /** + * Get the spans property: Location of the list in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the items property: Items in the list. + * + * @return the items value. + */ + @Generated + public List getItems() { + return this.items; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentListItem.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentListItem.java new file mode 100644 index 000000000000..f69f5d9fc678 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentListItem.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing a list item in the document. */ +@Immutable +public final class DocumentListItem { + /* + * Level of the list item (1-indexed). + */ + @Generated + @JsonProperty(value = "level") + private int level; + + /* + * Content of the list item. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the list item. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the list item in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the list item. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /** + * Creates an instance of DocumentListItem class. + * + * @param level the level value to set. + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentListItem( + @JsonProperty(value = "level") int level, + @JsonProperty(value = "content") String content, + @JsonProperty(value = "spans") List spans) { + this.level = level; + this.content = content; + this.spans = spans; + } + + /** + * Get the level property: Level of the list item (1-indexed). + * + * @return the level value. + */ + @Generated + public int getLevel() { + return this.level; + } + + /** + * Get the content property: Content of the list item. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the list item. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the list item in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the list item. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelBuildOperationDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelBuildOperationDetails.java new file mode 100644 index 000000000000..cd0659f14a03 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelBuildOperationDetails.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; + +/** Get Operation response object. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("documentModelBuild") +@Immutable +public final class DocumentModelBuildOperationDetails extends OperationDetails { + /* + * Operation result upon success. + */ + @Generated + @JsonProperty(value = "result") + private DocumentModelDetails result; + + /** + * Creates an instance of DocumentModelBuildOperationDetails class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + * @param resourceLocation the resourceLocation value to set. + */ + @Generated + @JsonCreator + private DocumentModelBuildOperationDetails( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime, + @JsonProperty(value = "resourceLocation") String resourceLocation) { + super(status, createdDateTime, lastUpdatedDateTime, resourceLocation); + } + + /** + * Get the result property: Operation result upon success. + * + * @return the result value. + */ + @Generated + public DocumentModelDetails getResult() { + return this.result; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelComposeOperationDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelComposeOperationDetails.java new file mode 100644 index 000000000000..7964df152a0c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelComposeOperationDetails.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; + +/** Get Operation response object. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("documentModelCompose") +@Immutable +public final class DocumentModelComposeOperationDetails extends OperationDetails { + /* + * Operation result upon success. + */ + @Generated + @JsonProperty(value = "result") + private DocumentModelDetails result; + + /** + * Creates an instance of DocumentModelComposeOperationDetails class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + * @param resourceLocation the resourceLocation value to set. + */ + @Generated + @JsonCreator + private DocumentModelComposeOperationDetails( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime, + @JsonProperty(value = "resourceLocation") String resourceLocation) { + super(status, createdDateTime, lastUpdatedDateTime, resourceLocation); + } + + /** + * Get the result property: Operation result upon success. + * + * @return the result value. + */ + @Generated + public DocumentModelDetails getResult() { + return this.result; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelCopyToOperationDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelCopyToOperationDetails.java new file mode 100644 index 000000000000..feeabfe56041 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelCopyToOperationDetails.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; + +/** Get Operation response object. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("documentModelCopyTo") +@Immutable +public final class DocumentModelCopyToOperationDetails extends OperationDetails { + /* + * Operation result upon success. + */ + @Generated + @JsonProperty(value = "result") + private DocumentModelDetails result; + + /** + * Creates an instance of DocumentModelCopyToOperationDetails class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + * @param resourceLocation the resourceLocation value to set. + */ + @Generated + @JsonCreator + private DocumentModelCopyToOperationDetails( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime, + @JsonProperty(value = "resourceLocation") String resourceLocation) { + super(status, createdDateTime, lastUpdatedDateTime, resourceLocation); + } + + /** + * Get the result property: Operation result upon success. + * + * @return the result value. + */ + @Generated + public DocumentModelDetails getResult() { + return this.result; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelDetails.java new file mode 100644 index 000000000000..262b023a5088 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentModelDetails.java @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.Map; + +/** Document model info. */ +@Immutable +public final class DocumentModelDetails { + /* + * Unique document model name. + */ + @Generated + @JsonProperty(value = "modelId", access = JsonProperty.Access.WRITE_ONLY) + private String modelId; + + /* + * Document model description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * Date and time (UTC) when the document model was created. + */ + @Generated + @JsonProperty(value = "createdDateTime") + private OffsetDateTime createdDateTime; + + /* + * Date and time (UTC) when the document model will expire. + */ + @Generated + @JsonProperty(value = "expirationDateTime") + private OffsetDateTime expirationDateTime; + + /* + * API version used to create this document model. + */ + @Generated + @JsonProperty(value = "apiVersion") + private String apiVersion; + + /* + * List of key-value tag attributes associated with the document model. + */ + @Generated + @JsonProperty(value = "tags") + private Map tags; + + /* + * Custom document model build mode. + */ + @Generated + @JsonProperty(value = "buildMode") + private DocumentBuildMode buildMode; + + /* + * Azure Blob Storage location containing the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + */ + @Generated + @JsonProperty(value = "azureBlobSource") + private AzureBlobContentSource azureBlobSource; + + /* + * Azure Blob Storage file list specifying the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + */ + @Generated + @JsonProperty(value = "azureBlobFileListSource") + private AzureBlobFileListContentSource azureBlobFileListSource; + + /* + * Supported document types. + */ + @Generated + @JsonProperty(value = "docTypes") + private Map docTypes; + + /** + * Creates an instance of DocumentModelDetails class. + * + * @param createdDateTime the createdDateTime value to set. + */ + @Generated + @JsonCreator + private DocumentModelDetails(@JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime) { + this.createdDateTime = createdDateTime; + } + + /** + * Get the modelId property: Unique document model name. + * + * @return the modelId value. + */ + @Generated + public String getModelId() { + return this.modelId; + } + + /** + * Get the description property: Document model description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the createdDateTime property: Date and time (UTC) when the document model was created. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the expirationDateTime property: Date and time (UTC) when the document model will expire. + * + * @return the expirationDateTime value. + */ + @Generated + public OffsetDateTime getExpirationDateTime() { + return this.expirationDateTime; + } + + /** + * Get the apiVersion property: API version used to create this document model. + * + * @return the apiVersion value. + */ + @Generated + public String getApiVersion() { + return this.apiVersion; + } + + /** + * Get the tags property: List of key-value tag attributes associated with the document model. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Get the buildMode property: Custom document model build mode. + * + * @return the buildMode value. + */ + @Generated + public DocumentBuildMode getBuildMode() { + return this.buildMode; + } + + /** + * Get the azureBlobSource property: Azure Blob Storage location containing the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobSource value. + */ + @Generated + public AzureBlobContentSource getAzureBlobSource() { + return this.azureBlobSource; + } + + /** + * Get the azureBlobFileListSource property: Azure Blob Storage file list specifying the training data. Either + * azureBlobSource or azureBlobFileListSource must be specified. + * + * @return the azureBlobFileListSource value. + */ + @Generated + public AzureBlobFileListContentSource getAzureBlobFileListSource() { + return this.azureBlobFileListSource; + } + + /** + * Get the docTypes property: Supported document types. + * + * @return the docTypes value. + */ + @Generated + public Map getDocTypes() { + return this.docTypes; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentPage.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentPage.java new file mode 100644 index 000000000000..80c5971a254d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentPage.java @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Content and layout elements extracted from a page from the input. */ +@Immutable +public final class DocumentPage { + /* + * 1-based page number in the input document. + */ + @Generated + @JsonProperty(value = "pageNumber") + private int pageNumber; + + /* + * The general orientation of the content in clockwise direction, measured in + * degrees between (-180, 180]. + */ + @Generated + @JsonProperty(value = "angle") + private Double angle; + + /* + * The width of the image/PDF in pixels/inches, respectively. + */ + @Generated + @JsonProperty(value = "width") + private Double width; + + /* + * The height of the image/PDF in pixels/inches, respectively. + */ + @Generated + @JsonProperty(value = "height") + private Double height; + + /* + * The unit used by the width, height, and polygon properties. For images, the + * unit is "pixel". For PDF, the unit is "inch". + */ + @Generated + @JsonProperty(value = "unit") + private LengthUnit unit; + + /* + * Location of the page in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Extracted words from the page. + */ + @Generated + @JsonProperty(value = "words") + private List words; + + /* + * Extracted selection marks from the page. + */ + @Generated + @JsonProperty(value = "selectionMarks") + private List selectionMarks; + + /* + * Extracted lines from the page, potentially containing both textual and visual + * elements. + */ + @Generated + @JsonProperty(value = "lines") + private List lines; + + /* + * Extracted barcodes from the page. + */ + @Generated + @JsonProperty(value = "barcodes") + private List barcodes; + + /* + * Extracted formulas from the page. + */ + @Generated + @JsonProperty(value = "formulas") + private List formulas; + + /** + * Creates an instance of DocumentPage class. + * + * @param pageNumber the pageNumber value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentPage( + @JsonProperty(value = "pageNumber") int pageNumber, + @JsonProperty(value = "spans") List spans) { + this.pageNumber = pageNumber; + this.spans = spans; + } + + /** + * Get the pageNumber property: 1-based page number in the input document. + * + * @return the pageNumber value. + */ + @Generated + public int getPageNumber() { + return this.pageNumber; + } + + /** + * Get the angle property: The general orientation of the content in clockwise direction, measured in degrees + * between (-180, 180]. + * + * @return the angle value. + */ + @Generated + public Double getAngle() { + return this.angle; + } + + /** + * Get the width property: The width of the image/PDF in pixels/inches, respectively. + * + * @return the width value. + */ + @Generated + public Double getWidth() { + return this.width; + } + + /** + * Get the height property: The height of the image/PDF in pixels/inches, respectively. + * + * @return the height value. + */ + @Generated + public Double getHeight() { + return this.height; + } + + /** + * Get the unit property: The unit used by the width, height, and polygon properties. For images, the unit is + * "pixel". For PDF, the unit is "inch". + * + * @return the unit value. + */ + @Generated + public LengthUnit getUnit() { + return this.unit; + } + + /** + * Get the spans property: Location of the page in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the words property: Extracted words from the page. + * + * @return the words value. + */ + @Generated + public List getWords() { + return this.words; + } + + /** + * Get the selectionMarks property: Extracted selection marks from the page. + * + * @return the selectionMarks value. + */ + @Generated + public List getSelectionMarks() { + return this.selectionMarks; + } + + /** + * Get the lines property: Extracted lines from the page, potentially containing both textual and visual elements. + * + * @return the lines value. + */ + @Generated + public List getLines() { + return this.lines; + } + + /** + * Get the barcodes property: Extracted barcodes from the page. + * + * @return the barcodes value. + */ + @Generated + public List getBarcodes() { + return this.barcodes; + } + + /** + * Get the formulas property: Extracted formulas from the page. + * + * @return the formulas value. + */ + @Generated + public List getFormulas() { + return this.formulas; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentParagraph.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentParagraph.java new file mode 100644 index 000000000000..b3fc7d72bfc7 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentParagraph.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A paragraph object consisting with contiguous lines generally with common alignment and spacing. */ +@Immutable +public final class DocumentParagraph { + /* + * Semantic role of the paragraph. + */ + @Generated + @JsonProperty(value = "role") + private ParagraphRole role; + + /* + * Concatenated content of the paragraph in reading order. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the paragraph. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the paragraph in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /** + * Creates an instance of DocumentParagraph class. + * + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentParagraph( + @JsonProperty(value = "content") String content, @JsonProperty(value = "spans") List spans) { + this.content = content; + this.spans = spans; + } + + /** + * Get the role property: Semantic role of the paragraph. + * + * @return the role value. + */ + @Generated + public ParagraphRole getRole() { + return this.role; + } + + /** + * Get the content property: Concatenated content of the paragraph in reading order. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the paragraph. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the paragraph in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSection.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSection.java new file mode 100644 index 000000000000..f4ab5213456a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSection.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing a section in the document. */ +@Immutable +public final class DocumentSection { + /* + * Location of the section in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the section. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /** + * Creates an instance of DocumentSection class. + * + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentSection(@JsonProperty(value = "spans") List spans) { + this.spans = spans; + } + + /** + * Get the spans property: Location of the section in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the section. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMark.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMark.java new file mode 100644 index 000000000000..b784afe8b2bf --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMark.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A selection mark object representing check boxes, radio buttons, and other elements indicating a selection. */ +@Immutable +public final class DocumentSelectionMark { + /* + * State of the selection mark. + */ + @Generated + @JsonProperty(value = "state") + private DocumentSelectionMarkState state; + + /* + * Bounding polygon of the selection mark, with coordinates specified relative + * to the top-left of the page. The numbers represent the x, y values of the + * polygon vertices, clockwise from the left (-180 degrees inclusive) relative + * to the element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /* + * Location of the selection mark in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "span") + private DocumentSpan span; + + /* + * Confidence of correctly extracting the selection mark. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentSelectionMark class. + * + * @param state the state value to set. + * @param span the span value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentSelectionMark( + @JsonProperty(value = "state") DocumentSelectionMarkState state, + @JsonProperty(value = "span") DocumentSpan span, + @JsonProperty(value = "confidence") double confidence) { + this.state = state; + this.span = span; + this.confidence = confidence; + } + + /** + * Get the state property: State of the selection mark. + * + * @return the state value. + */ + @Generated + public DocumentSelectionMarkState getState() { + return this.state; + } + + /** + * Get the polygon property: Bounding polygon of the selection mark, with coordinates specified relative to the + * top-left of the page. The numbers represent the x, y values of the polygon vertices, clockwise from the left + * (-180 degrees inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } + + /** + * Get the span property: Location of the selection mark in the reading order concatenated content. + * + * @return the span value. + */ + @Generated + public DocumentSpan getSpan() { + return this.span; + } + + /** + * Get the confidence property: Confidence of correctly extracting the selection mark. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMarkState.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMarkState.java new file mode 100644 index 000000000000..d5892635b58f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSelectionMarkState.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** State of the selection mark. */ +public final class DocumentSelectionMarkState extends ExpandableStringEnum { + /** The selection mark is selected, often indicated by a check ✓ or cross X inside the selection mark. */ + @Generated public static final DocumentSelectionMarkState SELECTED = fromString("selected"); + + /** The selection mark is not selected. */ + @Generated public static final DocumentSelectionMarkState UNSELECTED = fromString("unselected"); + + /** + * Creates a new instance of DocumentSelectionMarkState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentSelectionMarkState() {} + + /** + * Creates or finds a DocumentSelectionMarkState from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentSelectionMarkState. + */ + @Generated + @JsonCreator + public static DocumentSelectionMarkState fromString(String name) { + return fromString(name, DocumentSelectionMarkState.class); + } + + /** + * Gets known DocumentSelectionMarkState values. + * + * @return known DocumentSelectionMarkState values. + */ + @Generated + public static Collection values() { + return values(DocumentSelectionMarkState.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSignatureType.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSignatureType.java new file mode 100644 index 000000000000..a4899008a785 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSignatureType.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Presence of signature. */ +public final class DocumentSignatureType extends ExpandableStringEnum { + /** A signature is detected. */ + @Generated public static final DocumentSignatureType SIGNED = fromString("signed"); + + /** No signatures are detected. */ + @Generated public static final DocumentSignatureType UNSIGNED = fromString("unsigned"); + + /** + * Creates a new instance of DocumentSignatureType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentSignatureType() {} + + /** + * Creates or finds a DocumentSignatureType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentSignatureType. + */ + @Generated + @JsonCreator + public static DocumentSignatureType fromString(String name) { + return fromString(name, DocumentSignatureType.class); + } + + /** + * Gets known DocumentSignatureType values. + * + * @return known DocumentSignatureType values. + */ + @Generated + public static Collection values() { + return values(DocumentSignatureType.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSpan.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSpan.java new file mode 100644 index 000000000000..8cd8ad488c28 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentSpan.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Contiguous region of the concatenated content property, specified as an offset and length. */ +@Immutable +public final class DocumentSpan { + /* + * Zero-based index of the content represented by the span. + */ + @Generated + @JsonProperty(value = "offset") + private int offset; + + /* + * Number of characters in the content represented by the span. + */ + @Generated + @JsonProperty(value = "length") + private int length; + + /** + * Creates an instance of DocumentSpan class. + * + * @param offset the offset value to set. + * @param length the length value to set. + */ + @Generated + @JsonCreator + private DocumentSpan(@JsonProperty(value = "offset") int offset, @JsonProperty(value = "length") int length) { + this.offset = offset; + this.length = length; + } + + /** + * Get the offset property: Zero-based index of the content represented by the span. + * + * @return the offset value. + */ + @Generated + public int getOffset() { + return this.offset; + } + + /** + * Get the length property: Number of characters in the content represented by the span. + * + * @return the length value. + */ + @Generated + public int getLength() { + return this.length; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentStyle.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentStyle.java new file mode 100644 index 000000000000..69883f618d99 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentStyle.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing observed text styles. */ +@Immutable +public final class DocumentStyle { + /* + * Is content handwritten? + */ + @Generated + @JsonProperty(value = "isHandwritten") + private Boolean isHandwritten; + + /* + * Visually most similar font from among the set of supported font families, with + * fallback fonts following CSS convention (ex. 'Arial, sans-serif'). + */ + @Generated + @JsonProperty(value = "similarFontFamily") + private String similarFontFamily; + + /* + * Font style. + */ + @Generated + @JsonProperty(value = "fontStyle") + private FontStyle fontStyle; + + /* + * Font weight. + */ + @Generated + @JsonProperty(value = "fontWeight") + private FontWeight fontWeight; + + /* + * Foreground color in #rrggbb hexadecimal format. + */ + @Generated + @JsonProperty(value = "color") + private String color; + + /* + * Background color in #rrggbb hexadecimal format.. + */ + @Generated + @JsonProperty(value = "backgroundColor") + private String backgroundColor; + + /* + * Location of the text elements in the concatenated content the style applies to. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Confidence of correctly identifying the style. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentStyle class. + * + * @param spans the spans value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentStyle( + @JsonProperty(value = "spans") List spans, + @JsonProperty(value = "confidence") double confidence) { + this.spans = spans; + this.confidence = confidence; + } + + /** + * Get the isHandwritten property: Is content handwritten?. + * + * @return the isHandwritten value. + */ + @Generated + public Boolean isHandwritten() { + return this.isHandwritten; + } + + /** + * Get the similarFontFamily property: Visually most similar font from among the set of supported font families, + * with fallback fonts following CSS convention (ex. 'Arial, sans-serif'). + * + * @return the similarFontFamily value. + */ + @Generated + public String getSimilarFontFamily() { + return this.similarFontFamily; + } + + /** + * Get the fontStyle property: Font style. + * + * @return the fontStyle value. + */ + @Generated + public FontStyle getFontStyle() { + return this.fontStyle; + } + + /** + * Get the fontWeight property: Font weight. + * + * @return the fontWeight value. + */ + @Generated + public FontWeight getFontWeight() { + return this.fontWeight; + } + + /** + * Get the color property: Foreground color in #rrggbb hexadecimal format. + * + * @return the color value. + */ + @Generated + public String getColor() { + return this.color; + } + + /** + * Get the backgroundColor property: Background color in #rrggbb hexadecimal format.. + * + * @return the backgroundColor value. + */ + @Generated + public String getBackgroundColor() { + return this.backgroundColor; + } + + /** + * Get the spans property: Location of the text elements in the concatenated content the style applies to. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the confidence property: Confidence of correctly identifying the style. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTable.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTable.java new file mode 100644 index 000000000000..f1eab84706db --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTable.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A table object consisting table cells arranged in a rectangular layout. */ +@Immutable +public final class DocumentTable { + /* + * Number of rows in the table. + */ + @Generated + @JsonProperty(value = "rowCount") + private int rowCount; + + /* + * Number of columns in the table. + */ + @Generated + @JsonProperty(value = "columnCount") + private int columnCount; + + /* + * Cells contained within the table. + */ + @Generated + @JsonProperty(value = "cells") + private List cells; + + /* + * Bounding regions covering the table. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the table in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Caption associated with the table. + */ + @Generated + @JsonProperty(value = "caption") + private DocumentCaption caption; + + /* + * List of footnotes associated with the table. + */ + @Generated + @JsonProperty(value = "footnotes") + private List footnotes; + + /** + * Creates an instance of DocumentTable class. + * + * @param rowCount the rowCount value to set. + * @param columnCount the columnCount value to set. + * @param cells the cells value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentTable( + @JsonProperty(value = "rowCount") int rowCount, + @JsonProperty(value = "columnCount") int columnCount, + @JsonProperty(value = "cells") List cells, + @JsonProperty(value = "spans") List spans) { + this.rowCount = rowCount; + this.columnCount = columnCount; + this.cells = cells; + this.spans = spans; + } + + /** + * Get the rowCount property: Number of rows in the table. + * + * @return the rowCount value. + */ + @Generated + public int getRowCount() { + return this.rowCount; + } + + /** + * Get the columnCount property: Number of columns in the table. + * + * @return the columnCount value. + */ + @Generated + public int getColumnCount() { + return this.columnCount; + } + + /** + * Get the cells property: Cells contained within the table. + * + * @return the cells value. + */ + @Generated + public List getCells() { + return this.cells; + } + + /** + * Get the boundingRegions property: Bounding regions covering the table. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the table in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the caption property: Caption associated with the table. + * + * @return the caption value. + */ + @Generated + public DocumentCaption getCaption() { + return this.caption; + } + + /** + * Get the footnotes property: List of footnotes associated with the table. + * + * @return the footnotes value. + */ + @Generated + public List getFootnotes() { + return this.footnotes; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCell.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCell.java new file mode 100644 index 000000000000..8216ea672bb0 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCell.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** An object representing the location and content of a table cell. */ +@Immutable +public final class DocumentTableCell { + /* + * Table cell kind. + */ + @Generated + @JsonProperty(value = "kind") + private DocumentTableCellKind kind; + + /* + * Row index of the cell. + */ + @Generated + @JsonProperty(value = "rowIndex") + private int rowIndex; + + /* + * Column index of the cell. + */ + @Generated + @JsonProperty(value = "columnIndex") + private int columnIndex; + + /* + * Number of rows spanned by this cell. + */ + @Generated + @JsonProperty(value = "rowSpan") + private Integer rowSpan; + + /* + * Number of columns spanned by this cell. + */ + @Generated + @JsonProperty(value = "columnSpan") + private Integer columnSpan; + + /* + * Concatenated content of the table cell in reading order. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding regions covering the table cell. + */ + @Generated + @JsonProperty(value = "boundingRegions") + private List boundingRegions; + + /* + * Location of the table cell in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "spans") + private List spans; + + /* + * Child elements of the table cell. + */ + @Generated + @JsonProperty(value = "elements") + private List elements; + + /** + * Creates an instance of DocumentTableCell class. + * + * @param rowIndex the rowIndex value to set. + * @param columnIndex the columnIndex value to set. + * @param content the content value to set. + * @param spans the spans value to set. + */ + @Generated + @JsonCreator + private DocumentTableCell( + @JsonProperty(value = "rowIndex") int rowIndex, + @JsonProperty(value = "columnIndex") int columnIndex, + @JsonProperty(value = "content") String content, + @JsonProperty(value = "spans") List spans) { + this.rowIndex = rowIndex; + this.columnIndex = columnIndex; + this.content = content; + this.spans = spans; + } + + /** + * Get the kind property: Table cell kind. + * + * @return the kind value. + */ + @Generated + public DocumentTableCellKind getKind() { + return this.kind; + } + + /** + * Get the rowIndex property: Row index of the cell. + * + * @return the rowIndex value. + */ + @Generated + public int getRowIndex() { + return this.rowIndex; + } + + /** + * Get the columnIndex property: Column index of the cell. + * + * @return the columnIndex value. + */ + @Generated + public int getColumnIndex() { + return this.columnIndex; + } + + /** + * Get the rowSpan property: Number of rows spanned by this cell. + * + * @return the rowSpan value. + */ + @Generated + public Integer getRowSpan() { + return this.rowSpan; + } + + /** + * Get the columnSpan property: Number of columns spanned by this cell. + * + * @return the columnSpan value. + */ + @Generated + public Integer getColumnSpan() { + return this.columnSpan; + } + + /** + * Get the content property: Concatenated content of the table cell in reading order. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the boundingRegions property: Bounding regions covering the table cell. + * + * @return the boundingRegions value. + */ + @Generated + public List getBoundingRegions() { + return this.boundingRegions; + } + + /** + * Get the spans property: Location of the table cell in the reading order concatenated content. + * + * @return the spans value. + */ + @Generated + public List getSpans() { + return this.spans; + } + + /** + * Get the elements property: Child elements of the table cell. + * + * @return the elements value. + */ + @Generated + public List getElements() { + return this.elements; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCellKind.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCellKind.java new file mode 100644 index 000000000000..64fe4f24a61d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTableCellKind.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Table cell kind. */ +public final class DocumentTableCellKind extends ExpandableStringEnum { + /** Contains the main content/data. */ + @Generated public static final DocumentTableCellKind CONTENT = fromString("content"); + + /** Describes the content of the row. */ + @Generated public static final DocumentTableCellKind ROW_HEADER = fromString("rowHeader"); + + /** Describes the content of the column. */ + @Generated public static final DocumentTableCellKind COLUMN_HEADER = fromString("columnHeader"); + + /** Describes the row headers, usually located at the top left corner of a table. */ + @Generated public static final DocumentTableCellKind STUB_HEAD = fromString("stubHead"); + + /** Describes the content in (parts of) the table. */ + @Generated public static final DocumentTableCellKind DESCRIPTION = fromString("description"); + + /** + * Creates a new instance of DocumentTableCellKind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DocumentTableCellKind() {} + + /** + * Creates or finds a DocumentTableCellKind from its string representation. + * + * @param name a name to look for. + * @return the corresponding DocumentTableCellKind. + */ + @Generated + @JsonCreator + public static DocumentTableCellKind fromString(String name) { + return fromString(name, DocumentTableCellKind.class); + } + + /** + * Gets known DocumentTableCellKind values. + * + * @return known DocumentTableCellKind values. + */ + @Generated + public static Collection values() { + return values(DocumentTableCellKind.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTypeDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTypeDetails.java new file mode 100644 index 000000000000..a2439cf6b791 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentTypeDetails.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Document type info. */ +@Immutable +public final class DocumentTypeDetails { + /* + * Document model description. + */ + @Generated + @JsonProperty(value = "description") + private String description; + + /* + * Custom document model build mode. + */ + @Generated + @JsonProperty(value = "buildMode") + private DocumentBuildMode buildMode; + + /* + * Description of the document semantic schema using a JSON Schema style syntax. + */ + @Generated + @JsonProperty(value = "fieldSchema") + private Map fieldSchema; + + /* + * Estimated confidence for each field. + */ + @Generated + @JsonProperty(value = "fieldConfidence") + private Map fieldConfidence; + + /** + * Creates an instance of DocumentTypeDetails class. + * + * @param fieldSchema the fieldSchema value to set. + */ + @Generated + @JsonCreator + private DocumentTypeDetails(@JsonProperty(value = "fieldSchema") Map fieldSchema) { + this.fieldSchema = fieldSchema; + } + + /** + * Get the description property: Document model description. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the buildMode property: Custom document model build mode. + * + * @return the buildMode value. + */ + @Generated + public DocumentBuildMode getBuildMode() { + return this.buildMode; + } + + /** + * Get the fieldSchema property: Description of the document semantic schema using a JSON Schema style syntax. + * + * @return the fieldSchema value. + */ + @Generated + public Map getFieldSchema() { + return this.fieldSchema; + } + + /** + * Get the fieldConfidence property: Estimated confidence for each field. + * + * @return the fieldConfidence value. + */ + @Generated + public Map getFieldConfidence() { + return this.fieldConfidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentWord.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentWord.java new file mode 100644 index 000000000000..75b80a18c4b2 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/DocumentWord.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A word object consisting of a contiguous sequence of characters. For non-space delimited languages, such as Chinese, + * Japanese, and Korean, each character is represented as its own word. + */ +@Immutable +public final class DocumentWord { + /* + * Text content of the word. + */ + @Generated + @JsonProperty(value = "content") + private String content; + + /* + * Bounding polygon of the word, with coordinates specified relative to the + * top-left of the page. The numbers represent the x, y values of the polygon + * vertices, clockwise from the left (-180 degrees inclusive) relative to the + * element orientation. + */ + @Generated + @JsonProperty(value = "polygon") + private List polygon; + + /* + * Location of the word in the reading order concatenated content. + */ + @Generated + @JsonProperty(value = "span") + private DocumentSpan span; + + /* + * Confidence of correctly extracting the word. + */ + @Generated + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Creates an instance of DocumentWord class. + * + * @param content the content value to set. + * @param span the span value to set. + * @param confidence the confidence value to set. + */ + @Generated + @JsonCreator + private DocumentWord( + @JsonProperty(value = "content") String content, + @JsonProperty(value = "span") DocumentSpan span, + @JsonProperty(value = "confidence") double confidence) { + this.content = content; + this.span = span; + this.confidence = confidence; + } + + /** + * Get the content property: Text content of the word. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the polygon property: Bounding polygon of the word, with coordinates specified relative to the top-left of + * the page. The numbers represent the x, y values of the polygon vertices, clockwise from the left (-180 degrees + * inclusive) relative to the element orientation. + * + * @return the polygon value. + */ + @Generated + public List getPolygon() { + return this.polygon; + } + + /** + * Get the span property: Location of the word in the reading order concatenated content. + * + * @return the span value. + */ + @Generated + public DocumentSpan getSpan() { + return this.span; + } + + /** + * Get the confidence property: Confidence of correctly extracting the word. + * + * @return the confidence value. + */ + @Generated + public double getConfidence() { + return this.confidence; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Error.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Error.java new file mode 100644 index 000000000000..88fa6cc37baf --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/Error.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The error object. */ +@Immutable +public final class Error { + /* + * One of a server-defined set of error codes. + */ + @Generated + @JsonProperty(value = "code") + private String code; + + /* + * A human-readable representation of the error. + */ + @Generated + @JsonProperty(value = "message") + private String message; + + /* + * The target of the error. + */ + @Generated + @JsonProperty(value = "target") + private String target; + + /* + * An array of details about specific errors that led to this reported error. + */ + @Generated + @JsonProperty(value = "details") + private List details; + + /* + * An object containing more specific information than the current object about the error. + */ + @Generated + @JsonProperty(value = "innererror") + private InnerError innererror; + + /** + * Creates an instance of Error class. + * + * @param code the code value to set. + * @param message the message value to set. + */ + @Generated + @JsonCreator + private Error(@JsonProperty(value = "code") String code, @JsonProperty(value = "message") String message) { + this.code = code; + this.message = message; + } + + /** + * Get the code property: One of a server-defined set of error codes. + * + * @return the code value. + */ + @Generated + public String getCode() { + return this.code; + } + + /** + * Get the message property: A human-readable representation of the error. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * Get the target property: The target of the error. + * + * @return the target value. + */ + @Generated + public String getTarget() { + return this.target; + } + + /** + * Get the details property: An array of details about specific errors that led to this reported error. + * + * @return the details value. + */ + @Generated + public List getDetails() { + return this.details; + } + + /** + * Get the innererror property: An object containing more specific information than the current object about the + * error. + * + * @return the innererror value. + */ + @Generated + public InnerError getInnererror() { + return this.innererror; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontStyle.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontStyle.java new file mode 100644 index 000000000000..98e8629a8c72 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontStyle.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Font style. */ +public final class FontStyle extends ExpandableStringEnum { + /** Characters are represented normally. */ + @Generated public static final FontStyle NORMAL = fromString("normal"); + + /** Characters are visually slanted to the right. */ + @Generated public static final FontStyle ITALIC = fromString("italic"); + + /** + * Creates a new instance of FontStyle value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FontStyle() {} + + /** + * Creates or finds a FontStyle from its string representation. + * + * @param name a name to look for. + * @return the corresponding FontStyle. + */ + @Generated + @JsonCreator + public static FontStyle fromString(String name) { + return fromString(name, FontStyle.class); + } + + /** + * Gets known FontStyle values. + * + * @return known FontStyle values. + */ + @Generated + public static Collection values() { + return values(FontStyle.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontWeight.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontWeight.java new file mode 100644 index 000000000000..30532b9aa9e6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/FontWeight.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Font weight. */ +public final class FontWeight extends ExpandableStringEnum { + /** Characters are represented normally. */ + @Generated public static final FontWeight NORMAL = fromString("normal"); + + /** Characters are represented with thicker strokes. */ + @Generated public static final FontWeight BOLD = fromString("bold"); + + /** + * Creates a new instance of FontWeight value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FontWeight() {} + + /** + * Creates or finds a FontWeight from its string representation. + * + * @param name a name to look for. + * @return the corresponding FontWeight. + */ + @Generated + @JsonCreator + public static FontWeight fromString(String name) { + return fromString(name, FontWeight.class); + } + + /** + * Gets known FontWeight values. + * + * @return known FontWeight values. + */ + @Generated + public static Collection values() { + return values(FontWeight.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/InnerError.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/InnerError.java new file mode 100644 index 000000000000..cc17cdb2156a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/InnerError.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** An object containing more specific information about the error. */ +@Immutable +public final class InnerError { + /* + * One of a server-defined set of error codes. + */ + @Generated + @JsonProperty(value = "code") + private String code; + + /* + * A human-readable representation of the error. + */ + @Generated + @JsonProperty(value = "message") + private String message; + + /* + * Inner error. + */ + @Generated + @JsonProperty(value = "innererror") + private InnerError innererror; + + /** Creates an instance of InnerError class. */ + @Generated + private InnerError() {} + + /** + * Get the code property: One of a server-defined set of error codes. + * + * @return the code value. + */ + @Generated + public String getCode() { + return this.code; + } + + /** + * Get the message property: A human-readable representation of the error. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * Get the innererror property: Inner error. + * + * @return the innererror value. + */ + @Generated + public InnerError getInnererror() { + return this.innererror; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/LengthUnit.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/LengthUnit.java new file mode 100644 index 000000000000..4768d12fe6b5 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/LengthUnit.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** + * The unit used by the width, height, and polygon properties. For images, the unit is "pixel". For PDF, the unit is + * "inch". + */ +public final class LengthUnit extends ExpandableStringEnum { + /** Length unit for image files. */ + @Generated public static final LengthUnit PIXEL = fromString("pixel"); + + /** Length unit for PDF files. */ + @Generated public static final LengthUnit INCH = fromString("inch"); + + /** + * Creates a new instance of LengthUnit value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public LengthUnit() {} + + /** + * Creates or finds a LengthUnit from its string representation. + * + * @param name a name to look for. + * @return the corresponding LengthUnit. + */ + @Generated + @JsonCreator + public static LengthUnit fromString(String name) { + return fromString(name, LengthUnit.class); + } + + /** + * Gets known LengthUnit values. + * + * @return known LengthUnit values. + */ + @Generated + public static Collection values() { + return values(LengthUnit.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationDetails.java new file mode 100644 index 000000000000..06acfa3300f3 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationDetails.java @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.OffsetDateTime; +import java.util.Map; + +/** Operation info. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "kind", + defaultImpl = OperationDetails.class) +@JsonTypeName("OperationDetails") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "documentModelBuild", value = DocumentModelBuildOperationDetails.class), + @JsonSubTypes.Type(name = "documentModelCompose", value = DocumentModelComposeOperationDetails.class), + @JsonSubTypes.Type(name = "documentModelCopyTo", value = DocumentModelCopyToOperationDetails.class), + @JsonSubTypes.Type(name = "documentClassifierBuild", value = DocumentClassifierBuildOperationDetails.class) +}) +@Immutable +public class OperationDetails { + /* + * Operation ID + */ + @Generated + @JsonProperty(value = "operationId", access = JsonProperty.Access.WRITE_ONLY) + private String operationId; + + /* + * Operation status. + */ + @Generated + @JsonProperty(value = "status") + private OperationStatus status; + + /* + * Operation progress (0-100). + */ + @Generated + @JsonProperty(value = "percentCompleted") + private Integer percentCompleted; + + /* + * Date and time (UTC) when the operation was created. + */ + @Generated + @JsonProperty(value = "createdDateTime") + private OffsetDateTime createdDateTime; + + /* + * Date and time (UTC) when the status was last updated. + */ + @Generated + @JsonProperty(value = "lastUpdatedDateTime") + private OffsetDateTime lastUpdatedDateTime; + + /* + * URL of the resource targeted by this operation. + */ + @Generated + @JsonProperty(value = "resourceLocation") + private String resourceLocation; + + /* + * API version used to create this operation. + */ + @Generated + @JsonProperty(value = "apiVersion") + private String apiVersion; + + /* + * List of key-value tag attributes associated with the document model. + */ + @Generated + @JsonProperty(value = "tags") + private Map tags; + + /* + * Encountered error. + */ + @Generated + @JsonProperty(value = "error") + private Error error; + + /** + * Creates an instance of OperationDetails class. + * + * @param status the status value to set. + * @param createdDateTime the createdDateTime value to set. + * @param lastUpdatedDateTime the lastUpdatedDateTime value to set. + * @param resourceLocation the resourceLocation value to set. + */ + @Generated + @JsonCreator + protected OperationDetails( + @JsonProperty(value = "status") OperationStatus status, + @JsonProperty(value = "createdDateTime") OffsetDateTime createdDateTime, + @JsonProperty(value = "lastUpdatedDateTime") OffsetDateTime lastUpdatedDateTime, + @JsonProperty(value = "resourceLocation") String resourceLocation) { + this.status = status; + this.createdDateTime = createdDateTime; + this.lastUpdatedDateTime = lastUpdatedDateTime; + this.resourceLocation = resourceLocation; + } + + /** + * Get the operationId property: Operation ID. + * + * @return the operationId value. + */ + @Generated + public String getOperationId() { + return this.operationId; + } + + /** + * Get the status property: Operation status. + * + * @return the status value. + */ + @Generated + public OperationStatus getStatus() { + return this.status; + } + + /** + * Get the percentCompleted property: Operation progress (0-100). + * + * @return the percentCompleted value. + */ + @Generated + public Integer getPercentCompleted() { + return this.percentCompleted; + } + + /** + * Get the createdDateTime property: Date and time (UTC) when the operation was created. + * + * @return the createdDateTime value. + */ + @Generated + public OffsetDateTime getCreatedDateTime() { + return this.createdDateTime; + } + + /** + * Get the lastUpdatedDateTime property: Date and time (UTC) when the status was last updated. + * + * @return the lastUpdatedDateTime value. + */ + @Generated + public OffsetDateTime getLastUpdatedDateTime() { + return this.lastUpdatedDateTime; + } + + /** + * Get the resourceLocation property: URL of the resource targeted by this operation. + * + * @return the resourceLocation value. + */ + @Generated + public String getResourceLocation() { + return this.resourceLocation; + } + + /** + * Get the apiVersion property: API version used to create this operation. + * + * @return the apiVersion value. + */ + @Generated + public String getApiVersion() { + return this.apiVersion; + } + + /** + * Get the tags property: List of key-value tag attributes associated with the document model. + * + * @return the tags value. + */ + @Generated + public Map getTags() { + return this.tags; + } + + /** + * Get the error property: Encountered error. + * + * @return the error value. + */ + @Generated + public Error getError() { + return this.error; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationStatus.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationStatus.java new file mode 100644 index 000000000000..0eb3ea305db2 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/OperationStatus.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Operation status. */ +public final class OperationStatus extends ExpandableStringEnum { + /** The operation has not started yet. */ + @Generated public static final OperationStatus NOT_STARTED = fromString("notStarted"); + + /** The operation is in progress. */ + @Generated public static final OperationStatus RUNNING = fromString("running"); + + /** The operation has failed. */ + @Generated public static final OperationStatus FAILED = fromString("failed"); + + /** The operation has succeeded. */ + @Generated public static final OperationStatus SUCCEEDED = fromString("succeeded"); + + /** The operation has been canceled. */ + @Generated public static final OperationStatus CANCELED = fromString("canceled"); + + /** + * Creates a new instance of OperationStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OperationStatus() {} + + /** + * Creates or finds a OperationStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationStatus. + */ + @Generated + @JsonCreator + public static OperationStatus fromString(String name) { + return fromString(name, OperationStatus.class); + } + + /** + * Gets known OperationStatus values. + * + * @return known OperationStatus values. + */ + @Generated + public static Collection values() { + return values(OperationStatus.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ParagraphRole.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ParagraphRole.java new file mode 100644 index 000000000000..925985417f33 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ParagraphRole.java @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Semantic role of the paragraph. */ +public final class ParagraphRole extends ExpandableStringEnum { + /** Text near the top edge of the page. */ + @Generated public static final ParagraphRole PAGE_HEADER = fromString("pageHeader"); + + /** Text near the bottom edge of the page. */ + @Generated public static final ParagraphRole PAGE_FOOTER = fromString("pageFooter"); + + /** Page number. */ + @Generated public static final ParagraphRole PAGE_NUMBER = fromString("pageNumber"); + + /** Top-level title describing the entire document. */ + @Generated public static final ParagraphRole TITLE = fromString("title"); + + /** Sub heading describing a section of the document. */ + @Generated public static final ParagraphRole SECTION_HEADING = fromString("sectionHeading"); + + /** A note usually placed after the main content on a page. */ + @Generated public static final ParagraphRole FOOTNOTE = fromString("footnote"); + + /** A block of formulas, often with shared alignment. */ + @Generated public static final ParagraphRole FORMULA_BLOCK = fromString("formulaBlock"); + + /** + * Creates a new instance of ParagraphRole value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ParagraphRole() {} + + /** + * Creates or finds a ParagraphRole from its string representation. + * + * @param name a name to look for. + * @return the corresponding ParagraphRole. + */ + @Generated + @JsonCreator + public static ParagraphRole fromString(String name) { + return fromString(name, ParagraphRole.class); + } + + /** + * Gets known ParagraphRole values. + * + * @return known ParagraphRole values. + */ + @Generated + public static Collection values() { + return values(ParagraphRole.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/QuotaDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/QuotaDetails.java new file mode 100644 index 000000000000..d7b3e530aee6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/QuotaDetails.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Quota used, limit, and next reset date/time. */ +@Immutable +public final class QuotaDetails { + /* + * Amount of the resource quota used. + */ + @Generated + @JsonProperty(value = "used") + private int used; + + /* + * Resource quota limit. + */ + @Generated + @JsonProperty(value = "quota") + private int quota; + + /* + * Date/time when the resource quota usage will be reset. + */ + @Generated + @JsonProperty(value = "quotaResetDateTime") + private OffsetDateTime quotaResetDateTime; + + /** + * Creates an instance of QuotaDetails class. + * + * @param used the used value to set. + * @param quota the quota value to set. + * @param quotaResetDateTime the quotaResetDateTime value to set. + */ + @Generated + @JsonCreator + private QuotaDetails( + @JsonProperty(value = "used") int used, + @JsonProperty(value = "quota") int quota, + @JsonProperty(value = "quotaResetDateTime") OffsetDateTime quotaResetDateTime) { + this.used = used; + this.quota = quota; + this.quotaResetDateTime = quotaResetDateTime; + } + + /** + * Get the used property: Amount of the resource quota used. + * + * @return the used value. + */ + @Generated + public int getUsed() { + return this.used; + } + + /** + * Get the quota property: Resource quota limit. + * + * @return the quota value. + */ + @Generated + public int getQuota() { + return this.quota; + } + + /** + * Get the quotaResetDateTime property: Date/time when the resource quota usage will be reset. + * + * @return the quotaResetDateTime value. + */ + @Generated + public OffsetDateTime getQuotaResetDateTime() { + return this.quotaResetDateTime; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ResourceDetails.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ResourceDetails.java new file mode 100644 index 000000000000..6f6b95d13b25 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/ResourceDetails.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** General information regarding the current resource. */ +@Immutable +public final class ResourceDetails { + /* + * Details regarding custom document models. + */ + @Generated + @JsonProperty(value = "customDocumentModels") + private CustomDocumentModelsDetails customDocumentModels; + + /* + * Quota used, limit, and next reset date/time. + */ + @Generated + @JsonProperty(value = "customNeuralDocumentModelBuilds") + private QuotaDetails customNeuralDocumentModelBuilds; + + /** + * Creates an instance of ResourceDetails class. + * + * @param customDocumentModels the customDocumentModels value to set. + * @param customNeuralDocumentModelBuilds the customNeuralDocumentModelBuilds value to set. + */ + @Generated + @JsonCreator + private ResourceDetails( + @JsonProperty(value = "customDocumentModels") CustomDocumentModelsDetails customDocumentModels, + @JsonProperty(value = "customNeuralDocumentModelBuilds") QuotaDetails customNeuralDocumentModelBuilds) { + this.customDocumentModels = customDocumentModels; + this.customNeuralDocumentModelBuilds = customNeuralDocumentModelBuilds; + } + + /** + * Get the customDocumentModels property: Details regarding custom document models. + * + * @return the customDocumentModels value. + */ + @Generated + public CustomDocumentModelsDetails getCustomDocumentModels() { + return this.customDocumentModels; + } + + /** + * Get the customNeuralDocumentModelBuilds property: Quota used, limit, and next reset date/time. + * + * @return the customNeuralDocumentModelBuilds value. + */ + @Generated + public QuotaDetails getCustomNeuralDocumentModelBuilds() { + return this.customNeuralDocumentModelBuilds; + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/SplitMode.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/SplitMode.java new file mode 100644 index 000000000000..4b2bc5043f37 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/SplitMode.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Document splitting mode. */ +public final class SplitMode extends ExpandableStringEnum { + /** Automatically split file into documents. */ + @Generated public static final SplitMode AUTO = fromString("auto"); + + /** Treat the entire file as a single document. */ + @Generated public static final SplitMode NONE = fromString("none"); + + /** Treat each page in the file as a separate document. */ + @Generated public static final SplitMode PER_PAGE = fromString("perPage"); + + /** + * Creates a new instance of SplitMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public SplitMode() {} + + /** + * Creates or finds a SplitMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding SplitMode. + */ + @Generated + @JsonCreator + public static SplitMode fromString(String name) { + return fromString(name, SplitMode.class); + } + + /** + * Gets known SplitMode values. + * + * @return known SplitMode values. + */ + @Generated + public static Collection values() { + return values(SplitMode.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/StringIndexType.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/StringIndexType.java new file mode 100644 index 000000000000..f5bc628cc2b7 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/StringIndexType.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Method used to compute string offset and length. */ +public final class StringIndexType extends ExpandableStringEnum { + /** User-perceived display character, or grapheme cluster, as defined by Unicode 8.0.0. */ + @Generated public static final StringIndexType TEXT_ELEMENTS = fromString("textElements"); + + /** Character unit represented by a single unicode code point. Used by Python 3. */ + @Generated public static final StringIndexType UNICODE_CODE_POINT = fromString("unicodeCodePoint"); + + /** Character unit represented by a 16-bit Unicode code unit. Used by JavaScript, Java, and .NET. */ + @Generated public static final StringIndexType UTF16CODE_UNIT = fromString("utf16CodeUnit"); + + /** + * Creates a new instance of StringIndexType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public StringIndexType() {} + + /** + * Creates or finds a StringIndexType from its string representation. + * + * @param name a name to look for. + * @return the corresponding StringIndexType. + */ + @Generated + @JsonCreator + public static StringIndexType fromString(String name) { + return fromString(name, StringIndexType.class); + } + + /** + * Gets known StringIndexType values. + * + * @return known StringIndexType values. + */ + @Generated + public static Collection values() { + return values(StringIndexType.class); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/package-info.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/package-info.java new file mode 100644 index 000000000000..21a90898fee7 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for DocumentIntelligence. Extracts content, layout, and structured data from + * documents. + */ +package com.azure.ai.documentintelligence.models; diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/package-info.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/package-info.java new file mode 100644 index 000000000000..faa25d720491 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for DocumentIntelligence. Extracts content, layout, and structured data from + * documents. + */ +package com.azure.ai.documentintelligence; diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/module-info.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/module-info.java new file mode 100644 index 000000000000..0c042f848877 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/module-info.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.ai.documentintelligence { + requires transitive com.azure.core; + requires transitive com.azure.core.experimental; + + exports com.azure.ai.documentintelligence; + exports com.azure.ai.documentintelligence.models; + + opens com.azure.ai.documentintelligence.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/resources/azure-ai-documentintelligence.properties b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/resources/azure-ai-documentintelligence.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/resources/azure-ai-documentintelligence.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/README.md b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/README.md new file mode 100644 index 000000000000..03b005d8200f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/README.md @@ -0,0 +1,104 @@ +--- +page_type: sample +languages: + - java +products: + - azure + - azure-cognitive-services + - azure-document-intelligence +urlFragment: documentintelligence-java-samples +--- + +# Azure Document Intelligence client library samples for Java + +Azure Document Intelligence samples are a set of self-contained Java programs that demonstrate interacting with Azure Document Intelligence service/ Document Intelligence +using the client library. Each sample focuses on a specific scenario and can be executed independently. + +## Key concepts +Key concepts are explained in detail [here][SDK_README_KEY_CONCEPTS]. + +## Getting started +Getting started explained in detail [here][SDK_README_GETTING_STARTED]. + +## Examples +The following sections provide code samples covering common scenario operations with the Azure Document Intelligence client library. + +All of these samples need the endpoint to your Document Intelligence resource ([instructions on how to get endpoint][get-endpoint-instructions]), and your Document Intelligence API key ([instructions on how to get key][get-key-instructions]). + +| **File Name** | **Description** | +|--------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| +| [Authentication][authentication_sample] | Authenticate the client | +| [AnalyzeLayout][analyze_layout] and [AnalyzeLayoutAsync][analyze_layout_async] | Analyze document layout, such as tables, lines, words, and selection marks like radio buttons and check boxes from a file stream | +| [AnalyzeLayoutFromUrl][analyze_layout_from_url] and [AnalyzeLayoutFromUrlAsync][analyze_layout_from_url_async] | Analyze document layout such as tables, lines, words, and selection marks like radio buttons and check boxes from a URL | +| [AnalyzeIdentityDocuments][analyze_id_documents] and [AnalyzeIdentityDocumentsAsync][analyze_id_documents_async] | Analyze data from an identity document like a passport or a US drivers license using a prebuilt model | +| [AnalyzeIdentityDocumentsFromUrl][analyze_id_documents_from_url] and [AnalyzeIdentityDocumentsFromUrlAsync][analyze_id_documents_from_url_async] | Analyze data from a URL of a passport or a US drivers license using a prebuilt model | +| [AnalyzeInvoices][analyze_invoices] and [AnalyzeInvoiceAsync][analyze_invoices_async] | Analyze invoices from an input stream | +| [AnalyzeInvoicesFromUrl][analyze_invoices_from_url] and [AnalyzeInvoicesFromUrlAsync][analyze_invoices_from_url_async] | Analyze invoices from a URL | +| [AnalyzeReceipts][analyze_receipts] and [AnalyzeReceiptsAsync][analyze_receipts_async] | Analyze data from a file of a US sales receipt using a prebuilt model | +| [AnalyzeReceiptsFromUrl][analyze_receipts_from_url] and [AnalyzeReceiptsFromUrlAsync][analyze_receipts_from_url_async] | Analyze data from a URL of a US sales receipt using a prebuilt model | +| [AnalyzeTaxW2][analyze_w2] and [AnalyzeTaxW2Async][analyze_w2_async] | Analyze data from a file of a US W2 Tax document using a prebuilt model | +| [AnalyzeCustomDocumentFromUrl][analyze_custom_documents] and [AnalyzeCustomDocumentAsync][analyze_custom_documents_async] | Analyze forms with your custom model | +| [BuildDocumentModel][build_model] and [BuildDocumentModelAsync][build_model_async] | Build a custom document analysis model | +| [ManageCustomModels][manage_custom_models] and [ManageCustomModelsAsync][manage_custom_models_async] | Manage the custom models in your account | +| [CopyDocumentModel][copy_model] and [CopyDocumentModelAsync][copy_model_async] | Copy custom model from one Document Intelligence resource to another | +| [ComposeDocumentModel][compose_model] and [ComposeDocumentModelAsync][compose_model_async] | Creates a composed model from a collection of existing built models with labels | +| [GetOperation][get_operation] and [GetOperationAsync][get_operation_async] | Get/list all document model associated with the Document Intelligence resource | +| [BuildDocumentClassifier][build_classifier] and [BuildDocumentClassifierAsync][build_classifier_async] | Build custom classifier models that combine layout and language features | + +## Troubleshooting +Troubleshooting steps can be found [here][SDK_README_TROUBLESHOOTING]. + +## Next steps +Check out the [API reference documentation][java_fr_ref_docs] to learn more about +what you can do with the Azure Document Intelligence client library. + +## Contributing +If you would like to become an active contributor to this project please refer to our [Contribution +Guidelines][SDK_README_CONTRIBUTING] for more information. + + +[SDK_README_CONTRIBUTING]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/README.md#contributing +[SDK_README_GETTING_STARTED]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/README.md#getting-started +[SDK_README_TROUBLESHOOTING]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/README.md#troubleshooting +[SDK_README_KEY_CONCEPTS]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/README.md#key-concepts +[SDK_README_DEPENDENCY]: ../../README.md#adding-the-package-to-your-product +[SDK_README_NEXT_STEPS]: ../../README.md#next-steps +[java_fr_ref_docs]: https://aka.ms/azsdk-java-documentintelligence-ref-doc +[get-endpoint-instructions]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/documentintelligence/azure-ai-documentintelligence#create-a-form-recognizer-resource +[get-key-instructions]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/documentintelligence/azure-ai-documentintelligence#create-a-form-recognizer-client-using-azurekeycredential + +[authentication_sample]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/Authentication.java +[build_model]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModel.java +[build_model_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModelAsync.java +[compose_model]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModel.java +[compose_model_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModelAsync.java +[copy_model]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModel.java +[copy_model_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModelAsync.java +[manage_custom_models]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModels.java +[manage_custom_models_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModelsAsync.java +[analyze_layout]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayout.java +[analyze_layout_async]:https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutAsync.java +[analyze_layout_from_url]:https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrl.java +[analyze_layout_from_url_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrlAsync.java +[analyze_custom_documents]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentFromUrl.java +[analyze_custom_documents_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentAsync.java +[analyze_id_documents]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocuments.java +[analyze_id_documents_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsAsync.java +[analyze_id_documents_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrl.java +[analyze_id_documents_from_url_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrlAsync.java +[analyze_invoices]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoices.java +[analyze_invoices_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesAsync.java +[analyze_invoices_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrl.java +[analyze_invoices_from_url_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrlAsync.java +[analyze_receipts]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceipts.java +[analyze_receipts_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsAsync.java +[analyze_receipts_from_url]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrl.java +[analyze_receipts_from_url_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrlAsync.java +[analyze_w2]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2.java +[analyze_w2_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2Async.java +[get_operation]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummary.java +[get_operation_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummaryAsync.java +[build_classifier]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifier.java +[build_classifier_async]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifierAsync.java + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fdocumentintelligence%2Fazure-ai-documentintelligence%2FREADME.png) diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentAsync.java new file mode 100644 index 000000000000..61bc41fa19c1 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentAsync.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * Async sample to analyze a custom document with a custom-built model. To learn how to build your own models, + * look at BuildDocumentModelAsync.java and BuildDocumentModel.java. + */ +public class AnalyzeCustomDocumentAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + // The document you are analyzing must be of the same type as the documents provided for building the custom document analysis model + File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/forms/Invoice_6.pdf"); + byte[] fileContent = Files.readAllBytes(sourceFile.toPath()); + String modelId = "{modelId}"; + PollerFlux analyzeDocumentPoller + = client.beginAnalyzeDocument(modelId, + "1", + "en-US", + StringIndexType.TEXT_ELEMENTS, + Arrays.asList(DocumentAnalysisFeature.LANGUAGES), + null, + ContentFormat.TEXT, + new AnalyzeDocumentRequest().setBase64Source(fileContent)); + + + Mono analyzeDocumentResult = analyzeDocumentPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + analyzeDocumentResult.subscribe(analyzeResult -> { + for (int i = 0; i < analyzeResult.getDocuments().size(); i++) { + Document analyzedDocument = analyzeResult.getDocuments().get(i); + System.out.printf("----------- Analyzing custom document %d -----------%n", i); + System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n", + analyzedDocument.getDocType(), analyzedDocument.getConfidence()); + } + + analyzeResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding box %s.%n", + documentLine.getContent(), + documentLine.getPolygon().toString())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + }); + + // tables + List tables = analyzeResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentFromUrl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentFromUrl.java new file mode 100644 index 000000000000..5115c8552bd3 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeCustomDocumentFromUrl.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.util.Arrays; +import java.util.List; + +/** + * Sample to analyze a custom document with a custom-built model. To learn how to build your own models, + * look at BuildDocumentModelAsync.java and BuildDocumentModel.java. + */ +public class AnalyzeCustomDocumentFromUrl { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String documentUrl = "{document-url}"; + String modelId = "{custom-built-model-ID}"; + SyncPoller analyzeDocumentPoller = client.beginAnalyzeDocument(modelId, + "1", + "en-US", + StringIndexType.TEXT_ELEMENTS, + Arrays.asList(DocumentAnalysisFeature.LANGUAGES), + null, + ContentFormat.TEXT, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)); + + AnalyzeResult analyzeResult = analyzeDocumentPoller.getFinalResult(); + + for (int i = 0; i < analyzeResult.getDocuments().size(); i++) { + final Document analyzedDocument = analyzeResult.getDocuments().get(i); + System.out.printf("----------- Analyzing custom document %d -----------%n", i); + System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n", + analyzedDocument.getDocType(), analyzedDocument.getConfidence()); + } + + analyzeResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + }); + + // tables + List tables = analyzeResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocuments.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocuments.java new file mode 100644 index 000000000000..6fe5c5982e6d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocuments.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.Map; + +/** + * Sample for analyzing commonly found License document fields from a local file input stream. + * See fields found on an identity document here + */ +public class AnalyzeIdentityDocuments { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * + * @throws IOException from reading file. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + File licenseDocumentFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/identityDocuments/license.png"); + + SyncPoller analyzeIdentityDocumentPoller = + client.beginAnalyzeDocument("prebuilt-idDocument", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(licenseDocumentFile.toPath()))); + + AnalyzeResult identityDocumentResults = analyzeIdentityDocumentPoller.getFinalResult(); + + for (int i = 0; i < identityDocumentResults.getDocuments().size(); i++) { + Document analyzedIDDocument = identityDocumentResults.getDocuments().get(i); + Map licenseFields = analyzedIDDocument.getFields(); + System.out.printf("----------- Analyzed license info for page %d -----------%n", i); + DocumentField addressField = licenseFields.get("Address"); + if (addressField != null) { + if (DocumentFieldType.STRING == addressField.getType()) { + String address = addressField.getValueString(); + System.out.printf("Address: %s, confidence: %.2f%n", + address, addressField.getConfidence()); + } + } + + DocumentField countryRegionDocumentField = licenseFields.get("CountryRegion"); + if (countryRegionDocumentField != null) { + if (DocumentFieldType.STRING == countryRegionDocumentField.getType()) { + String countryRegion = countryRegionDocumentField.getValueCountryRegion(); + System.out.printf("Country or region: %s, confidence: %.2f%n", + countryRegion, countryRegionDocumentField.getConfidence()); + } + } + + DocumentField dateOfBirthField = licenseFields.get("DateOfBirth"); + if (dateOfBirthField != null) { + if (DocumentFieldType.DATE == dateOfBirthField.getType()) { + LocalDate dateOfBirth = dateOfBirthField.getValueDate(); + System.out.printf("Date of Birth: %s, confidence: %.2f%n", + dateOfBirth, dateOfBirthField.getConfidence()); + } + } + + DocumentField dateOfExpirationField = licenseFields.get("DateOfExpiration"); + if (dateOfExpirationField != null) { + if (DocumentFieldType.DATE == dateOfExpirationField.getType()) { + LocalDate expirationDate = dateOfExpirationField.getValueDate(); + System.out.printf("Document date of expiration: %s, confidence: %.2f%n", + expirationDate, dateOfExpirationField.getConfidence()); + } + } + + DocumentField documentNumberField = licenseFields.get("DocumentNumber"); + if (documentNumberField != null) { + if (DocumentFieldType.STRING == documentNumberField.getType()) { + String documentNumber = documentNumberField.getValueString(); + System.out.printf("Document number: %s, confidence: %.2f%n", + documentNumber, documentNumberField.getConfidence()); + } + } + + DocumentField firstNameField = licenseFields.get("FirstName"); + if (firstNameField != null) { + if (DocumentFieldType.STRING == firstNameField.getType()) { + String firstName = firstNameField.getValueString(); + System.out.printf("First Name: %s, confidence: %.2f%n", + firstName, documentNumberField.getConfidence()); + } + } + + DocumentField lastNameField = licenseFields.get("LastName"); + if (lastNameField != null) { + if (DocumentFieldType.STRING == lastNameField.getType()) { + String lastName = lastNameField.getValueString(); + System.out.printf("Last name: %s, confidence: %.2f%n", + lastName, lastNameField.getConfidence()); + } + } + + DocumentField regionField = licenseFields.get("Region"); + if (regionField != null) { + if (DocumentFieldType.STRING == regionField.getType()) { + String region = regionField.getValueString(); + System.out.printf("Region: %s, confidence: %.2f%n", + region, regionField.getConfidence()); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsAsync.java new file mode 100644 index 000000000000..13b63040590b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsAsync.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found license fields from a local file input stream of a license identity + * document. See fields found on license here + */ +public class AnalyzeIdentityDocumentsAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + File licenseDocumentFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/identityDocuments/license.png"); + byte[] fileContent = Files.readAllBytes(licenseDocumentFile.toPath()); + + PollerFlux analyzeIdentityDocumentPoller + = client.beginAnalyzeDocument("prebuilt-idDocument", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(fileContent)); + + Mono identityDocumentPollerResult = analyzeIdentityDocumentPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + identityDocumentPollerResult.subscribe(idDocumentResults -> { + for (int i = 0; i < idDocumentResults.getDocuments().size(); i++) { + Document analyzedIDDocument = idDocumentResults.getDocuments().get(i); + Map licenseFields = analyzedIDDocument.getFields(); + System.out.printf("----------- Analyzed license info for page %d -----------%n", i); + DocumentField addressField = licenseFields.get("Address"); + if (addressField != null) { + if (DocumentFieldType.STRING == addressField.getType()) { + String address = addressField.getValueString(); + System.out.printf("Address: %s, confidence: %.2f%n", + address, addressField.getConfidence()); + } + } + + DocumentField countryRegionDocumentField = licenseFields.get("CountryRegion"); + if (countryRegionDocumentField != null) { + if (DocumentFieldType.STRING == countryRegionDocumentField.getType()) { + String countryRegion = countryRegionDocumentField.getValueCountryRegion(); + System.out.printf("Country or region: %s, confidence: %.2f%n", + countryRegion, countryRegionDocumentField.getConfidence()); + } + } + + DocumentField dateOfBirthField = licenseFields.get("DateOfBirth"); + if (dateOfBirthField != null) { + if (DocumentFieldType.DATE == dateOfBirthField.getType()) { + LocalDate dateOfBirth = dateOfBirthField.getValueDate(); + System.out.printf("Date of Birth: %s, confidence: %.2f%n", + dateOfBirth, dateOfBirthField.getConfidence()); + } + } + + DocumentField dateOfExpirationField = licenseFields.get("DateOfExpiration"); + if (dateOfExpirationField != null) { + if (DocumentFieldType.DATE == dateOfExpirationField.getType()) { + LocalDate expirationDate = dateOfExpirationField.getValueDate(); + System.out.printf("Document date of expiration: %s, confidence: %.2f%n", + expirationDate, dateOfExpirationField.getConfidence()); + } + } + + DocumentField documentNumberField = licenseFields.get("DocumentNumber"); + if (documentNumberField != null) { + if (DocumentFieldType.STRING == documentNumberField.getType()) { + String documentNumber = documentNumberField.getValueString(); + System.out.printf("Document number: %s, confidence: %.2f%n", + documentNumber, documentNumberField.getConfidence()); + } + } + + DocumentField firstNameField = licenseFields.get("FirstName"); + if (firstNameField != null) { + if (DocumentFieldType.STRING == firstNameField.getType()) { + String firstName = firstNameField.getValueString(); + System.out.printf("First Name: %s, confidence: %.2f%n", + firstName, firstNameField.getConfidence()); + } + } + + DocumentField lastNameField = licenseFields.get("LastName"); + if (lastNameField != null) { + if (DocumentFieldType.STRING == lastNameField.getType()) { + String lastName = lastNameField.getValueString(); + System.out.printf("Last name: %s, confidence: %.2f%n", + lastName, lastNameField.getConfidence()); + } + } + + DocumentField regionField = licenseFields.get("Region"); + if (regionField != null) { + if (DocumentFieldType.STRING == regionField.getType()) { + String region = regionField.getValueString(); + System.out.printf("Region: %s, confidence: %.2f%n", + region, regionField.getConfidence()); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrl.java new file mode 100644 index 000000000000..e23ce207dd19 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrl.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.IOException; +import java.time.LocalDate; +import java.util.Map; + +/** + * Sample for analyzing commonly found ID document fields from a file source URL of an identity document. + * See fields found on an identity document href + */ +public class AnalyzeIdentityDocumentsFromUrl { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String licenseDocumentUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/src/samples/resources/sample-forms/IdentityDocuments/license.png"; + SyncPoller analyzeIdentityDocumentPoller + = client.beginAnalyzeDocument("prebuilt-idDocument", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(licenseDocumentUrl)); + + AnalyzeResult identityDocumentResults = analyzeIdentityDocumentPoller.getFinalResult(); + + for (int i = 0; i < identityDocumentResults.getDocuments().size(); i++) { + Document analyzedIDDocument = identityDocumentResults.getDocuments().get(i); + Map licenseFields = analyzedIDDocument.getFields(); + System.out.printf("----------- Analyzed license info for page %d -----------%n", i); + DocumentField addressField = licenseFields.get("Address"); + if (addressField != null) { + if (DocumentFieldType.STRING == addressField.getType()) { + String address = addressField.getValueString(); + System.out.printf("Address: %s, confidence: %.2f%n", + address, addressField.getConfidence()); + } + } + + DocumentField countryRegionDocumentField = licenseFields.get("CountryRegion"); + if (countryRegionDocumentField != null) { + if (DocumentFieldType.STRING == countryRegionDocumentField.getType()) { + String countryRegion = countryRegionDocumentField.getValueCountryRegion(); + System.out.printf("Country or region: %s, confidence: %.2f%n", + countryRegion, countryRegionDocumentField.getConfidence()); + } + } + + DocumentField dateOfBirthField = licenseFields.get("DateOfBirth"); + if (dateOfBirthField != null) { + if (DocumentFieldType.DATE == dateOfBirthField.getType()) { + LocalDate dateOfBirth = dateOfBirthField.getValueDate(); + System.out.printf("Date of Birth: %s, confidence: %.2f%n", + dateOfBirth, dateOfBirthField.getConfidence()); + } + } + + DocumentField dateOfExpirationField = licenseFields.get("DateOfExpiration"); + if (dateOfExpirationField != null) { + if (DocumentFieldType.DATE == dateOfExpirationField.getType()) { + LocalDate expirationDate = dateOfExpirationField.getValueDate(); + System.out.printf("Document date of expiration: %s, confidence: %.2f%n", + expirationDate, dateOfExpirationField.getConfidence()); + } + } + + DocumentField documentNumberField = licenseFields.get("DocumentNumber"); + if (documentNumberField != null) { + if (DocumentFieldType.STRING == documentNumberField.getType()) { + String documentNumber = documentNumberField.getValueString(); + System.out.printf("Document number: %s, confidence: %.2f%n", + documentNumber, documentNumberField.getConfidence()); + } + } + + DocumentField firstNameField = licenseFields.get("FirstName"); + if (firstNameField != null) { + if (DocumentFieldType.STRING == firstNameField.getType()) { + String firstName = firstNameField.getValueString(); + System.out.printf("First Name: %s, confidence: %.2f%n", + firstName, documentNumberField.getConfidence()); + } + } + + DocumentField lastNameField = licenseFields.get("LastName"); + if (lastNameField != null) { + if (DocumentFieldType.STRING == lastNameField.getType()) { + String lastName = lastNameField.getValueString(); + System.out.printf("Last name: %s, confidence: %.2f%n", + lastName, lastNameField.getConfidence()); + } + } + + DocumentField regionField = licenseFields.get("Region"); + if (regionField != null) { + if (DocumentFieldType.STRING == regionField.getType()) { + String region = regionField.getValueString(); + System.out.printf("Region: %s, confidence: %.2f%n", + region, regionField.getConfidence()); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrlAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrlAsync.java new file mode 100644 index 000000000000..f5a7819d8917 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeIdentityDocumentsFromUrlAsync.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.time.LocalDate; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found identity document fields from a file source URL. + * See fields found on a license here + */ +public class AnalyzeIdentityDocumentsFromUrlAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String licenseDocumentUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/src/samples/resources/sample-forms/IdentityDocuments/license.png"; + PollerFlux analyzeIdentityDocumentPoller = + client.beginAnalyzeDocument("prebuilt-idDocument", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(licenseDocumentUrl)); + + Mono identityDocumentPollerResult = analyzeIdentityDocumentPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + identityDocumentPollerResult.subscribe(identityDocumentResults -> { + for (int i = 0; i < identityDocumentResults.getDocuments().size(); i++) { + Document analyzedIDDocument = identityDocumentResults.getDocuments().get(i); + Map licenseFields = analyzedIDDocument.getFields(); + System.out.printf("----------- Analyzed license info for page %d -----------%n", i); + DocumentField addressField = licenseFields.get("Address"); + if (addressField != null) { + if (DocumentFieldType.STRING == addressField.getType()) { + String address = addressField.getValueString(); + System.out.printf("Address: %s, confidence: %.2f%n", + address, addressField.getConfidence()); + } + } + + DocumentField countryRegionDocumentField = licenseFields.get("CountryRegion"); + if (countryRegionDocumentField != null) { + if (DocumentFieldType.STRING == countryRegionDocumentField.getType()) { + String countryRegion = countryRegionDocumentField.getValueCountryRegion(); + System.out.printf("Country or region: %s, confidence: %.2f%n", + countryRegion, countryRegionDocumentField.getConfidence()); + } + } + + DocumentField dateOfBirthField = licenseFields.get("DateOfBirth"); + if (dateOfBirthField != null) { + if (DocumentFieldType.DATE == dateOfBirthField.getType()) { + LocalDate dateOfBirth = dateOfBirthField.getValueDate(); + System.out.printf("Date of Birth: %s, confidence: %.2f%n", + dateOfBirth, dateOfBirthField.getConfidence()); + } + } + + DocumentField dateOfExpirationField = licenseFields.get("DateOfExpiration"); + if (dateOfExpirationField != null) { + if (DocumentFieldType.DATE == dateOfExpirationField.getType()) { + LocalDate expirationDate = dateOfExpirationField.getValueDate(); + System.out.printf("Document date of expiration: %s, confidence: %.2f%n", + expirationDate, dateOfExpirationField.getConfidence()); + } + } + + DocumentField documentNumberField = licenseFields.get("DocumentNumber"); + if (documentNumberField != null) { + if (DocumentFieldType.STRING == documentNumberField.getType()) { + String documentNumber = documentNumberField.getValueString(); + System.out.printf("Document number: %s, confidence: %.2f%n", + documentNumber, documentNumberField.getConfidence()); + } + } + + DocumentField firstNameField = licenseFields.get("FirstName"); + if (firstNameField != null) { + if (DocumentFieldType.STRING == firstNameField.getType()) { + String firstName = firstNameField.getValueString(); + System.out.printf("First Name: %s, confidence: %.2f%n", + firstName, firstNameField.getConfidence()); + } + } + + DocumentField lastNameField = licenseFields.get("LastName"); + if (lastNameField != null) { + if (DocumentFieldType.STRING == lastNameField.getType()) { + String lastName = lastNameField.getValueString(); + System.out.printf("Last name: %s, confidence: %.2f%n", + lastName, lastNameField.getConfidence()); + } + } + + DocumentField regionField = licenseFields.get("Region"); + if (regionField != null) { + if (DocumentFieldType.STRING == regionField.getType()) { + String region = regionField.getValueString(); + System.out.printf("Region: %s, confidence: %.2f%n", + region, regionField.getConfidence()); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoices.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoices.java new file mode 100644 index 000000000000..ebeaf8f6df75 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoices.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +/** + * Sample for analyzing commonly found invoice fields from a local file input stream of an invoice document. + * See fields found on an invoice here + */ +public class AnalyzeInvoices { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + File invoice = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/invoices/sample_invoice.jpg"); + + SyncPoller analyzeInvoicesPoller = + client.beginAnalyzeDocument("prebuilt-invoice", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(invoice.toPath()))); + + AnalyzeResult analyzeInvoiceResult = analyzeInvoicesPoller.getFinalResult(); + + for (int i = 0; i < analyzeInvoiceResult.getDocuments().size(); i++) { + Document analyzedInvoice = analyzeInvoiceResult.getDocuments().get(i); + Map invoiceFields = analyzedInvoice.getFields(); + System.out.printf("----------- Analyzing invoice %d -----------%n", i); + DocumentField vendorNameField = invoiceFields.get("VendorName"); + if (vendorNameField != null) { + if (DocumentFieldType.STRING == vendorNameField.getType()) { + String merchantName = vendorNameField.getValueString(); + System.out.printf("Vendor Name: %s, confidence: %.2f%n", + merchantName, vendorNameField.getConfidence()); + } + } + + DocumentField vendorAddressField = invoiceFields.get("VendorAddress"); + if (vendorAddressField != null) { + if (DocumentFieldType.STRING == vendorAddressField.getType()) { + String merchantAddress = vendorAddressField.getValueString(); + System.out.printf("Vendor address: %s, confidence: %.2f%n", + merchantAddress, vendorAddressField.getConfidence()); + } + } + + DocumentField customerNameField = invoiceFields.get("CustomerName"); + if (customerNameField != null) { + if (DocumentFieldType.STRING == customerNameField.getType()) { + String merchantAddress = customerNameField.getValueString(); + System.out.printf("Customer Name: %s, confidence: %.2f%n", + merchantAddress, customerNameField.getConfidence()); + } + } + + DocumentField customerAddressRecipientField = invoiceFields.get("CustomerAddressRecipient"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.STRING == customerAddressRecipientField.getType()) { + String customerAddr = customerAddressRecipientField.getValueString(); + System.out.printf("Customer Address Recipient: %s, confidence: %.2f%n", + customerAddr, customerAddressRecipientField.getConfidence()); + } + } + + DocumentField invoiceIdField = invoiceFields.get("InvoiceId"); + if (invoiceIdField != null) { + if (DocumentFieldType.STRING == invoiceIdField.getType()) { + String invoiceId = invoiceIdField.getValueString(); + System.out.printf("Invoice ID: %s, confidence: %.2f%n", + invoiceId, invoiceIdField.getConfidence()); + } + } + + DocumentField invoiceDateField = invoiceFields.get("InvoiceDate"); + if (customerNameField != null) { + if (DocumentFieldType.DATE == invoiceDateField.getType()) { + LocalDate invoiceDate = invoiceDateField.getValueDate(); + System.out.printf("Invoice Date: %s, confidence: %.2f%n", + invoiceDate, invoiceDateField.getConfidence()); + } + } + + DocumentField invoiceTotalField = invoiceFields.get("InvoiceTotal"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.NUMBER == invoiceTotalField.getType()) { + Double invoiceTotal = invoiceTotalField.getValueNumber(); + System.out.printf("Invoice Total: %.2f, confidence: %.2f%n", + invoiceTotal, invoiceTotalField.getConfidence()); + } + } + + DocumentField invoiceItemsField = invoiceFields.get("Items"); + if (invoiceItemsField != null) { + System.out.printf("Invoice Items: %n"); + if (DocumentFieldType.ARRAY == invoiceItemsField.getType()) { + List invoiceItems = invoiceItemsField.getValueArray(); + invoiceItems.stream() + .filter(invoiceItem -> DocumentFieldType.OBJECT == invoiceItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + // See a full list of fields found on an invoice here: + // https://aka.ms/documentintelligence/invoicefields + if ("Description".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Description: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("UnitPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double unitPrice = documentField.getValueNumber(); + System.out.printf("Unit Price: %f, confidence: %.2f%n", + unitPrice, documentField.getConfidence()); + } + } + if ("ProductCode".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double productCode = documentField.getValueNumber(); + System.out.printf("Product Code: %f, confidence: %.2f%n", + productCode, documentField.getConfidence()); + } + } + })); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesAsync.java new file mode 100644 index 000000000000..2b1825344be4 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesAsync.java @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found invoice fields from a local file input stream of an invoice document. + * See fields found on an invoice here + */ +public class AnalyzeInvoicesAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + File invoice = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/invoices/sample_invoice.jpg"); + byte[] fileContent = Files.readAllBytes(invoice.toPath()); + PollerFlux analyzeInvoicePoller; + try (InputStream targetStream = new ByteArrayInputStream(fileContent)) { + analyzeInvoicePoller = + client.beginAnalyzeDocument("prebuilt-invoice", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(invoice.toPath())) + ); + } + + Mono analyzeInvoiceResultMono = analyzeInvoicePoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + analyzeInvoiceResultMono.subscribe(analyzeInvoiceResult -> { + for (int i = 0; i < analyzeInvoiceResult.getDocuments().size(); i++) { + Document analyzedInvoice = analyzeInvoiceResult.getDocuments().get(i); + Map invoiceFields = analyzedInvoice.getFields(); + System.out.printf("----------- Analyzing invoice %d -----------%n", i); + DocumentField vendorNameField = invoiceFields.get("VendorName"); + if (vendorNameField != null) { + if (DocumentFieldType.STRING == vendorNameField.getType()) { + String merchantName = vendorNameField.getValueString(); + System.out.printf("Vendor Name: %s, confidence: %.2f%n", + merchantName, vendorNameField.getConfidence()); + } + } + + DocumentField vendorAddressField = invoiceFields.get("VendorAddress"); + if (vendorAddressField != null) { + if (DocumentFieldType.STRING == vendorAddressField.getType()) { + String merchantAddress = vendorAddressField.getValueString(); + System.out.printf("Vendor address: %s, confidence: %.2f%n", + merchantAddress, vendorAddressField.getConfidence()); + } + } + + DocumentField customerNameField = invoiceFields.get("CustomerName"); + if (customerNameField != null) { + if (DocumentFieldType.STRING == customerNameField.getType()) { + String merchantAddress = customerNameField.getValueString(); + System.out.printf("Customer Name: %s, confidence: %.2f%n", + merchantAddress, customerNameField.getConfidence()); + } + } + + DocumentField customerAddressRecipientField = invoiceFields.get("CustomerAddressRecipient"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.STRING == customerAddressRecipientField.getType()) { + String customerAddr = customerAddressRecipientField.getValueString(); + System.out.printf("Customer Address Recipient: %s, confidence: %.2f%n", + customerAddr, customerAddressRecipientField.getConfidence()); + } + } + + DocumentField invoiceIdField = invoiceFields.get("InvoiceId"); + if (invoiceIdField != null) { + if (DocumentFieldType.STRING == invoiceIdField.getType()) { + String invoiceId = invoiceIdField.getValueString(); + System.out.printf("Invoice ID: %s, confidence: %.2f%n", + invoiceId, invoiceIdField.getConfidence()); + } + } + + DocumentField invoiceDateField = invoiceFields.get("InvoiceDate"); + if (customerNameField != null) { + if (DocumentFieldType.DATE == invoiceDateField.getType()) { + LocalDate invoiceDate = invoiceDateField.getValueDate(); + System.out.printf("Invoice Date: %s, confidence: %.2f%n", + invoiceDate, invoiceDateField.getConfidence()); + } + } + + DocumentField invoiceTotalField = invoiceFields.get("InvoiceTotal"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.NUMBER == invoiceTotalField.getType()) { + Double invoiceTotal = invoiceTotalField.getValueNumber(); + System.out.printf("Invoice Total: %.2f, confidence: %.2f%n", + invoiceTotal, invoiceTotalField.getConfidence()); + } + } + + DocumentField invoiceItemsField = invoiceFields.get("Items"); + if (invoiceItemsField != null) { + System.out.printf("Invoice Items: %n"); + if (DocumentFieldType.ARRAY == invoiceItemsField.getType()) { + List invoiceItems = invoiceItemsField.getValueArray(); + invoiceItems.stream() + .filter(invoiceItem -> DocumentFieldType.OBJECT == invoiceItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + // See a full list of fields found on an invoice here: + // https://aka.ms/documentintelligence/invoicefields + if ("Description".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Description: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("UnitPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double unitPrice = documentField.getValueNumber(); + System.out.printf("Unit Price: %f, confidence: %.2f%n", + unitPrice, documentField.getConfidence()); + } + } + if ("ProductCode".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double productCode = documentField.getValueNumber(); + System.out.printf("Product Code: %f, confidence: %.2f%n", + productCode, documentField.getConfidence()); + } + } + })); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrl.java new file mode 100644 index 000000000000..c75da467e9b9 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrl.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.IOException; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +/** + * Sample for analyzing commonly found invoice fields from a file source URL of an invoice document. + * See fields found on an invoice here + */ +public class AnalyzeInvoicesFromUrl { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String invoiceUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/samples/sample_forms/forms/sample_invoice.jpg"; + + SyncPoller analyzeInvoicesPoller + = client.beginAnalyzeDocument("prebuilt-invoice", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(invoiceUrl)); + + AnalyzeResult analyzeInvoiceResult = analyzeInvoicesPoller.getFinalResult(); + + for (int i = 0; i < analyzeInvoiceResult.getDocuments().size(); i++) { + Document analyzedInvoice = analyzeInvoiceResult.getDocuments().get(i); + Map invoiceFields = analyzedInvoice.getFields(); + System.out.printf("----------- Analyzing invoice %d -----------%n", i); + DocumentField vendorNameField = invoiceFields.get("VendorName"); + if (vendorNameField != null) { + if (DocumentFieldType.STRING == vendorNameField.getType()) { + String merchantName = vendorNameField.getValueString(); + System.out.printf("Vendor Name: %s, confidence: %.2f%n", + merchantName, vendorNameField.getConfidence()); + } + } + + DocumentField vendorAddressField = invoiceFields.get("VendorAddress"); + if (vendorAddressField != null) { + if (DocumentFieldType.STRING == vendorAddressField.getType()) { + String merchantAddress = vendorAddressField.getValueString(); + System.out.printf("Vendor address: %s, confidence: %.2f%n", + merchantAddress, vendorAddressField.getConfidence()); + } + } + + DocumentField customerNameField = invoiceFields.get("CustomerName"); + if (customerNameField != null) { + if (DocumentFieldType.STRING == customerNameField.getType()) { + String merchantAddress = customerNameField.getValueString(); + System.out.printf("Customer Name: %s, confidence: %.2f%n", + merchantAddress, customerNameField.getConfidence()); + } + } + + DocumentField customerAddressRecipientField = invoiceFields.get("CustomerAddressRecipient"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.STRING == customerAddressRecipientField.getType()) { + String customerAddr = customerAddressRecipientField.getValueString(); + System.out.printf("Customer Address Recipient: %s, confidence: %.2f%n", + customerAddr, customerAddressRecipientField.getConfidence()); + } + } + + DocumentField invoiceIdField = invoiceFields.get("InvoiceId"); + if (invoiceIdField != null) { + if (DocumentFieldType.STRING == invoiceIdField.getType()) { + String invoiceId = invoiceIdField.getValueString(); + System.out.printf("Invoice ID: %s, confidence: %.2f%n", + invoiceId, invoiceIdField.getConfidence()); + } + } + + DocumentField invoiceDateField = invoiceFields.get("InvoiceDate"); + if (customerNameField != null) { + if (DocumentFieldType.DATE == invoiceDateField.getType()) { + LocalDate invoiceDate = invoiceDateField.getValueDate(); + System.out.printf("Invoice Date: %s, confidence: %.2f%n", + invoiceDate, invoiceDateField.getConfidence()); + } + } + + DocumentField invoiceTotalField = invoiceFields.get("InvoiceTotal"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.NUMBER == invoiceTotalField.getType()) { + Double invoiceTotal = invoiceTotalField.getValueNumber(); + System.out.printf("Invoice Total: %.2f, confidence: %.2f%n", + invoiceTotal, invoiceTotalField.getConfidence()); + } + } + + DocumentField invoiceItemsField = invoiceFields.get("Items"); + if (invoiceItemsField != null) { + System.out.printf("Invoice Items: %n"); + if (DocumentFieldType.ARRAY == invoiceItemsField.getType()) { + List invoiceItems = invoiceItemsField.getValueArray(); + invoiceItems.stream() + .filter(invoiceItem -> DocumentFieldType.OBJECT == invoiceItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + // See a full list of fields found on an invoice here: + // https://aka.ms/documentintelligence/invoicefields + if ("Description".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Description: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("UnitPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double unitPrice = documentField.getValueNumber(); + System.out.printf("Unit Price: %f, confidence: %.2f%n", + unitPrice, documentField.getConfidence()); + } + } + if ("ProductCode".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double productCode = documentField.getValueNumber(); + System.out.printf("Product Code: %f, confidence: %.2f%n", + productCode, documentField.getConfidence()); + } + } + })); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrlAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrlAsync.java new file mode 100644 index 000000000000..a21143bd4ffe --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeInvoicesFromUrlAsync.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.IOException; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found invoice fields from a file source URL of an invoice document. + * See fields found on an invoice here + */ +public class AnalyzeInvoicesFromUrlAsync { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String invoiceUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/samples/sample_forms/forms/sample_invoice.jpg"; + + PollerFlux analyzeInvoicePoller + = client.beginAnalyzeDocument("prebuilt-invoice", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(invoiceUrl)); + + Mono analyzeInvoiceResultMono = analyzeInvoicePoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + analyzeInvoiceResultMono.subscribe(analyzeInvoiceResult -> { + for (int i = 0; i < analyzeInvoiceResult.getDocuments().size(); i++) { + Document analyzedInvoice = analyzeInvoiceResult.getDocuments().get(i); + Map invoiceFields = analyzedInvoice.getFields(); + System.out.printf("----------- Analyzing invoice %d -----------%n", i); + DocumentField vendorNameField = invoiceFields.get("VendorName"); + if (vendorNameField != null) { + if (DocumentFieldType.STRING == vendorNameField.getType()) { + String merchantName = vendorNameField.getValueString(); + System.out.printf("Vendor Name: %s, confidence: %.2f%n", + merchantName, vendorNameField.getConfidence()); + } + } + + DocumentField vendorAddressField = invoiceFields.get("VendorAddress"); + if (vendorAddressField != null) { + if (DocumentFieldType.STRING == vendorAddressField.getType()) { + String merchantAddress = vendorAddressField.getValueString(); + System.out.printf("Vendor address: %s, confidence: %.2f%n", + merchantAddress, vendorAddressField.getConfidence()); + } + } + + DocumentField customerNameField = invoiceFields.get("CustomerName"); + if (customerNameField != null) { + if (DocumentFieldType.STRING == customerNameField.getType()) { + String merchantAddress = customerNameField.getValueString(); + System.out.printf("Customer Name: %s, confidence: %.2f%n", + merchantAddress, customerNameField.getConfidence()); + } + } + + DocumentField customerAddressRecipientField = invoiceFields.get("CustomerAddressRecipient"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.STRING == customerAddressRecipientField.getType()) { + String customerAddr = customerAddressRecipientField.getValueString(); + System.out.printf("Customer Address Recipient: %s, confidence: %.2f%n", + customerAddr, customerAddressRecipientField.getConfidence()); + } + } + + DocumentField invoiceIdField = invoiceFields.get("InvoiceId"); + if (invoiceIdField != null) { + if (DocumentFieldType.STRING == invoiceIdField.getType()) { + String invoiceId = invoiceIdField.getValueString(); + System.out.printf("Invoice ID: %s, confidence: %.2f%n", + invoiceId, invoiceIdField.getConfidence()); + } + } + + DocumentField invoiceDateField = invoiceFields.get("InvoiceDate"); + if (customerNameField != null) { + if (DocumentFieldType.DATE == invoiceDateField.getType()) { + LocalDate invoiceDate = invoiceDateField.getValueDate(); + System.out.printf("Invoice Date: %s, confidence: %.2f%n", + invoiceDate, invoiceDateField.getConfidence()); + } + } + + DocumentField invoiceTotalField = invoiceFields.get("InvoiceTotal"); + if (customerAddressRecipientField != null) { + if (DocumentFieldType.NUMBER == invoiceTotalField.getType()) { + Double invoiceTotal = invoiceTotalField.getValueNumber(); + System.out.printf("Invoice Total: %.2f, confidence: %.2f%n", + invoiceTotal, invoiceTotalField.getConfidence()); + } + } + + DocumentField invoiceItemsField = invoiceFields.get("Items"); + if (invoiceItemsField != null) { + System.out.printf("Invoice Items: %n"); + if (DocumentFieldType.ARRAY == invoiceItemsField.getType()) { + List invoiceItems = invoiceItemsField.getValueArray(); + invoiceItems.stream() + .filter(invoiceItem -> DocumentFieldType.OBJECT == invoiceItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + // See a full list of fields found on an invoice here: + // https://aka.ms/documentintelligence/invoicefields + if ("Description".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Description: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("UnitPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double unitPrice = documentField.getValueNumber(); + System.out.printf("Unit Price: %f, confidence: %.2f%n", + unitPrice, documentField.getConfidence()); + } + } + if ("ProductCode".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double productCode = documentField.getValueNumber(); + System.out.printf("Product Code: %f, confidence: %.2f%n", + productCode, documentField.getConfidence()); + } + } + })); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayout.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayout.java new file mode 100644 index 000000000000..ae3558bee14c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayout.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; + +/** + * Sample for analyzing layout information from a document given through a file. + */ +public class AnalyzeLayout { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + File selectionMarkDocument = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/forms/selectionMarkForm.pdf"); + + SyncPoller analyzeLayoutResultPoller = + client.beginAnalyzeDocument("prebuilt-layout", null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(selectionMarkDocument.toPath()))); + + AnalyzeResult analyzeLayoutResult = analyzeLayoutResultPoller.getFinalResult(); + + // pages + analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s; is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f%n.", + documentWord.getContent(), + documentWord.getConfidence())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding polygon %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon(), + documentSelectionMark.getConfidence())); + }); + + // tables + List tables = analyzeLayoutResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + + // styles + analyzeLayoutResult.getStyles().forEach(documentStyle + -> System.out.printf("Document is handwritten %s%n.", documentStyle.isHandwritten())); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutAsync.java new file mode 100644 index 000000000000..8bfa492a0270 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutAsync.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing layout information from a document given through a file. + */ +public class AnalyzeLayoutAsync { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/forms/selectionMarkForm.pdf"); + byte[] fileContent = Files.readAllBytes(sourceFile.toPath()); + InputStream targetStream = new ByteArrayInputStream(fileContent); + + PollerFlux analyzeLayoutPoller = + client.beginAnalyzeDocument("prebuilt-layout", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(sourceFile.toPath()))); + + Mono analyzeLayoutResultMono = + analyzeLayoutPoller + .last() + .flatMap(pollResponse -> { + if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED.equals(pollResponse.getStatus())) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error( + new RuntimeException( + "Polling completed unsuccessfully with status:" + pollResponse.getStatus())); + } + }); + + analyzeLayoutResultMono.subscribe(analyzeLayoutResult -> { + // pages + analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding polygon %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon(), + documentSelectionMark.getConfidence())); + }); + + // tables + List tables = analyzeLayoutResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + + // styles + analyzeLayoutResult.getStyles().forEach(documentStyle + -> System.out.printf("Document is handwritten %s.%n", documentStyle.isHandwritten())); + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrl.java new file mode 100644 index 000000000000..ed5e0118d394 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrl.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.util.List; + +/** + * Sample for analyzing content information from a document given through a URL. + */ +public class AnalyzeLayoutFromUrl { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + SyncPoller analyzeLayoutPoller = + client.beginAnalyzeDocument("prebuilt-layout", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource("https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/selectionMarkForm.pdf")); + + AnalyzeResult analyzeLayoutResult = analyzeLayoutPoller.getFinalResult(); + + // pages + analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding polygon %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon(), + documentSelectionMark.getConfidence())); + }); + + // tables + List tables = analyzeLayoutResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + + // styles + analyzeLayoutResult.getStyles().forEach(documentStyle + -> System.out.printf("Document is handwritten %s.%n", documentStyle.isHandwritten())); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrlAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrlAsync.java new file mode 100644 index 000000000000..21b3f5a8a625 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeLayoutFromUrlAsync.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing layout information from a document given through a URL. + */ +public class AnalyzeLayoutFromUrlAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + PollerFlux analyzeLayoutPoller = + client.beginAnalyzeDocument("prebuilt-layout", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource("https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence/" + + "azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/selectionMarkForm.pdf")); + + Mono analyzeLayoutResultMono = + analyzeLayoutPoller + .last() + .flatMap(pollResponse -> { + if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED.equals(pollResponse.getStatus())) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error( + new RuntimeException( + "Polling completed unsuccessfully with status:" + pollResponse.getStatus())); + } + }); + + analyzeLayoutResultMono.subscribe(analyzeLayoutResult -> { + // pages + analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding box %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding polygon %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon(), + documentSelectionMark.getConfidence())); + }); + + // tables + List tables = analyzeLayoutResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + + // styles + analyzeLayoutResult.getStyles().forEach(documentStyle + -> System.out.printf("Document is handwritten %s.%n", documentStyle.isHandwritten())); + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceipts.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceipts.java new file mode 100644 index 000000000000..e31a93530e3a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceipts.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +/** + * Sample for analyzing commonly found receipt fields from a local file input stream. + * See fields found on a receipt here + */ +public class AnalyzeReceipts { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException from reading file. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/receipts/contoso-allinone.jpg"); + + SyncPoller analyzeReceiptPoller = + client.beginAnalyzeDocument("prebuilt-receipt", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(sourceFile.toPath()))); + + AnalyzeResult receiptResults = analyzeReceiptPoller.getFinalResult(); + + for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } + + DocumentField receiptItemsField = receiptFields.get("Items"); + if (receiptItemsField != null) { + System.out.printf("Receipt Items: %n"); + if (DocumentFieldType.ARRAY == receiptItemsField.getType()) { + List receiptItems = receiptItemsField.getValueArray(); + receiptItems.stream() + .filter(receiptItem -> DocumentFieldType.OBJECT == receiptItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + if ("Name".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Name: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("Price".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double price = documentField.getValueNumber(); + System.out.printf("Price: %f, confidence: %.2f%n", + price, documentField.getConfidence()); + } + } + if ("TotalPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double totalPrice = documentField.getValueNumber(); + System.out.printf("Total Price: %f, confidence: %.2f%n", + totalPrice, documentField.getConfidence()); + } + } + })); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsAsync.java new file mode 100644 index 000000000000..643a63e4c58d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsAsync.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found receipt fields from a local file input stream. + * See fields found on a receipt here + */ +public class AnalyzeReceiptsAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/receipts/contoso-allinone.jpg"); + + PollerFlux analyzeReceiptPoller; + analyzeReceiptPoller = client.beginAnalyzeDocument("prebuilt-receipt", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(sourceFile.toPath()))); + + + Mono receiptResultsMono = analyzeReceiptPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + receiptResultsMono.subscribe(receiptResults -> { + for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } + + DocumentField receiptItemsField = receiptFields.get("Items"); + if (receiptItemsField != null) { + System.out.printf("Receipt Items: %n"); + if (DocumentFieldType.ARRAY == receiptItemsField.getType()) { + List receiptItems = receiptItemsField.getValueArray(); + receiptItems.stream() + .filter(receiptItem -> DocumentFieldType.OBJECT == receiptItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + if ("Name".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Name: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("Price".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double price = documentField.getValueNumber(); + System.out.printf("Price: %f, confidence: %.2f%n", + price, documentField.getConfidence()); + } + } + if ("TotalPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double totalPrice = documentField.getValueNumber(); + System.out.printf("Total Price: %f, confidence: %.2f%n", + totalPrice, documentField.getConfidence()); + } + } + })); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrl.java new file mode 100644 index 000000000000..e472b6b915b6 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrl.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.time.LocalDate; +import java.util.List; +import java.util.Map; + +/** + * Sample for analyzing commonly found receipt fields from a file source URL. + * See fields found on a receipt here. + * + */ +public class AnalyzeReceiptsFromUrl { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String receiptUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence" + + "/azure-ai-documentintelligence/src/samples/resources/sample-forms/receipts/contoso-allinone.jpg"; + + SyncPoller analyzeReceiptPoller = + client.beginAnalyzeDocument("prebuilt-receipt", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(receiptUrl)); + + AnalyzeResult receiptResults = analyzeReceiptPoller.getFinalResult(); + + for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } + + DocumentField receiptItemsField = receiptFields.get("Items"); + if (receiptItemsField != null) { + System.out.printf("Receipt Items: %n"); + if (DocumentFieldType.ARRAY == receiptItemsField.getType()) { + List receiptItems = receiptItemsField.getValueArray(); + receiptItems.stream() + .filter(receiptItem -> DocumentFieldType.OBJECT == receiptItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + if ("Name".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Name: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("Price".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double price = documentField.getValueNumber(); + System.out.printf("Price: %f, confidence: %.2f%n", + price, documentField.getConfidence()); + } + } + if ("TotalPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double totalPrice = documentField.getValueNumber(); + System.out.printf("Total Price: %f, confidence: %.2f%n", + totalPrice, documentField.getConfidence()); + } + } + })); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrlAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrlAsync.java new file mode 100644 index 000000000000..d255a4fccb38 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeReceiptsFromUrlAsync.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Async sample for analyzing commonly found receipt fields from a file source URL. + * See fields found on a receipt here + */ +public class AnalyzeReceiptsFromUrlAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String receiptUrl = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence" + + "/azure-ai-documentintelligence/src/samples/resources/sample-forms/receipts/contoso-allinone.jpg"; + + PollerFlux analyzeReceiptPoller = + client.beginAnalyzeDocument("prebuilt-receipt", null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(receiptUrl)); + + Mono receiptResultsMono = analyzeReceiptPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + receiptResultsMono.subscribe(receiptResults -> { + for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } + + DocumentField receiptItemsField = receiptFields.get("Items"); + if (receiptItemsField != null) { + System.out.printf("Receipt Items: %n"); + if (DocumentFieldType.ARRAY == receiptItemsField.getType()) { + List receiptItems = receiptItemsField.getValueArray(); + receiptItems.stream() + .filter(receiptItem -> DocumentFieldType.OBJECT == receiptItem.getType()) + .map(documentField -> documentField.getValueObject()) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + if ("Name".equals(key)) { + if (DocumentFieldType.STRING == documentField.getType()) { + String name = documentField.getValueString(); + System.out.printf("Name: %s, confidence: %.2fs%n", + name, documentField.getConfidence()); + } + } + if ("Quantity".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double quantity = documentField.getValueNumber(); + System.out.printf("Quantity: %f, confidence: %.2f%n", + quantity, documentField.getConfidence()); + } + } + if ("Price".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double price = documentField.getValueNumber(); + System.out.printf("Price: %f, confidence: %.2f%n", + price, documentField.getConfidence()); + } + } + if ("TotalPrice".equals(key)) { + if (DocumentFieldType.NUMBER == documentField.getType()) { + Double totalPrice = documentField.getValueNumber(); + System.out.printf("Total Price: %f, confidence: %.2f%n", + totalPrice, documentField.getConfidence()); + } + } + })); + } + } + } + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2.java new file mode 100644 index 000000000000..fc285c03eaba --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.SyncPoller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.LocalDate; +import java.util.Map; + +/** + * Sample for analyzing commonly found W-2 fields from a local file input stream of a tax W-2 document. + * See fields found on a US Tax W2 document here + */ +public class AnalyzeTaxW2 { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + File invoice = new File("./documentintelligence/azure-ai-documentintelligence/src/samples/resources/Sample-W2.jpg"); + + SyncPoller analyzeW2Poller = + client.beginAnalyzeDocument("prebuilt-tax.us.w2", null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(invoice.toPath()))); + + AnalyzeResult analyzeTaxResult = analyzeW2Poller.getFinalResult(); + + for (int i = 0; i < analyzeTaxResult.getDocuments().size(); i++) { + Document analyzedTaxDocument = analyzeTaxResult.getDocuments().get(i); + Map taxFields = analyzedTaxDocument.getFields(); + System.out.printf("----------- Analyzing Document %d -----------%n", i); + DocumentField w2FormVariantField = taxFields.get("W2FormVariant"); + if (w2FormVariantField != null) { + if (DocumentFieldType.STRING == w2FormVariantField.getType()) { + String merchantName = w2FormVariantField.getValueString(); + System.out.printf("Form variant: %s, confidence: %.2f%n", + merchantName, w2FormVariantField.getConfidence()); + } + } + + DocumentField employeeField = taxFields.get("Employee"); + if (employeeField != null) { + System.out.println("Employee Data: "); + if (DocumentFieldType.OBJECT == employeeField.getType()) { + Map employeeDataFieldMap = employeeField.getValueObject(); + DocumentField employeeName = employeeDataFieldMap.get("Name"); + if (employeeName != null) { + if (DocumentFieldType.STRING == employeeName.getType()) { + String merchantAddress = employeeName.getValueString(); + System.out.printf("Employee Name: %s, confidence: %.2f%n", + merchantAddress, employeeName.getConfidence()); + } + } + DocumentField employeeAddrField = employeeDataFieldMap.get("Address"); + if (employeeAddrField != null) { + if (DocumentFieldType.STRING == employeeAddrField.getType()) { + String employeeAddress = employeeAddrField.getValueString(); + System.out.printf("Employee Address: %s, confidence: %.2f%n", + employeeAddress, employeeAddrField.getConfidence()); + } + } + } + } + + DocumentField employerField = taxFields.get("Employer"); + if (employerField != null) { + System.out.println("Employer Data: "); + if (DocumentFieldType.OBJECT == employerField.getType()) { + Map employerDataFieldMap = employerField.getValueObject(); + DocumentField employerNameField = employerDataFieldMap.get("Name"); + if (employerNameField != null) { + if (DocumentFieldType.STRING == employerNameField.getType()) { + String employerName = employerNameField.getValueString(); + System.out.printf("Employee Name: %s, confidence: %.2f%n", + employerName, employerNameField.getConfidence()); + } + } + + DocumentField employerIDNumberField = employerDataFieldMap.get("IdNumber"); + if (employerIDNumberField != null) { + if (DocumentFieldType.STRING == employerIDNumberField.getType()) { + String employerIdNumber = employerIDNumberField.getValueString(); + System.out.printf("Employee ID Number: %s, confidence: %.2f%n", + employerIdNumber, employerIDNumberField.getConfidence()); + } + } + } + } + + DocumentField localTaxInfosField = taxFields.get("LocalTaxInfos"); + if (localTaxInfosField != null) { + System.out.println("Local Tax Info data:"); + if (DocumentFieldType.ARRAY == localTaxInfosField.getType()) { + Map localTaxInfoDataFields = localTaxInfosField.getValueObject(); + DocumentField localWagesTips = localTaxInfoDataFields.get("LocalWagesTipsEtc"); + if (DocumentFieldType.NUMBER == localTaxInfosField.getType()) { + System.out.printf("Local Wages Tips Value: %.2f, confidence: %.2f%n", + localWagesTips.getValueNumber(), localTaxInfosField.getConfidence()); + } + } + } + + DocumentField taxYearField = taxFields.get("TaxYear"); + if (taxYearField != null) { + if (DocumentFieldType.STRING == taxYearField.getType()) { + String taxYear = taxYearField.getValueString(); + System.out.printf("Tax year: %s, confidence: %.2f%n", + taxYear, taxYearField.getConfidence()); + } + } + + DocumentField taxDateField = taxFields.get("TaxDate"); + if (employeeField != null) { + if (DocumentFieldType.DATE == taxDateField.getType()) { + LocalDate taxDate = taxDateField.getValueDate(); + System.out.printf("Tax Date: %s, confidence: %.2f%n", + taxDate, taxDateField.getConfidence()); + } + } + + DocumentField socialSecurityTaxField = taxFields.get("SocialSecurityTaxWithheld"); + if (localTaxInfosField != null) { + if (DocumentFieldType.NUMBER == socialSecurityTaxField.getType()) { + Double socialSecurityTax = socialSecurityTaxField.getValueNumber(); + System.out.printf("Social Security Tax withheld: %.2f, confidence: %.2f%n", + socialSecurityTax, socialSecurityTaxField.getConfidence()); + } + } + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2Async.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2Async.java new file mode 100644 index 000000000000..65dcf041e7ba --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/AnalyzeTaxW2Async.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.io.IOException; +import java.time.LocalDate; +import java.util.Map; + +/** + * Async Sample for analyzing commonly found W-2 fields from a local file input stream of a tax W-2 document. + * See fields found on a US Tax W2 document here + */ +public class AnalyzeTaxW2Async { + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public static void main(final String[] args) throws IOException { + // Instantiate a client that will be used to call the service. + DocumentAnalysisAsyncClient client = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String w2Url = + "https://raw.githubusercontent.com/Azure/azure-sdk-for-java/main/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/w2/Sample-W2.jpg"; + + PollerFlux analyzeW2Poller = + client.beginAnalyzeDocument("prebuilt-tax.us.w2", null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(w2Url)); + + Mono w2Mono = analyzeW2Poller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + System.out.println("Polling completed successfully"); + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + w2Mono.subscribe(analyzeTaxResult -> { + + for (int i = 0; i < analyzeTaxResult.getDocuments().size(); i++) { + Document analyzedTaxDocument = analyzeTaxResult.getDocuments().get(i); + Map taxFields = analyzedTaxDocument.getFields(); + System.out.printf("----------- Analyzing Document %d -----------%n", i); + DocumentField w2FormVariantField = taxFields.get("W2FormVariant"); + if (w2FormVariantField != null) { + if (DocumentFieldType.STRING == w2FormVariantField.getType()) { + String merchantName = w2FormVariantField.getValueString(); + System.out.printf("Form variant: %s, confidence: %.2f%n", + merchantName, w2FormVariantField.getConfidence()); + } + } + + DocumentField employeeField = taxFields.get("Employee"); + if (employeeField != null) { + System.out.println("Employee Data: "); + if (DocumentFieldType.OBJECT == employeeField.getType()) { + Map employeeDataFieldMap = employeeField.getValueObject(); + DocumentField employeeName = employeeDataFieldMap.get("Name"); + if (employeeName != null) { + if (DocumentFieldType.STRING == employeeName.getType()) { + String merchantAddress = employeeName.getValueString(); + System.out.printf("Employee Name: %s, confidence: %.2f%n", + merchantAddress, employeeName.getConfidence()); + } + } + DocumentField employeeAddrField = employeeDataFieldMap.get("Address"); + if (employeeAddrField != null) { + if (DocumentFieldType.STRING == employeeAddrField.getType()) { + String employeeAddress = employeeAddrField.getValueString(); + System.out.printf("Employee Address: %s, confidence: %.2f%n", + employeeAddress, employeeAddrField.getConfidence()); + } + } + } + } + + DocumentField employerField = taxFields.get("Employer"); + if (employerField != null) { + System.out.println("Employer Data: "); + if (DocumentFieldType.OBJECT == employerField.getType()) { + Map employerDataFieldMap = employerField.getValueObject(); + DocumentField employerNameField = employerDataFieldMap.get("Name"); + if (employerNameField != null) { + if (DocumentFieldType.STRING == employerNameField.getType()) { + String employerName = employerNameField.getValueString(); + System.out.printf("Employee Name: %s, confidence: %.2f%n", + employerName, employerNameField.getConfidence()); + } + } + + DocumentField employerIDNumberField = employerDataFieldMap.get("IdNumber"); + if (employerIDNumberField != null) { + if (DocumentFieldType.STRING == employerIDNumberField.getType()) { + String employerIdNumber = employerIDNumberField.getValueString(); + System.out.printf("Employee ID Number: %s, confidence: %.2f%n", + employerIdNumber, employerIDNumberField.getConfidence()); + } + } + } + } + + DocumentField localTaxInfosField = taxFields.get("LocalTaxInfos"); + if (localTaxInfosField != null) { + System.out.println("Local Tax Info data:"); + if (DocumentFieldType.ARRAY == localTaxInfosField.getType()) { + Map localTaxInfoDataFields = localTaxInfosField.getValueObject(); + DocumentField localWagesTips = localTaxInfoDataFields.get("LocalWagesTipsEtc"); + if (DocumentFieldType.NUMBER == localTaxInfosField.getType()) { + System.out.printf("Local Wages Tips Value: %.2f, confidence: %.2f%n", + localWagesTips.getValueNumber(), localTaxInfosField.getConfidence()); + } + } + } + + DocumentField taxYearField = taxFields.get("TaxYear"); + if (taxYearField != null) { + if (DocumentFieldType.STRING == taxYearField.getType()) { + String taxYear = taxYearField.getValueString(); + System.out.printf("Tax year: %s, confidence: %.2f%n", + taxYear, taxYearField.getConfidence()); + } + } + + DocumentField taxDateField = taxFields.get("TaxDate"); + if (employeeField != null) { + if (DocumentFieldType.DATE == taxDateField.getType()) { + LocalDate taxDate = taxDateField.getValueDate(); + System.out.printf("Tax Date: %s, confidence: %.2f%n", + taxDate, taxDateField.getConfidence()); + } + } + + DocumentField socialSecurityTaxField = taxFields.get("SocialSecurityTaxWithheld"); + if (localTaxInfosField != null) { + if (DocumentFieldType.NUMBER == socialSecurityTaxField.getType()) { + Double socialSecurityTax = socialSecurityTaxField.getValueNumber(); + System.out.printf("Social Security Tax withheld: %.2f, confidence: %.2f%n", + socialSecurityTax, socialSecurityTaxField.getConfidence()); + } + } + } + }); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClientJavaDocCodeSnippets.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..a6a6dfbd317a --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisAsyncClientJavaDocCodeSnippets.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.ClassifyDocumentRequest; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.SplitMode; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.AsyncPollResponse; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; + +/** + * Code snippet for {@link DocumentAnalysisAsyncClient} + */ +public class DocumentAnalysisAsyncClientJavaDocCodeSnippets { + private final DocumentAnalysisAsyncClient documentAnalysisAsyncClient + = new DocumentAnalysisClientBuilder().buildAsyncClient(); + + /** + * Code snippet for creating a {@link DocumentAnalysisAsyncClient} + */ + public void createDocumentAnalysisAsyncClient() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.instantiation + DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildAsyncClient(); + // END: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.instantiation + } + + /** + * Code snippet for creating a {@link DocumentAnalysisAsyncClient} with pipeline + */ + public void createDocumentAnalysisAsyncClientWithPipeline() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.pipeline.instantiation + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(/* add policies */) + .build(); + + DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .pipeline(pipeline) + .buildAsyncClient(); + // END: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.pipeline.instantiation + } + + /** + * Code snippet for {@link DocumentAnalysisAsyncClient#beginAnalyzeDocument(String, String, String, StringIndexType, List, List, ContentFormat, AnalyzeDocumentRequest)} + */ + public void beginAnalyzeDocumentFromUrl() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.beginAnalyzeDocumentFromUrl#String-String-String-StringIndexType-List-List-ContentFormat-AnalyzeDocumentRequest + String documentUrl = "{document_url}"; + String modelId = "{model_id}"; + documentAnalysisAsyncClient.beginAnalyzeDocument(modelId, + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)) + // if polling operation completed, retrieve the final result. + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(analyzeResult -> + analyzeResult.getDocuments() + .forEach(document -> + document.getFields() + .forEach((key, documentField) -> { + System.out.printf("Field text: %s%n", key); + System.out.printf("Field value data content: %s%n", documentField.getContent()); + System.out.printf("Confidence score: %.2f%n", documentField.getConfidence()); + }))); + // END: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.beginAnalyzeDocumentFromUrl#String-String-String-StringIndexType-List-List-ContentFormat-AnalyzeDocumentRequest + } + + /** + * Code snippet for + * {@link DocumentAnalysisAsyncClient#beginClassifyDocument(String, ClassifyDocumentRequest, StringIndexType, SplitMode)} + * with options + * + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public void beginClassifyDocument() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.beginClassifyDocument#String-ClassifyDocumentRequest-StringIndexType-SplitMode + File document = new File("{local/file_path/fileName.jpg}"); + String classifierId = "{model_id}"; + + // Utility method to convert input stream to Binary Data + BinaryData buffer = BinaryData.fromStream(new ByteArrayInputStream(Files.readAllBytes(document.toPath()))); + + documentAnalysisAsyncClient.beginClassifyDocument(classifierId, new ClassifyDocumentRequest().setBase64Source(Files.readAllBytes(document.toPath()))) + // if polling operation completed, retrieve the final result. + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(analyzeResult -> { + System.out.println(analyzeResult.getModelId()); + analyzeResult.getDocuments() + .forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType())); + }); + // END: com.azure.ai.documentintelligence.DocumentAnalysisAsyncClient.beginClassifyDocument#String-ClassifyDocumentRequest-StringIndexType-SplitMode + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisClientJavaDocCodeSnippets.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..a5ec0242bd12 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/DocumentAnalysisClientJavaDocCodeSnippets.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ClassifyDocumentRequest; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.util.polling.SyncPoller; +import com.azure.identity.DefaultAzureCredentialBuilder; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; + +/** + * Code snippet for {@link DocumentAnalysisClient} + */ +public class DocumentAnalysisClientJavaDocCodeSnippets { + private final DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder().buildClient(); + private final DocumentModelAdministrationClient documentModelAdminClient = + new DocumentModelAdministrationClientBuilder().buildClient(); + + /** + * Code snippet for creating a {@link DocumentAnalysisClient} + */ + public void createDocumentAnalysisClient() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisClient.instantiation + DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildClient(); + // END: com.azure.ai.documentintelligence.DocumentAnalysisClient.instantiation + } + + public void useAadAsyncClient() { + // BEGIN: readme-sample-createDocumentAnalysisAsyncClientWithAAD + DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder() + .endpoint("{endpoint}") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildAsyncClient(); + // END: readme-sample-createDocumentAnalysisAsyncClientWithAAD + } + + /** + * Code snippet for creating a {@link DocumentAnalysisClient} with pipeline + */ + public void createDocumentAnalysisClientWithPipeline() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisClient.pipeline.instantiation + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(/* add policies */) + .build(); + + DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .pipeline(pipeline) + .buildClient(); + // END: com.azure.ai.documentintelligence.DocumentAnalysisClient.pipeline.instantiation + } + + + // Analyze Custom Form + + /** + * Code snippet for {@link DocumentAnalysisClient#beginAnalyzeDocument(String, String, String, StringIndexType, List, List, ContentFormat, AnalyzeDocumentRequest)} + */ + public void beginAnalyzeDocumentFromUrl() { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl#String-String-String-StringIndexType-List-List-ContentFormat-AnalyzeDocumentRequest + String documentUrl = "{document_url}"; + String modelId = "{custom_trained_model_id}"; + + documentAnalysisClient.beginAnalyzeDocument(modelId, + "1", + "en-US", + StringIndexType.TEXT_ELEMENTS, + Arrays.asList(DocumentAnalysisFeature.LANGUAGES), + null, + ContentFormat.TEXT, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)).getFinalResult() + .getDocuments().stream() + .map(Document::getFields) + .forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> { + System.out.printf("Field text: %s%n", key); + System.out.printf("Field value data content: %s%n", documentField.getContent()); + System.out.printf("Confidence score: %.2f%n", documentField.getConfidence()); + })); + + // END: com.azure.ai.documentintelligence.DocumentAnalysisClient.beginAnalyzeDocumentFromUrl#String-String-String-StringIndexType-List-List-ContentFormat-AnalyzeDocumentRequest + } + + /** + * Code snippet for + * {@link DocumentAnalysisClient#beginClassifyDocument(String, ClassifyDocumentRequest)} + * + * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. + */ + public void beginClassifyDocumentContext() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.DocumentAnalysisClient.beginClassifyDocument#string-BinaryData-Context + File document = new File("{local/file_path/fileName.jpg}"); + String classifierId = "{custom_trained_classifier_id}"; + + documentAnalysisClient.beginClassifyDocument(classifierId, new ClassifyDocumentRequest().setBase64Source(Files.readAllBytes(document.toPath()))) + .getFinalResult() + .getDocuments() + .forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType())); + // END: com.azure.ai.documentintelligence.DocumentAnalysisClient.beginClassifyDocument#string-BinaryData-Context + } + + private void buildAndAnalyzeCustomDocument() { + // BEGIN: readme-sample-build-analyze + String blobContainerUrl = "{SAS_URL_of_your_container_in_blob_storage}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your custom documents. + String prefix = "{blob_name_prefix}}"; + // Build custom document analysis model + SyncPoller buildOperationPoller = + documentModelAdminClient.beginBuildDocumentModel( + new BuildDocumentModelRequest("modelId", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))); + + DocumentModelDetails customBuildModel = buildOperationPoller.getFinalResult(); + + // analyze using custom-built model + String modelId = customBuildModel.getModelId(); + String documentUrl = "documentUrl"; + SyncPoller analyzeDocumentPoller = + documentAnalysisClient.beginAnalyzeDocument(modelId, + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)); + + AnalyzeResult analyzeResult = analyzeDocumentPoller.getFinalResult(); + + for (int i = 0; i < analyzeResult.getDocuments().size(); i++) { + final Document analyzedDocument = analyzeResult.getDocuments().get(i); + System.out.printf("----------- Analyzing custom document %d -----------%n", i); + System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n", + analyzedDocument.getDocType(), analyzedDocument.getConfidence()); + analyzedDocument.getFields().forEach((key, documentField) -> { + System.out.printf("Document Field content: %s%n", documentField.getContent()); + System.out.printf("Document Field confidence: %.2f%n", documentField.getConfidence()); + System.out.printf("Document Field Type: %s%n", documentField.getType()); + System.out.printf("Document Field found within bounding region: %s%n", + documentField.getBoundingRegions().toString()); + }); + } + + analyzeResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding box %s.%n", + documentLine.getContent(), + documentLine.getPolygon().toString())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + }); + + // tables + List tables = analyzeResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + // END: readme-sample-build-analyze + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/ReadmeSamples.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/ReadmeSamples.java new file mode 100644 index 000000000000..b1b6fffaa234 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/ReadmeSamples.java @@ -0,0 +1,296 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.documentintelligence; + +import com.azure.ai.documentintelligence.models.AnalyzeDocumentRequest; +import com.azure.ai.documentintelligence.models.AnalyzeResult; +import com.azure.ai.documentintelligence.models.AnalyzeResultOperation; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ContentFormat; +import com.azure.ai.documentintelligence.models.Document; +import com.azure.ai.documentintelligence.models.DocumentAnalysisFeature; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentField; +import com.azure.ai.documentintelligence.models.DocumentFieldType; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.DocumentTable; +import com.azure.ai.documentintelligence.models.ResourceDetails; +import com.azure.ai.documentintelligence.models.StringIndexType; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.SyncPoller; +import com.azure.identity.DefaultAzureCredentialBuilder; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public final class ReadmeSamples { + DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder().buildClient(); + DocumentModelAdministrationClient administrationClient = new DocumentModelAdministrationClientBuilder() + .buildClient(); + public void createWithKeyCredential() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.readme.createDocumentAnalysisClient + DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildClient(); + // END: com.azure.ai.documentintelligence.readme.createDocumentAnalysisClient + } + + /** + * Code snippet for creating a {@link DocumentAnalysisAsyncClient} + */ + public void createDocumentAnalysisClientWithAAD() { + // BEGIN: com.azure.ai.documentanalysis.readme.DocumentAnalysisAsyncClient.withAAD + DocumentAnalysisAsyncClient documentAnalysisAsyncClient = new DocumentAnalysisClientBuilder() + .credential(new DefaultAzureCredentialBuilder().build()) + .endpoint("{endpoint}") + .buildAsyncClient(); + // END: com.azure.ai.documentanalysis.readme.DocumentAnalysisAsyncClient.withAAD + } + + public void analyzeLayout() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.readme.analyzeLayout + File layoutDocument = new File("local/file_path/filename.png"); + Path filePath = layoutDocument.toPath(); + BinaryData layoutDocumentData = BinaryData.fromFile(filePath, (int) layoutDocument.length()); + + SyncPoller analyzeLayoutResultPoller = + documentAnalysisClient.beginAnalyzeDocument("prebuilt-layout", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(layoutDocument.toPath()))); + + AnalyzeResult analyzeLayoutResult = analyzeLayoutResultPoller.getFinalResult(); + + // pages + analyzeLayoutResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding box %s.%n", + documentLine.getContent(), + documentLine.getPolygon().toString())); + + // selection marks + documentPage.getSelectionMarks().forEach(documentSelectionMark -> + System.out.printf("Selection mark is '%s' and is within a bounding box %s with confidence %.2f.%n", + documentSelectionMark.getState().toString(), + documentSelectionMark.getPolygon().toString(), + documentSelectionMark.getConfidence())); + }); + + // tables + List tables = analyzeLayoutResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + // END: com.azure.ai.documentintelligence.readme.analyzeLayout + } + + public void analyzeReceipts() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.readme.analyzeReceipt + File sourceFile = new File("../documentintelligence/azure-ai-documentintelligence/src/samples/resources/" + + "sample-forms/receipts/contoso-allinone.jpg"); + + SyncPoller analyzeReceiptPoller = + documentAnalysisClient.beginAnalyzeDocument("prebuilt-receipt", + null, + null, + null, + null, + null, + null, + new AnalyzeDocumentRequest().setBase64Source(Files.readAllBytes(sourceFile.toPath()))); + + AnalyzeResult receiptResults = analyzeReceiptPoller.getFinalResult(); + + for (int i = 0; i < receiptResults.getDocuments().size(); i++) { + Document analyzedReceipt = receiptResults.getDocuments().get(i); + Map receiptFields = analyzedReceipt.getFields(); + System.out.printf("----------- Analyzing receipt info %d -----------%n", i); + DocumentField merchantNameField = receiptFields.get("MerchantName"); + if (merchantNameField != null) { + if (DocumentFieldType.STRING == merchantNameField.getType()) { + String merchantName = merchantNameField.getValueString(); + System.out.printf("Merchant Name: %s, confidence: %.2f%n", + merchantName, merchantNameField.getConfidence()); + } + } + + DocumentField merchantPhoneNumberField = receiptFields.get("MerchantPhoneNumber"); + if (merchantPhoneNumberField != null) { + if (DocumentFieldType.PHONE_NUMBER == merchantPhoneNumberField.getType()) { + String merchantAddress = merchantPhoneNumberField.getValuePhoneNumber(); + System.out.printf("Merchant Phone number: %s, confidence: %.2f%n", + merchantAddress, merchantPhoneNumberField.getConfidence()); + } + } + + DocumentField merchantAddressField = receiptFields.get("MerchantAddress"); + if (merchantAddressField != null) { + if (DocumentFieldType.STRING == merchantAddressField.getType()) { + String merchantAddress = merchantAddressField.getValueString(); + System.out.printf("Merchant Address: %s, confidence: %.2f%n", + merchantAddress, merchantAddressField.getConfidence()); + } + } + + DocumentField transactionDateField = receiptFields.get("TransactionDate"); + if (transactionDateField != null) { + if (DocumentFieldType.DATE == transactionDateField.getType()) { + LocalDate transactionDate = transactionDateField.getValueDate(); + System.out.printf("Transaction Date: %s, confidence: %.2f%n", + transactionDate, transactionDateField.getConfidence()); + } + } + } + // END: com.azure.ai.documentintelligence.readme.analyzeReceipt + + } + + public void buildModel() throws IOException { + // BEGIN: com.azure.ai.documentintelligence.readme.buildModel + // Build custom document analysis model + String blobContainerUrl = "{SAS_URL_of_your_container_in_blob_storage}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + SyncPoller buildOperationPoller = + administrationClient.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))); + + DocumentModelDetails documentModelDetails = buildOperationPoller.getFinalResult(); + + // Model Info + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model created on: %s%n%n", documentModelDetails.getCreatedDateTime()); + + System.out.println("Document Fields:"); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + // END: com.azure.ai.documentintelligence.readme.buildModel + + } + + public void analyzeCustomModel() { + // BEGIN: com.azure.ai.documentintelligence.readme.analyzeCustomModel + String documentUrl = "{document-url}"; + String modelId = "{custom-built-model-ID}"; + SyncPoller analyzeDocumentPoller = documentAnalysisClient.beginAnalyzeDocument(modelId, + "1", + "en-US", + StringIndexType.TEXT_ELEMENTS, + Arrays.asList(DocumentAnalysisFeature.LANGUAGES), + null, + ContentFormat.TEXT, + new AnalyzeDocumentRequest().setUrlSource(documentUrl)); + + AnalyzeResult analyzeResult = analyzeDocumentPoller.getFinalResult(); + + for (int i = 0; i < analyzeResult.getDocuments().size(); i++) { + final Document analyzedDocument = analyzeResult.getDocuments().get(i); + System.out.printf("----------- Analyzing custom document %d -----------%n", i); + System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n", + analyzedDocument.getDocType(), analyzedDocument.getConfidence()); + } + + analyzeResult.getPages().forEach(documentPage -> { + System.out.printf("Page has width: %.2f and height: %.2f, measured with unit: %s%n", + documentPage.getWidth(), + documentPage.getHeight(), + documentPage.getUnit()); + + // lines + documentPage.getLines().forEach(documentLine -> + System.out.printf("Line '%s' is within a bounding polygon %s.%n", + documentLine.getContent(), + documentLine.getPolygon())); + + // words + documentPage.getWords().forEach(documentWord -> + System.out.printf("Word '%s' has a confidence score of %.2f.%n", + documentWord.getContent(), + documentWord.getConfidence())); + }); + + // tables + List tables = analyzeResult.getTables(); + for (int i = 0; i < tables.size(); i++) { + DocumentTable documentTable = tables.get(i); + System.out.printf("Table %d has %d rows and %d columns.%n", i, documentTable.getRowCount(), + documentTable.getColumnCount()); + documentTable.getCells().forEach(documentTableCell -> { + System.out.printf("Cell '%s', has row index %d and column index %d.%n", + documentTableCell.getContent(), + documentTableCell.getRowIndex(), documentTableCell.getColumnIndex()); + }); + System.out.println(); + } + // END: com.azure.ai.documentintelligence.readme.analyzeCustomModel + + } + + public void manageModels() { + // BEGIN: com.azure.ai.documentintelligence.readme.manageModels + + ResourceDetails resourceDetails = administrationClient.getResourceInfo(); + System.out.printf("The resource has %s models, and we can have at most %s models.%n", + resourceDetails.getCustomDocumentModels().getCount(), resourceDetails.getCustomDocumentModels().getLimit()); + + // Next, we get a paged list of all of our models + PagedIterable customDocumentModels = administrationClient.listModels(); + System.out.println("We have following models in the account:"); + customDocumentModels.forEach(documentModelInfo -> { + System.out.println(); + // get custom document analysis model info + DocumentModelDetails documentModel = administrationClient.getModel(documentModelInfo.getModelId()); + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model created on: %s%n", documentModel.getCreatedDateTime()); + if (documentModel.getDocTypes() != null) { + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s, ", field); + System.out.printf("Field type: %s, ", documentFieldSchema.getType()); + if (documentTypeDetails.getFieldConfidence() != null) { + System.out.printf("Field confidence: %.2f%n", + documentTypeDetails.getFieldConfidence().get(field)); + } + }); + }); + } + }); + // END: com.azure.ai.documentintelligence.readme.manageModels + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifier.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifier.java new file mode 100644 index 000000000000..1d6ad5335462 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifier.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.ClassifierDocumentTypeDetails; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.SyncPoller; + +import java.util.HashMap; + +/** + * Sample to build a classifier model with training data. + * For instructions on setting up documents for training in an Azure Storage Blob Container, see + * here. + *

+ * For this sample, you can use the training documents found in + * here + * to create your own custom document analysis models. + * For instructions to create a label file for your training forms, please see: + * here. + *

+ * Further, see AnalyzeDocumentWithClassifier.java to analyze a document with your custom classifier built model. + */ +public class BuildDocumentClassifier { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + // Build custom classifier document model + String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}"; + String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}"; + + HashMap docTypes = new HashMap<>(); + docTypes.put("1040-A", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040A) + )); + docTypes.put("1040-D", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040D) + )); + + SyncPoller buildOperationPoller + = client.beginBuildClassifier(new BuildDocumentClassifierRequest("classifierId", docTypes)); + DocumentClassifierDetails documentClassifierDetails = buildOperationPoller.getFinalResult(); + + System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier description: %s%n", documentClassifierDetails.getDescription()); + System.out.printf("Classifier created on: %s%n", documentClassifierDetails.getCreatedDateTime()); + System.out.printf("Classifier expires on: %s%n", documentClassifierDetails.getExpirationDateTime()); + documentClassifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", documentTypeDetails + .getAzureBlobSource().getContainerUrl()); + } + }); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifierAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifierAsync.java new file mode 100644 index 000000000000..36b4179b46e8 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentClassifierAsync.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.ClassifierDocumentTypeDetails; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.SyncPoller; + +import java.util.HashMap; + +/** + * Sample to build a classifier model with training data. + * For instructions on setting up documents for training in an Azure Storage Blob Container, see + * here. + *

+ * For this sample, you can use the training documents found in + * here + * to create your own custom document analysis models. + * For instructions to create a label file for your training forms, please see: + * here. + *

+ * Further, see AnalyzeDocumentWithClassifier.java to analyze a document with your custom classifer built model. + */ +public class BuildDocumentClassifierAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}"; + String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}"; + HashMap docTypes = new HashMap<>(); + docTypes.put("1040-D", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040D) + )); + docTypes.put("1040-A", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040A) + )); + + SyncPoller buildOperationPoller = + client.beginBuildClassifier(new BuildDocumentClassifierRequest("classifierID", docTypes)); + + DocumentClassifierDetails documentClassifierDetails = buildOperationPoller.getFinalResult(); + + // Classifier model Info + System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier description: %s%n", documentClassifierDetails.getDescription()); + System.out.printf("Classifier created on: %s%n", documentClassifierDetails.getCreatedDateTime()); + System.out.printf("Classifier expires on: %s%n", documentClassifierDetails.getExpirationDateTime()); + documentClassifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + }); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModel.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModel.java new file mode 100644 index 000000000000..f0121d017caa --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModel.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.SyncPoller; + +/** + * Sample to build a model with training data. + * For instructions on setting up documents for training in an Azure Storage Blob Container, see + * here. + *

+ * For this sample, you can use the training documents found in + * here + * to create your own custom document analysis models. + * For instructions to create a label file for your training forms, please see: + * here. + *

+ * Further, see AnalyzeCustomDocumentFromUrl.java to analyze a custom document with your built model. + */ +public class BuildDocumentModel { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + // Build custom document analysis model + String blobContainerUrl = "{SAS_URL_of_your_container_in_blob_storage}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + SyncPoller buildOperationPoller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))); + + DocumentModelDetails documentModelDetails = buildOperationPoller.getFinalResult(); + + // Model Info + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model created on: %s%n%n", documentModelDetails.getCreatedDateTime()); + + System.out.println("Document Fields:"); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModelAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModelAsync.java new file mode 100644 index 000000000000..03e1c523ef4d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/BuildDocumentModelAsync.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.PollerFlux; +import reactor.core.publisher.Mono; + +import java.util.concurrent.TimeUnit; + +/** + * Async sample to build a model with training data. + * For instructions on setting up documents for training in an Azure Storage Blob Container, see + * here. + *

+ * For this sample, you can use the training documents found in + * here + * to create your own custom document analysis models. + * For instructions to create a label file for your training forms, please see: + * here. + *

+ * Further, see AnalyzeCustomDocumentAsync.java to analyze a custom document with your built model. + */ +public class BuildDocumentModelAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String blobContainerUrl = "{SAS_URL_of_your_container_in_blob_storage}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + String prefix = "{blob_name_prefix}"; + PollerFlux buildModelPoller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))); + + Mono customFormModelResult = buildModelPoller + .last() + .flatMap(pollResponse -> { + if (pollResponse.getStatus().isComplete()) { + // building model completed successfully, retrieving final result. + return pollResponse.getFinalResult(); + } else { + return Mono.error(new RuntimeException("Polling completed unsuccessfully with status:" + + pollResponse.getStatus())); + } + }); + + customFormModelResult.subscribe(documentModel -> { + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model created on: %s%n%n", documentModel.getCreatedDateTime()); + + System.out.println("Document Fields:"); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModel.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModel.java new file mode 100644 index 000000000000..1984a309b608 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModel.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ComponentDocumentModelDetails; +import com.azure.ai.documentintelligence.models.ComposeDocumentModelRequest; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.SyncPoller; + +import java.time.Duration; +import java.util.Arrays; + +/** + * Sample for creating a custom document analysis composed model. + *

+ * This is useful when you have build different analysis models and want to aggregate a group of + * them into a single model that you (or a user) could use to analyze a custom document. When doing + * so, you can let the service decide which model more accurately represents the document to + * analyze, instead of manually trying each built model against the form and selecting + * the most accurate one. + *

+ */ +public class ComposeDocumentModel { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + // Build custom document analysis model + String model1TrainingFiles = "{SAS_URL_of_your_container_in_blob_storage_for_model_1}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + SyncPoller model1Poller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(model1TrainingFiles))); + + // Build custom document analysis model + String model2TrainingFiles = "{SAS_URL_of_your_container_in_blob_storage_for_model_2}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + SyncPoller model2Poller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(model2TrainingFiles))); + + String labeledModelId1 = model1Poller.getFinalResult().getModelId(); + String labeledModelId2 = model2Poller.getFinalResult().getModelId(); + String composedModelId = "my-composed-model"; + final DocumentModelDetails documentModelDetails = + client.beginComposeModel( + new ComposeDocumentModelRequest(composedModelId, Arrays.asList(new ComponentDocumentModelDetails(labeledModelId1), new ComponentDocumentModelDetails(labeledModelId2))) + .setDescription("my composed model description")) + .setPollInterval(Duration.ofSeconds(5)) + .getFinalResult(); + + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Composed model created on: %s%n", documentModelDetails.getCreatedDateTime()); + + System.out.println("Document Fields:"); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + } +} + diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModelAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModelAsync.java new file mode 100644 index 000000000000..cfcc8a4a13ed --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ComposeDocumentModelAsync.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ComponentDocumentModelDetails; +import com.azure.ai.documentintelligence.models.ComposeDocumentModelRequest; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.PollerFlux; + +import java.time.Duration; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +/** + * Sample for creating a custom document analysis composed model. + *

+ * This is useful when you have build different analysis models and want to aggregate a group of + * them into a single model that you (or a user) could use to analyze a custom document. When doing + * so, you can let the service decide which model more accurately represents the document to + * analyze, instead of manually trying each built model against the form and selecting + * the most accurate one. + *

+ */ +public class ComposeDocumentModelAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + // Build custom document analysis model + String model1TrainingFiles = "{SAS_URL_of_your_container_in_blob_storage_for_model_1}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + PollerFlux model1Poller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(model1TrainingFiles))); + + // Build custom document analysis model + String model2TrainingFiles = "{SAS_URL_of_your_container_in_blob_storage_for_model_2}"; + // The shared access signature (SAS) Url of your Azure Blob Storage container with your forms. + PollerFlux model2Poller = + client.beginBuildDocumentModel(new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(model2TrainingFiles))); + + String labeledModelId1 = model1Poller.getSyncPoller().getFinalResult().getModelId(); + String labeledModelId2 = model2Poller.getSyncPoller().getFinalResult().getModelId(); + + client.beginComposeModel( + new ComposeDocumentModelRequest("composedModelId", Arrays.asList(new ComponentDocumentModelDetails(labeledModelId1), new ComponentDocumentModelDetails(labeledModelId2))) + .setDescription("my composed model description")) + .setPollInterval(Duration.ofSeconds(5)) + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(documentModel -> { + + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Composed model created on: %s%n", documentModel.getCreatedDateTime()); + + System.out.println("Document Fields:"); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.MINUTES.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} + diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModel.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModel.java new file mode 100644 index 000000000000..5e875d80b617 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModel.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.ai.documentintelligence.models.CopyAuthorization; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.util.polling.SyncPoller; + +/** + * Sample for copying a custom document analysis model from a source Form Recognizer resource to a target Form Recognizer resource. + */ +public class CopyDocumentModel { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a source client which has the model that we want to copy. + DocumentModelAdministrationClient sourceClient = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + // Instantiate the target client where we want to copy the custom document analysis model to. + DocumentModelAdministrationClient targetClient = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + String copiedModelId = "my-copied-model"; + + // Get authorization to copy the model to target resource + CopyAuthorization modelDocumentModelCopyAuthorization + = targetClient.authorizeModelCopy(new AuthorizeCopyRequest(copiedModelId)); + + // The ID of the model that needs to be copied to the target resource + String copyModelId = "copy-model-ID"; + // Start copy operation from the source client + SyncPoller copyPoller = sourceClient.beginCopyModelTo(copyModelId, + modelDocumentModelCopyAuthorization); + copyPoller.waitForCompletion(); + + // Get the copied model + DocumentModelDetails copiedModel = targetClient.getModel(modelDocumentModelCopyAuthorization.getTargetModelId()); + + System.out.printf("Copied model has model ID: %s, was created on: %s.%n", + copiedModel.getModelId(), + copiedModel.getCreatedDateTime()); + } +} + diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModelAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModelAsync.java new file mode 100644 index 000000000000..00fdc783a83f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/CopyDocumentModelAsync.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.util.polling.AsyncPollResponse; + +import java.util.concurrent.TimeUnit; + +/** + * Async sample for copying a custom document analysis model from a source Form Recognizer resource to a target Form Recognizer resource. + */ +public class CopyDocumentModelAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a source client which has the model that we want to copy. + DocumentModelAdministrationAsyncClient sourceClient = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + // Instantiate the target client where we want to copy the custom document analysis model to. + DocumentModelAdministrationAsyncClient targetClient = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + String copiedModelId = "my-copied-model"; + // The ID of the model that needs to be copied to the target resource + String copyModelId = "copy-model-ID"; + + // Get authorization to copy the model to target resource + targetClient.authorizeModelCopy(new AuthorizeCopyRequest(copyModelId)) + // Start copy operation from the source client + // The ID of the model that needs to be copied to the target resource + .subscribe(copyAuthorization -> sourceClient.beginCopyModelTo(copyModelId, copyAuthorization) + .filter(pollResponse -> pollResponse.getStatus().isComplete()) + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(documentModelInfo -> { + System.out.printf("Original model has model ID: %s and was created on: %s.%n", + documentModelInfo.getModelId(), + documentModelInfo.getCreatedDateTime()); + + // Get the copied model from the target resource + targetClient.getModel(copyAuthorization.getTargetModelId()).subscribe(documentModel -> + System.out.printf("Copied model has model ID: %s was created on: %s.%n", + documentModel.getModelId(), + documentModel.getCreatedDateTime())); + })); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.SECONDS.sleep(30); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminAsyncClientJavaDocCodeSnippets.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminAsyncClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..b108bd4408bb --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminAsyncClientJavaDocCodeSnippets.java @@ -0,0 +1,498 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ClassifierDocumentTypeDetails; +import com.azure.ai.documentintelligence.models.ComponentDocumentModelDetails; +import com.azure.ai.documentintelligence.models.ComposeDocumentModelRequest; +import com.azure.ai.documentintelligence.models.CopyAuthorization; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentModelBuildOperationDetails; +import com.azure.ai.documentintelligence.models.OperationStatus; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.nimbusds.oauth2.sdk.Request; + +import java.util.Arrays; +import java.util.HashMap; + +/** + * Code snippet for {@link DocumentModelAdministrationAsyncClient} + */ +public class DocumentModelAdminAsyncClientJavaDocCodeSnippets { + private final DocumentModelAdministrationAsyncClient documentModelAdministrationAsyncClient = + new DocumentModelAdministrationClientBuilder().buildAsyncClient(); + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient} initialization + */ + public void documentModelAdministrationAsyncClientInitialization() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.initialization + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .endpoint("{endpoint}") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildAsyncClient(); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.initialization + } + + public void documentModelAdministrationAsyncClientKeyCred() { + // BEGIN: readme-sample-createDocumentModelAdministrationAsyncClient + DocumentModelAdministrationAsyncClient documentModelAdministrationAsyncClient = + new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildAsyncClient(); + // END: readme-sample-createDocumentModelAdministrationAsyncClient + } + + /** + * Code snippet for creating a {@link DocumentModelAdministrationAsyncClient} with pipeline + */ + public void createDocumentModelAdministrationAsyncClientWithPipeline() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.pipeline.instantiation + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(/* add policies */) + .build(); + + DocumentModelAdministrationAsyncClient documentModelAdministrationAsyncClient = + new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .pipeline(pipeline) + .buildAsyncClient(); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.pipeline.instantiation + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#beginBuildDocumentModel(BuildDocumentModelRequest)} + */ + public void beginBuildModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginBuildDocumentModel#BuildDocumentModelRequest + String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}"; + documentModelAdministrationAsyncClient.beginBuildDocumentModel( + new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))) + // if polling operation completed, retrieve the final result. + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(documentModel -> { + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Created on: %s%n", documentModel.getCreatedDateTime()); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginBuildDocumentModel#BuildDocumentModelRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#beginBuildClassifier(BinaryData, RequestOptions)} + */ + public void beginBuildClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginBuildClassifier#BuildDocumentClassifierRequest + String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}"; + String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}"; + HashMap documentTypesDetailsMap = new HashMap<>(); + documentTypesDetailsMap.put("1040-D", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040D) + )); + documentTypesDetailsMap.put("1040-A", new ClassifierDocumentTypeDetails().setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040A) + )); + + documentModelAdministrationAsyncClient.beginBuildClassifier(new BuildDocumentClassifierRequest("classifierID", documentTypesDetailsMap)) + // if polling operation completed, retrieve the final result. + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(classifierDetails -> { + System.out.printf("Classifier ID: %s%n", classifierDetails.getClassifierId()); + System.out.printf("Classifier description: %s%n", classifierDetails.getDescription()); + System.out.printf("Classifier created on: %s%n", classifierDetails.getCreatedDateTime()); + System.out.printf("Classifier expires on: %s%n", classifierDetails.getExpirationDateTime()); + classifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginBuildClassifier#BuildDocumentClassifierRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#deleteModel(String)} + */ + public void deleteModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteModel#string + String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.deleteModel(modelId) + .subscribe(ignored -> System.out.printf("Model ID: %s is deleted%n", modelId)); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteModel#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#deleteModelWithResponse(String, RequestOptions)} + */ + public void deleteModelWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteModelWithResponse#string-RequestOptions + String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.deleteModelWithResponse(modelId, null) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + System.out.printf("Model ID: %s is deleted.%n", modelId); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteModelWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#authorizeModelCopy(AuthorizeCopyRequest)} + */ + public void authorizeModelCopy() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.authorizeModelCopy + String modelId = "my-copied-model"; + documentModelAdministrationAsyncClient.authorizeModelCopy(new AuthorizeCopyRequest(modelId)) + .subscribe(copyAuthorization -> + System.out.printf("Copy Authorization for model id: %s, access token: %s, expiration time: %s, " + + "target resource ID; %s, target resource region: %s%n", + copyAuthorization.getTargetModelId(), + copyAuthorization.getAccessToken(), + copyAuthorization.getExpirationDateTime(), + copyAuthorization.getTargetResourceId(), + copyAuthorization.getTargetResourceRegion() + )); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.authorizeModelCopy + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#authorizeModelCopyWithResponse(BinaryData, RequestOptions)} + */ + public void authorizeModelCopyWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.authorizeModelCopyWithResponse#Options + /* + String modelId = "my-copied-model"; + Map attrs = new HashMap(); + attrs.put("createdBy", "sample"); + + documentModelAdministrationAsyncClient.authorizeModelCopyWithResponse( + new AuthorizeCopyRequest(modelId) + .setDescription("model desc") + .setTags(attrs), null) + .subscribe(copyAuthorization -> + System.out.printf("Copy Authorization response status: %s, for model id: %s, access token: %s, " + + "expiration time: %s, target resource ID; %s, target resource region: %s%n", + copyAuthorization.getStatusCode(), + copyAuthorization.getValue().getTargetModelId(), + copyAuthorization.getValue().getAccessToken(), + copyAuthorization.getValue().getExpirationDateTime(), + copyAuthorization.getValue().getTargetResourceId(), + copyAuthorization.getValue().getTargetResourceRegion() + )); + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.authorizeModelCopyWithResponse#Options + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getResourceInfo()} + */ + public void getResourceInfo() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getResourceInfo + documentModelAdministrationAsyncClient.getResourceInfo() + .subscribe(resourceInfo -> { + System.out.printf("Max number of models that can be build for this account: %d%n", + resourceInfo.getCustomDocumentModels().getLimit()); + System.out.printf("Current count of built document analysis models: %d%n", + resourceInfo.getCustomDocumentModels().getCount()); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getResourceInfo + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getResourceInfoWithResponse(RequestOptions)} + */ + public void getResourceInfoWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getResourceInfoWithResponse + /*documentModelAdministrationAsyncClient.getResourceInfoWithResponse(new RequestOptions()) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + ResourceDetails resourceDetails = response.getValue(); + System.out.printf("Max number of models that can be build for this account: %d%n", + resourceDetails.getCustomDocumentModelLimit()); + System.out.printf("Current count of built document analysis models: %d%n", + resourceDetails.getCustomDocumentModelCount()); + }); + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getResourceInfoWithResponse + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#beginComposeModel(BinaryData, RequestOptions)} + */ + public void beginCreateComposedModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginComposeDocumentModel#ComposeDocumentModelRequest + String modelId1 = "{model_Id_1}"; + String modelId2 = "{model_Id_2}"; + documentModelAdministrationAsyncClient.beginComposeModel( + new ComposeDocumentModelRequest("composedModelID", Arrays.asList(new ComponentDocumentModelDetails(modelId1), new ComponentDocumentModelDetails(modelId2)))) + // if polling operation completed, retrieve the final result. + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(documentModel -> { + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Created on: %s%n", documentModel.getCreatedDateTime()); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginComposeDocumentModel#ComposeDocumentModelRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#beginCopyModelTo(String, CopyAuthorization)} + */ + public void beginCopy() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginCopyDocumentModelTo#AuthorizeCopyRequest + String copyModelId = "copy-model"; + // Get authorization to copy the model to target resource + documentModelAdministrationAsyncClient.authorizeModelCopy(new AuthorizeCopyRequest(copyModelId)) + // Start copy operation from the source client + // The ID of the model that needs to be copied to the target resource + .subscribe(copyAuthorization -> documentModelAdministrationAsyncClient.beginCopyModelTo(copyModelId, + copyAuthorization) + .filter(pollResponse -> pollResponse.getStatus().isComplete()) + .flatMap(AsyncPollResponse::getFinalResult) + .subscribe(documentModel -> + System.out.printf("Copied model has model ID: %s, was created on: %s.%n,", + documentModel.getModelId(), + documentModel.getCreatedDateTime()))); + + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.beginCopyDocumentModelTo#AuthorizeCopyRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#listModels()} + */ + public void listModels() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listModels + documentModelAdministrationAsyncClient.listModels() + .subscribe(documentModelInfo -> + System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n", + documentModelInfo.getModelId(), + documentModelInfo.getDescription(), + documentModelInfo.getCreatedDateTime())); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listModels + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getModel(String)} + */ + public void getModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getModel#string + String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.getModel(modelId).subscribe(documentModel -> { + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model Created on: %s%n", documentModel.getCreatedDateTime()); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getModel#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getModelWithResponse(String, RequestOptions)} + */ + public void getModelWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getModelWithResponse#string-RequestOptions + /*String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.getModelWithResponse(modelId, null) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + DocumentModelDetails documentModelDetails = response.getValue(); + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedDateTime()); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getModelWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getModel(String)} + */ + public void getOperation() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getOperation#string + String operationId = "{operation_Id}"; + documentModelAdministrationAsyncClient.getOperation(operationId).subscribe(operationDetails -> { + System.out.printf("Operation ID: %s%n", operationDetails.getOperationId()); + System.out.printf("Operation Status: %s%n", operationDetails.getStatus()); + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId()); + if (OperationStatus.FAILED.equals(operationDetails.getStatus())) { + System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage()); + } + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getOperation#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getOperationWithResponse(String, RequestOptions)} + */ + public void getOperationWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getOperationWithResponse#string-RequestOptions + /*String operationId = "{operation_Id}"; + documentModelAdministrationAsyncClient.getOperationWithResponse(operationId, null) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + OperationDetails operationDetails = response.getValue(); + System.out.printf("Operation ID: %s%n", operationDetails.getOperationId()); + System.out.printf("Operation Status: %s%n", operationDetails.getStatus()); + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId()); + if (OperationStatus.FAILED.equals(operationDetails.getStatus())) { + System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage()); + } + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getOperationWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#listOperations()} + */ + public void listOperations() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listOperations + documentModelAdministrationAsyncClient.listOperations() + .subscribe(modelOperationSummary -> { + System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId()); + System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus()); + System.out.printf("Operation Created on: %s%n", modelOperationSummary.getCreatedDateTime()); + System.out.printf("Operation Percent completed: %d%n", modelOperationSummary.getPercentCompleted()); + System.out.printf("Operation Last updated on: %s%n", modelOperationSummary.getLastUpdatedDateTime()); + System.out.printf("Operation resource location: %s%n", modelOperationSummary.getResourceLocation()); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listOperations + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#deleteClassifier(String)} + */ + public void deleteClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteDocumentClassifier#string + String classifierId = "{classifierId}"; + documentModelAdministrationAsyncClient.deleteClassifier(classifierId) + .subscribe(ignored -> System.out.printf("Classifier ID: %s is deleted%n", classifierId)); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteDocumentClassifier#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#deleteClassifierWithResponse(String, RequestOptions)} + */ + public void deleteClassifierWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteDocumentClassifierWithResponse#string-RequestOptions + String classifierId = "{classifierId}"; + documentModelAdministrationAsyncClient.deleteClassifierWithResponse(classifierId, new RequestOptions()) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + System.out.printf("Classifier ID: %s is deleted.%n", classifierId); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.deleteDocumentClassifierWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#listClassifiers()} + */ + public void listClassifiers() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listDocumentClassifiers + documentModelAdministrationAsyncClient.listClassifiers() + .subscribe(documentModelInfo -> + System.out.printf("Classifier ID: %s, Classifier description: %s, Created on: %s.%n", + documentModelInfo.getClassifierId(), + documentModelInfo.getDescription(), + documentModelInfo.getCreatedDateTime())); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.listDocumentClassifiers + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getClassifier(String)} + */ + public void getDocumentClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getDocumentClassifier#string + String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.getClassifier(modelId).subscribe(documentClassifier -> { + System.out.printf("Classifier ID: %s%n", documentClassifier.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifier.getDescription()); + System.out.printf("Classifier Created on: %s%n", documentClassifier.getCreatedDateTime()); + documentClassifier.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + if (documentTypeDetails.getAzureBlobFileListSource() != null) { + System.out.printf("Blob File List Source container Url: %s", + (documentTypeDetails + .getAzureBlobFileListSource()).getContainerUrl()); + } + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getDocumentClassifier#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationAsyncClient#getClassifierWithResponse(String, RequestOptions)} + */ + public void getClassifierWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getDocumentClassifierWithResponse#string-RequestOptions + /*String modelId = "{model_id}"; + documentModelAdministrationAsyncClient.getClassifierWithResponse(modelId, new RequestOptions()) + .subscribe(response -> { + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + DocumentClassifierDetails documentClassifierDetails = response.getValue(); + System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifierDetails.getDescription()); + System.out.printf("Classifier Created on: %s%n", documentClassifierDetails.getCreatedDateTime()); + documentClassifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getContentSource() instanceof AzureBlobContentSource) { + System.out.printf("Blob Source container Url: %s", ((AzureBlobContentSource) documentTypeDetails + .getContentSource()).getContainerUrl()); + } + if (documentTypeDetails.getContentSource() instanceof BlobFileListContentSource) { + System.out.printf("Blob File List Source container Url: %s", + ((BlobFileListContentSource) documentTypeDetails + .getContentSource()).getContainerUrl()); + } + }); + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminAsyncClient.getDocumentClassifierWithResponse#string-RequestOptions + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminClientJavaDocCodeSnippets.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminClientJavaDocCodeSnippets.java new file mode 100644 index 000000000000..f23a41489bbd --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/DocumentModelAdminClientJavaDocCodeSnippets.java @@ -0,0 +1,516 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AuthorizeCopyRequest; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.BuildDocumentClassifierRequest; +import com.azure.ai.documentintelligence.models.BuildDocumentModelRequest; +import com.azure.ai.documentintelligence.models.ClassifierDocumentTypeDetails; +import com.azure.ai.documentintelligence.models.CopyAuthorization; +import com.azure.ai.documentintelligence.models.DocumentBuildMode; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.ai.documentintelligence.models.DocumentModelBuildOperationDetails; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.OperationDetails; +import com.azure.ai.documentintelligence.models.OperationStatus; +import com.azure.ai.documentintelligence.models.ResourceDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.identity.DefaultAzureCredentialBuilder; + +import java.util.HashMap; + +/** + * Code snippet for {@link DocumentModelAdministrationClient} + */ +public class DocumentModelAdminClientJavaDocCodeSnippets { + private final DocumentModelAdministrationClient documentModelAdministrationClient = + new DocumentModelAdministrationClientBuilder().buildClient(); + + /** + * Code snippet for {@link DocumentModelAdministrationClient} initialization + */ + public void documentModelAdministrationClientInInitialization() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.initialization + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .endpoint("{endpoint}") + .credential(new DefaultAzureCredentialBuilder().build()) + .buildClient(); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.initialization + } + + /** + * Code snippet for getting sync DocumentModelAdministration client using the AzureKeyCredential authentication. + */ + public void documentModelAdministrationClientKeyCred() { + // BEGIN: readme-sample-createDocumentModelAdministrationClient + DocumentModelAdministrationClient client = + new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("{endpoint}") + .buildClient(); + // END: readme-sample-createDocumentModelAdministrationClient + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#beginBuildDocumentModel(BinaryData, RequestOptions)} + */ + public void beginBuildModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginBuildDocumentModel#BuildDocumentModelRequest + String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}"; + DocumentModelDetails documentModelDetails + = documentModelAdministrationClient.beginBuildDocumentModel( + new BuildDocumentModelRequest("modelID", DocumentBuildMode.TEMPLATE) + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl))) + .getFinalResult(); + + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedDateTime()); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginBuildDocumentModel#BuildDocumentModelRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getResourceInfo()} + */ + public void getResourceInfo() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getResourceInfo + ResourceDetails resourceDetails = documentModelAdministrationClient.getResourceInfo(); + System.out.printf("Max number of models that can be build for this account: %d%n", + resourceDetails.getCustomDocumentModels().getLimit()); + System.out.printf("Current count of built document analysis models: %d%n", + resourceDetails.getCustomDocumentModels().getCount()); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getResourceInfo + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getResourceInfoWithResponse(RequestOptions)} + */ + public void getResourceInfoWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getResourceInfoWithResponse#RequestOptions + /*Response response = + documentModelAdministrationClient.getResourceInfoWithResponse(new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + ResourceDetails resourceDetails = response.getValue(); + System.out.printf("Max number of models that can be build for this account: %d%n", + resourceDetails.getCustomDocumentModels().getLimit()); + System.out.printf("Current count of built document analysis models: %d%n", + resourceDetails.getCustomDocumentModels().getCount()); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getResourceInfoWithResponse#RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#deleteModel(String)} + */ + public void deleteModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentModel#string + String modelId = "{custom-model-id}"; + documentModelAdministrationClient.deleteModel(modelId); + System.out.printf("Model ID: %s is deleted.%n", modelId); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentModel#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#deleteModelWithResponse(String, RequestOptions)} + */ + public void deleteModelWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentModelWithResponse#string-RequestOptions + String modelId = "{custom-model-id}"; + Response response + = documentModelAdministrationClient.deleteModelWithResponse(modelId, new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + System.out.printf("Model ID: %s is deleted.%n", modelId); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentModelWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#authorizeModelCopy(AuthorizeCopyRequest)} + */ + public void getCopyAuthorization() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getCopyAuthorization#AuthorizeCopyRequest + CopyAuthorization documentModelCopyAuthorization + = documentModelAdministrationClient.authorizeModelCopy(new AuthorizeCopyRequest("copyModelID")); + System.out.printf("Copy Authorization for model id: %s, access token: %s, expiration time: %s, " + + "target resource ID; %s, target resource region: %s%n", + documentModelCopyAuthorization.getTargetModelId(), + documentModelCopyAuthorization.getAccessToken(), + documentModelCopyAuthorization.getExpirationDateTime(), + documentModelCopyAuthorization.getTargetResourceId(), + documentModelCopyAuthorization.getTargetResourceRegion() + ); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getCopyAuthorization#AuthorizeCopyRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#authorizeModelCopyWithResponse(BinaryData, RequestOptions)} + */ + public void getCopyAuthorizationWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getCopyAuthorizationWithResponse#AuthorizeCopyRequest-RequestOptions + /*String modelId = "my-copied-model"; + Map attrs = new HashMap(); + attrs.put("createdBy", "sample"); + + Response copyAuthorizationResponse = + documentModelAdministrationClient.authorizeModelCopyWithResponse( + new AuthorizeCopyRequest(modelId) + .setDescription("model-desc") + .setTags(attrs), new RequestOptions()); + + System.out.printf("Copy Authorization operation returned with status: %s", + copyAuthorizationResponse.getStatusCode()); + DocumentModelCopyAuthorization documentModelCopyAuthorization = copyAuthorizationResponse.getValue(); + System.out.printf("Copy Authorization for model id: %s, access token: %s, " + + "expiration time: %s, target resource ID; %s, target resource region: %s%n", + documentModelCopyAuthorization.getTargetModelId(), + documentModelCopyAuthorization.getAccessToken(), + documentModelCopyAuthorization.getExpirationDateTime(), + documentModelCopyAuthorization.getTargetResourceId(), + documentModelCopyAuthorization.getTargetResourceRegion() + ); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getCopyAuthorizationWithResponse#AuthorizeCopyRequest-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#beginComposeModel(BinaryData, RequestOptions)} + */ + public void beginCreateComposedModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginComposeDocumentModel#list-RequestOptions + /*String modelId1 = "{custom-model-id_1}"; + String modelId2 = "{custom-model-id_2}"; + final DocumentModelDetails documentModelDetails + = documentModelAdministrationClient.beginComposeModel(new ComposeDocumentModelRequest("composedModelID", Arrays.asList(new ComponentDocumentModelDetails(modelId1), new ComponentDocumentModelDetails(modelId2))), new RequestOptions()) + .getFinalResult(); + + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedDateTime()); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginComposeDocumentModel#list-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#beginCopyModelTo(String, CopyAuthorization)} + */ + public void beginCopy() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginCopyDocumentModelTo#string-copyAuthorization + String copyModelId = "copy-model"; + // Get authorization to copy the model to target resource + CopyAuthorization documentModelCopyAuthorization + = documentModelAdministrationClient.authorizeModelCopy(new AuthorizeCopyRequest(copyModelId)); + // Start copy operation from the source client + DocumentModelDetails documentModelDetails + = documentModelAdministrationClient.beginCopyModelTo(copyModelId, documentModelCopyAuthorization) + .getFinalResult(); + System.out.printf("Copied model has model ID: %s, was created on: %s.%n,", + documentModelDetails.getModelId(), + documentModelDetails.getCreatedDateTime()); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginCopyDocumentModelTo#string-copyAuthorization + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#listModels()} + */ + public void listModels() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.listModels + documentModelAdministrationClient.listModels() + .forEach(documentModel -> + System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n", + documentModel.getModelId(), + documentModel.getDescription(), + documentModel.getCreatedDateTime()) + ); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.listModels + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#listModels(RequestOptions)} + */ + public void listModelsWithContext() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.listModels#RequestOptions + /*documentModelAdministrationClient.listModels(new RequestOptions()) + .forEach(documentModel -> + System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n", + documentModel.getModelId(), + documentModel.getDescription(), + documentModel.getCreatedDateTime()) + ); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.listModels#RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getModel(String)} + */ + public void getModel() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getModel#string + String modelId = "{custom-model-id}"; + DocumentModelDetails documentModelDetails = documentModelAdministrationClient.getModel(modelId); + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedDateTime()); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getModel#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getModelWithResponse(String, RequestOptions)} + */ + public void getModelWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getModelWithResponse#string-RequestOptions + String modelId = "{custom-model-id}"; + /*Response response + = documentModelAdministrationClient.getModelWithResponse(modelId, new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + DocumentModelDetails documentModelDetails = response.getValue(); + System.out.printf("Model ID: %s%n", documentModelDetails.getModelId()); + System.out.printf("Model Description: %s%n", documentModelDetails.getDescription()); + System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedDateTime()); + documentModelDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s", field); + System.out.printf("Field type: %s", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getModelWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getOperation(String)} + */ + public void getOperation() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getOperation#string + String operationId = "{operation-id}"; + OperationDetails operationDetails + = documentModelAdministrationClient.getOperation(operationId); + System.out.printf("Operation ID: %s%n", operationDetails.getOperationId()); + System.out.printf("Operation Status: %s%n", operationDetails.getStatus()); + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId()); + if (OperationStatus.FAILED.equals(operationDetails.getStatus())) { + System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage()); + } + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getOperation#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getOperationWithResponse(String, RequestOptions)} + */ + public void getOperationWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getOperationWithResponse#string-RequestOptions + /*String operationId = "{operation-id}"; + Response response = + documentModelAdministrationClient.getOperationWithResponse(operationId, new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + OperationDetails operationDetails = response.getValue(); + System.out.printf("Operation ID: %s%n", operationDetails.getOperationId()); + System.out.printf("Operation Status: %s%n", operationDetails.getStatus()); + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId()); + if (OperationStatus.FAILED.equals(operationDetails.getStatus())) { + System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage()); + } + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getOperationWithResponse#string-RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#listOperations()} + */ + public void listOperations() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.listOperations + PagedIterable + modelOperationInfo = documentModelAdministrationClient.listOperations(); + modelOperationInfo.forEach(modelOperationSummary -> { + System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId()); + System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus()); + System.out.printf("Operation Created on: %s%n", modelOperationSummary.getCreatedDateTime()); + System.out.printf("Operation Percent completed: %d%n", modelOperationSummary.getPercentCompleted()); + System.out.printf("Operation Last updated on: %s%n", modelOperationSummary.getLastUpdatedDateTime()); + System.out.printf("Operation resource location: %s%n", modelOperationSummary.getResourceLocation()); + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.listOperations + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#listOperations(RequestOptions)} + */ + public void listOperationsWithContext() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.listOperations#RequestOptions + /*PagedIterable + modelOperationInfo = documentModelAdministrationClient.listOperations(new RequestOptions()); + modelOperationInfo.forEach(modelOperationSummary -> { + System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId()); + System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus()); + System.out.printf("Operation Created on: %s%n", modelOperationSummary.getCreatedDateTime()); + System.out.printf("Operation Percent completed: %d%n", modelOperationSummary.getPercentCompleted()); + System.out.printf("Operation Last updated on: %s%n", modelOperationSummary.getLastUpdatedDateTime()); + System.out.printf("Operation resource location: %s%n", modelOperationSummary.getResourceLocation()); + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.listOperations#RequestOptions + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#beginBuildClassifier(BuildDocumentClassifierRequest)} + */ + public void beginBuildClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginBuildClassifier#BuildDocumentClassifierRequest + String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}"; + String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}"; + HashMap documentTypes = new HashMap<>(); + documentTypes.put("1040-D", new ClassifierDocumentTypeDetails() + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040D) + )); + documentTypes.put("1040-A", new ClassifierDocumentTypeDetails() + .setAzureBlobSource(new AzureBlobContentSource(blobContainerUrl1040A) + )); + + DocumentClassifierDetails classifierDetails + = documentModelAdministrationClient.beginBuildClassifier( + new BuildDocumentClassifierRequest("classifierID", documentTypes)) + .getFinalResult(); + + System.out.printf("Classifier ID: %s%n", classifierDetails.getClassifierId()); + System.out.printf("Classifier description: %s%n", classifierDetails.getDescription()); + System.out.printf("Classifier created on: %s%n", classifierDetails.getCreatedDateTime()); + System.out.printf("Classifier expires on: %s%n", classifierDetails.getExpirationDateTime()); + classifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.beginBuildClassifier#BuildDocumentClassifierRequest + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#deleteClassifier(String)} + */ + public void deleteDocumentClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentClassifier#string + String classifierId = "{classifierId}"; + documentModelAdministrationClient.deleteClassifier(classifierId); + System.out.printf("Classifier ID: %s is deleted.%n", classifierId); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentClassifier#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#deleteClassifierWithResponse(String, RequestOptions)} + */ + public void deleteDocumentClassifierWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentClassifierWithResponse#string-Context + String classifierId = "{classifierId}"; + Response response + = documentModelAdministrationClient.deleteClassifierWithResponse(classifierId, new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + System.out.printf("Classifier ID: %s is deleted.%n", classifierId); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.deleteDocumentClassifierWithResponse#string-Context + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#listClassifiers()} + */ + public void listDocumentClassifiers() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.listDocumentClassifiers + documentModelAdministrationClient.listClassifiers() + .forEach(documentModel -> + System.out.printf("Classifier ID: %s, Classifier description: %s, Created on: %s.%n", + documentModel.getClassifierId(), + documentModel.getDescription(), + documentModel.getCreatedDateTime()) + ); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.listDocumentClassifiers + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getClassifier(String)} + */ + public void getDocumentClassifier() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getDocumentClassifier#string + String classifierId = "{classifierId}"; + DocumentClassifierDetails documentClassifierDetails + = documentModelAdministrationClient.getClassifier(classifierId); + System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifierDetails.getDescription()); + System.out.printf("Classifier Created on: %s%n", documentClassifierDetails.getCreatedDateTime()); + documentClassifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + if (documentTypeDetails.getAzureBlobFileListSource() != null) { + System.out.printf("Blob File List Source container Url: %s", + (documentTypeDetails + .getAzureBlobFileListSource()).getContainerUrl()); + } + }); + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getDocumentClassifier#string + } + + /** + * Code snippet for {@link DocumentModelAdministrationClient#getClassifierWithResponse(String, RequestOptions)} + */ + public void getDocumentClassifierWithResponse() { + // BEGIN: com.azure.ai.documentintelligence.DocumentModelAdminClient.getDocumentClassifierWithResponse#string-RequestOptions + /*String modelId = "{custom-model-id}"; + Response response + = documentModelAdministrationClient.getClassifierWithResponse(modelId, new RequestOptions()); + System.out.printf("Response Status Code: %d.", response.getStatusCode()); + DocumentClassifierDetails documentClassifierDetails = response.getValue(); + System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifierDetails.getDescription()); + System.out.printf("Classifier Created on: %s%n", documentClassifierDetails.getCreatedDateTime()); + documentClassifierDetails.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getContentSource() instanceof AzureBlobContentSource) { + System.out.printf("Blob Source container Url: %s", ((AzureBlobContentSource) documentTypeDetails + .getContentSource()).getContainerUrl()); + } + if (documentTypeDetails.getContentSource() instanceof BlobFileListContentSource) { + System.out.printf("Blob File List Source container Url: %s", + ((BlobFileListContentSource) documentTypeDetails + .getContentSource()).getContainerUrl()); + } + }); + + */ + // END: com.azure.ai.documentintelligence.DocumentModelAdminClient.getDocumentClassifierWithResponse#string-RequestOptions + } + +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummary.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummary.java new file mode 100644 index 000000000000..9eb3df0a8f3d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummary.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.DocumentModelBuildOperationDetails; +import com.azure.ai.documentintelligence.models.OperationDetails; +import com.azure.ai.documentintelligence.models.OperationStatus; +import com.azure.core.credential.AzureKeyCredential; + +/** + * Sample to get/list all document model operations associated with the Form Recognizer resource. + * Kinds of operations returned are "documentModelBuild", "documentModelCompose", and "documentModelCopyTo". + * Note that operation information only persists for 24 hours. + * If the operation was successful, the document model can be accessed using getDocumentModel() or listDocumentModels() APIs + */ +public class GetOperationSummary { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + client.listOperations().forEach(modelOperationSummary -> { + System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId()); + System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus()); + System.out.printf("Operation resource location %s%n", modelOperationSummary.getResourceLocation()); + System.out.printf("Operation percent completion status: %d%n", modelOperationSummary.getPercentCompleted()); + + // get the specific operation info + OperationDetails modelOperationDetails = + client.getOperation(modelOperationSummary.getOperationId()); + if (OperationStatus.FAILED.equals(modelOperationSummary.getStatus())) { + System.out.printf("Operation fail error: %s%n", modelOperationDetails.getError().getMessage()); + } else { + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) modelOperationDetails).getResult().getModelId()); + } + }); + + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummaryAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummaryAsync.java new file mode 100644 index 000000000000..87c4a4d2020f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/GetOperationSummaryAsync.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.DocumentModelBuildOperationDetails; +import com.azure.ai.documentintelligence.models.OperationStatus; +import com.azure.core.credential.AzureKeyCredential; + +/** + * Async sample to get/list all document model operations associated with the Form Recognizer resource. + * Kinds of operations returned are "documentModelBuild", "documentModelCompose", and "documentModelCopyTo". + * Note that operation information only persists for 24 hours. + * If the operation was successful, the document model can be accessed using get_model or list_models APIs + */ +public class GetOperationSummaryAsync { + + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + client.listOperations().subscribe(modelOperationSummary -> { + System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId()); + System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus()); + System.out.printf("Operation resource location %s%n", modelOperationSummary.getResourceLocation()); + System.out.printf("Operation percent completion status: %d%n", modelOperationSummary.getPercentCompleted()); + + // get the specific operation info + client.getOperation(modelOperationSummary.getOperationId()).subscribe(modelOperationDetails -> { + if (OperationStatus.FAILED.equals(modelOperationSummary.getStatus())) { + System.out.printf("Operation fail error: %s%n", modelOperationDetails.getError().getMessage()); + } else { + System.out.printf("Model ID created with this operation: %s%n", + ((DocumentModelBuildOperationDetails) modelOperationDetails).getResult().getModelId()); + } + }); + + }); + + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModels.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModels.java new file mode 100644 index 000000000000..8d25e9164c32 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModels.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.DocumentModelDetails; +import com.azure.ai.documentintelligence.models.ResourceDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; + +import java.util.concurrent.atomic.AtomicReference; + +/** + * Sample for demonstrating common custom document analysis model management operations. + * To learn how to build your own models, look at BuildDocumentModel.java and BuildDocumentModelAsync.java. + */ +public class ManageCustomModels { + + /** + * Main program to invoke the demo for performing operations of a custom document analysis model. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + AtomicReference modelId = new AtomicReference<>(); + + // First, we see how many models we have, and what our limit is + ResourceDetails resourceDetails = client.getResourceInfo(); + System.out.printf("The resource has %s models, and we can have at most %s models.%n", + resourceDetails.getCustomDocumentModels().getCount(), resourceDetails.getCustomDocumentModels().getLimit()); + + // Next, we get a paged list of all of our models + PagedIterable customDocumentModels = client.listModels(); + System.out.println("We have following models in the account:"); + customDocumentModels.forEach(documentModelInfo -> { + System.out.println(); + // get custom document analysis model info + modelId.set(documentModelInfo.getModelId()); + DocumentModelDetails documentModel = client.getModel(modelId.get()); + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model created on: %s%n", documentModel.getCreatedDateTime()); + if (documentModel.getDocTypes() != null) { + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s, ", field); + System.out.printf("Field type: %s, ", documentFieldSchema.getType()); + if (documentTypeDetails.getFieldConfidence() != null) { + System.out.printf("Field confidence: %.2f%n", documentTypeDetails.getFieldConfidence().get(field)); + } + }); + }); + } + }); + + // Delete Custom Model + System.out.printf("Deleted model with model ID: %s, operation completed with status: %s%n", modelId.get(), + client.deleteModelWithResponse(modelId.get(), new RequestOptions()).getStatusCode()); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModelsAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModelsAsync.java new file mode 100644 index 000000000000..213dd39fc1bc --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageCustomModelsAsync.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.core.credential.AzureKeyCredential; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + + +/** + * Async sample for demonstrating to perform common custom document analysis model management operations on your Form + * Recognizer resource. + * To learn how to build your own models, look at BuildDocumentModelAsync.java and BuildDocumentModel.java. + */ +public class ManageCustomModelsAsync { + + /** + * Main program to invoke the demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + AtomicReference modelId = new AtomicReference<>(); + + // First, we see how many models we have, and what our limit is + client.getResourceInfo().subscribe(resourceInfo -> + System.out.printf("The resource has %s models, and we can have at most %s models.%n", + resourceInfo.getCustomDocumentModels().getCount(), resourceInfo.getCustomDocumentModels().getLimit())); + // Next, we get a paged list of all of our models + System.out.println("We have following models in the account:"); + client.listModels().subscribe(documentModelInfo -> { + String createdModelId = documentModelInfo.getModelId(); + System.out.println(); + // get custom document analysis model info + modelId.set(createdModelId); + client.getModel(documentModelInfo.getModelId()).subscribe(documentModel -> { + System.out.printf("Model ID: %s%n", documentModel.getModelId()); + System.out.printf("Model Description: %s%n", documentModel.getDescription()); + System.out.printf("Model created on: %s%n", documentModel.getCreatedDateTime()); + documentModel.getDocTypes().forEach((key, documentTypeDetails) -> { + documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> { + System.out.printf("Field: %s, ", field); + System.out.printf("Field type: %s, ", documentFieldSchema.getType()); + System.out.printf("Field confidence: %.2f%n", documentTypeDetails.getFieldConfidence().get(field)); + }); + }); + }); + }); + + // Delete Custom Model + client.deleteModel(modelId.get()); + System.out.printf("Deleted model with model ID: %s%n", modelId.get()); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.SECONDS.sleep(15); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiers.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiers.java new file mode 100644 index 000000000000..fd73c73f183e --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiers.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.ai.documentintelligence.models.AzureBlobContentSource; +import com.azure.ai.documentintelligence.models.DocumentClassifierDetails; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.Context; + +import java.util.concurrent.atomic.AtomicReference; + +/** + * Sample for demonstrating commonly performed document classifier management operations. + * To learn how to build your own classifiers, look at BuildDocumentClassifier.java and BuildDocumentClassifierAsync.java. + */ +public class ManageDocumentClassifiers { + + /** + * Main program to invoke the demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildClient(); + + AtomicReference classifierId = new AtomicReference<>(); + + // Next, we get a paged list of all document classifiers + PagedIterable documentClassifierDetailList = client.listClassifiers(); + System.out.println("We have following classifiers in the account:"); + documentClassifierDetailList.forEach(documentClassifierDetails -> { + System.out.println(); + // get Classifier info + classifierId.set(documentClassifierDetails.getClassifierId()); + DocumentClassifierDetails documentClassifier = client.getClassifier(documentClassifierDetails.getClassifierId()); + System.out.printf("Classifier ID: %s%n", documentClassifier.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifier.getDescription()); + System.out.printf("Classifier created on: %s%n", documentClassifier.getCreatedDateTime()); + documentClassifier.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s%n", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + }); + }); + + // Delete classifier + System.out.printf("Deleted Classifier with Classifier ID: %s, operation completed with status: %s%n", classifierId.get(), + client.deleteClassifierWithResponse(classifierId.get(), new RequestOptions()).getStatusCode()); + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiersAsync.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiersAsync.java new file mode 100644 index 000000000000..fe0a13552ab0 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/ManageDocumentClassifiersAsync.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.documentintelligence.administration; + +import com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient; +import com.azure.ai.documentintelligence.DocumentModelAdministrationClientBuilder; +import com.azure.core.credential.AzureKeyCredential; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + + +/** + * Async sample demonstrating common document classifier management operations on your Form + * Recognizer resource. + * To learn how to build your own classifiers, look at BuildDocumentClassifierAsync.java and BuildDocumentClassifier.java. + */ +public class ManageDocumentClassifiersAsync { + + /** + * Main program to invoke the demo. + * + * @param args Unused. Arguments to the program. + */ + public static void main(final String[] args) { + // Instantiate a client that will be used to call the service. + DocumentModelAdministrationAsyncClient client = new DocumentModelAdministrationClientBuilder() + .credential(new AzureKeyCredential("{key}")) + .endpoint("https://{endpoint}.cognitiveservices.azure.com/") + .buildAsyncClient(); + + AtomicReference classifierId = new AtomicReference<>(); + + // Next, we get a paged list of all document classifiers + System.out.println("We have following classifiers in the account:"); + client.listClassifiers().subscribe(documentClassifierDetails -> { + System.out.println(); + // get Classifier info + classifierId.set(documentClassifierDetails.getClassifierId()); + client.getClassifier(documentClassifierDetails.getClassifierId()).subscribe(documentClassifier -> { + System.out.printf("Classifier ID: %s%n", documentClassifier.getClassifierId()); + System.out.printf("Classifier Description: %s%n", documentClassifier.getDescription()); + System.out.printf("Classifier created on: %s%n", documentClassifier.getCreatedDateTime()); + documentClassifier.getDocTypes().forEach((key, documentTypeDetails) -> { + if (documentTypeDetails.getAzureBlobSource() != null) { + System.out.printf("Blob Source container Url: %s%n", (documentTypeDetails + .getAzureBlobSource()).getContainerUrl()); + } + }); + }); + }); + + + // Delete classifier + client.deleteClassifier(classifierId.get()); + System.out.printf("Deleted Classifier with Classifier ID: %s", classifierId.get()); + + // The .subscribe() creation and assignment is not a blocking call. For the purpose of this example, we sleep + // the thread so the program does not end before the send operation is complete. Using .block() instead of + // .subscribe() will turn this into a synchronous call. + try { + TimeUnit.SECONDS.sleep(15); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/package-info.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/package-info.java new file mode 100644 index 000000000000..71cbb760cd0f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/java/com/azure/ai/documentintelligence/administration/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package containing sample classes for interacting with {@link com.azure.ai.documentintelligence.DocumentModelAdministrationAsyncClient} to + * perform operations on Azure Form Recognizer + */ +package com.azure.ai.documentintelligence.administration; diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/IdentityDocuments/license.png b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/IdentityDocuments/license.png new file mode 100644 index 000000000000..661312305a45 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/IdentityDocuments/license.png differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Form_1.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Form_1.jpg new file mode 100644 index 000000000000..29cae664f1b8 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Form_1.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Invoice_6.pdf b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Invoice_6.pdf new file mode 100644 index 000000000000..53f505d20607 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/Invoice_6.pdf differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/selectionMarkForm.pdf b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/selectionMarkForm.pdf new file mode 100644 index 000000000000..0721647fa52b Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/forms/selectionMarkForm.pdf differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/Invoice_1.pdf b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/Invoice_1.pdf new file mode 100644 index 000000000000..5ffff2960d74 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/Invoice_1.pdf differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/sample_invoice.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/sample_invoice.jpg new file mode 100644 index 000000000000..6f8796469d78 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/invoices/sample_invoice.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/receipts/contoso-allinone.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/receipts/contoso-allinone.jpg new file mode 100644 index 000000000000..1aaad34387ec Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/receipts/contoso-allinone.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg new file mode 100644 index 000000000000..29cae664f1b8 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.labels.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.labels.json new file mode 100644 index 000000000000..82ba91c2d746 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.labels.json @@ -0,0 +1,527 @@ +{ + "document": "Form_1.jpg", + "labels": [ + { + "label": "Merchant", + "key": null, + "value": [ + { + "page": 1, + "text": "Hero", + "boundingBoxes": [ + [ + 0.3658823529411765, + 0.09409090909090909, + 0.46352941176470586, + 0.09272727272727273, + 0.46294117647058824, + 0.12090909090909091, + 0.3652941176470588, + 0.12090909090909091 + ] + ] + }, + { + "page": 1, + "text": "Limited", + "boundingBoxes": [ + [ + 0.47705882352941176, + 0.09272727272727273, + 0.6323529411764706, + 0.09181818181818181, + 0.6323529411764706, + 0.12090909090909091, + 0.47705882352941176, + 0.12090909090909091 + ] + ] + } + ] + }, + { + "label": "PhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "555-348-6512", + "boundingBoxes": [ + [ + 0.21588235294117647, + 0.15954545454545455, + 0.3111764705882353, + 0.16, + 0.3111764705882353, + 0.17, + 0.21588235294117647, + 0.17181818181818181 + ] + ] + } + ] + }, + { + "label": "Website", + "key": null, + "value": [ + { + "page": 1, + "text": "www.herolimited.com", + "boundingBoxes": [ + [ + 0.16176470588235295, + 0.17863636363636365, + 0.31058823529411766, + 0.17863636363636365, + 0.3111764705882353, + 0.19, + 0.16117647058823528, + 0.19045454545454546 + ] + ] + } + ] + }, + { + "label": "DatedAs", + "key": null, + "value": [ + { + "page": 1, + "text": "12/20/2020", + "boundingBoxes": [ + [ + 0.6876470588235294, + 0.19136363636363637, + 0.7747058823529411, + 0.19090909090909092, + 0.7747058823529411, + 0.20454545454545456, + 0.6870588235294117, + 0.20454545454545456 + ] + ] + } + ] + }, + { + "label": "Email", + "key": null, + "value": [ + { + "page": 1, + "text": "accounts@herolimited.com", + "boundingBoxes": [ + [ + 0.0976470588235294, + 0.22, + 0.27941176470588236, + 0.21818181818181817, + 0.2782352941176471, + 0.22863636363636364, + 0.0976470588235294, + 0.22863636363636364 + ] + ] + } + ] + }, + { + "label": "PurchaseOrderNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "948284", + "boundingBoxes": [ + [ + 0.7547058823529412, + 0.20954545454545453, + 0.81, + 0.21, + 0.8094117647058824, + 0.22181818181818183, + 0.7541176470588236, + 0.22227272727272726 + ] + ] + } + ] + }, + { + "label": "VendorName", + "key": null, + "value": [ + { + "page": 1, + "text": "Hillary", + "boundingBoxes": [ + [ + 0.20705882352941177, + 0.2772727272727273, + 0.25529411764705884, + 0.2768181818181818, + 0.25470588235294117, + 0.2913636363636364, + 0.20647058823529413, + 0.2913636363636364 + ] + ] + }, + { + "page": 1, + "text": "Swank", + "boundingBoxes": [ + [ + 0.25823529411764706, + 0.2768181818181818, + 0.30470588235294116, + 0.2768181818181818, + 0.30411764705882355, + 0.2909090909090909, + 0.2576470588235294, + 0.2913636363636364 + ] + ] + } + ] + }, + { + "label": "CompanyName", + "key": null, + "value": [ + { + "page": 1, + "text": "Higgly", + "boundingBoxes": [ + [ + 0.22294117647058823, + 0.29409090909090907, + 0.26823529411764707, + 0.29409090909090907, + 0.2676470588235294, + 0.31, + 0.2223529411764706, + 0.31 + ] + ] + }, + { + "page": 1, + "text": "Wiggly", + "boundingBoxes": [ + [ + 0.27176470588235296, + 0.29409090909090907, + 0.32294117647058823, + 0.29363636363636364, + 0.32235294117647056, + 0.30863636363636365, + 0.2711764705882353, + 0.31 + ] + ] + }, + { + "page": 1, + "text": "Books", + "boundingBoxes": [ + [ + 0.3264705882352941, + 0.29363636363636364, + 0.37, + 0.29363636363636364, + 0.36941176470588233, + 0.30727272727272725, + 0.32588235294117646, + 0.30863636363636365 + ] + ] + } + ] + }, + { + "label": "CompanyAddress", + "key": null, + "value": [ + { + "page": 1, + "text": "938", + "boundingBoxes": [ + [ + 0.16294117647058823, + 0.31136363636363634, + 0.19058823529411764, + 0.31136363636363634, + 0.19058823529411764, + 0.3240909090909091, + 0.16294117647058823, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "NE", + "boundingBoxes": [ + [ + 0.19411764705882353, + 0.31136363636363634, + 0.21470588235294116, + 0.31136363636363634, + 0.21470588235294116, + 0.3240909090909091, + 0.1935294117647059, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Burner", + "boundingBoxes": [ + [ + 0.21764705882352942, + 0.31136363636363634, + 0.26823529411764707, + 0.31136363636363634, + 0.26823529411764707, + 0.3240909090909091, + 0.21764705882352942, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Road", + "boundingBoxes": [ + [ + 0.27176470588235296, + 0.31136363636363634, + 0.30941176470588233, + 0.3118181818181818, + 0.30941176470588233, + 0.3240909090909091, + 0.2711764705882353, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Boulder", + "boundingBoxes": [ + [ + 0.16411764705882353, + 0.3286363636363636, + 0.22058823529411764, + 0.3277272727272727, + 0.22, + 0.3427272727272727, + 0.1635294117647059, + 0.3427272727272727 + ] + ] + }, + { + "page": 1, + "text": "City,", + "boundingBoxes": [ + [ + 0.22411764705882353, + 0.3277272727272727, + 0.2570588235294118, + 0.3277272727272727, + 0.2564705882352941, + 0.3422727272727273, + 0.2235294117647059, + 0.3427272727272727 + ] + ] + }, + { + "page": 1, + "text": "CO", + "boundingBoxes": [ + [ + 0.2605882352941176, + 0.3277272727272727, + 0.2817647058823529, + 0.3277272727272727, + 0.2811764705882353, + 0.3422727272727273, + 0.26, + 0.3422727272727273 + ] + ] + }, + { + "page": 1, + "text": "92848", + "boundingBoxes": [ + [ + 0.2852941176470588, + 0.3277272727272727, + 0.3341176470588235, + 0.3277272727272727, + 0.3341176470588235, + 0.34136363636363637, + 0.2847058823529412, + 0.3422727272727273 + ] + ] + } + ] + }, + { + "label": "CompanyPhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "938-294-2949", + "boundingBoxes": [ + [ + 0.4194117647058824, + 0.3281818181818182, + 0.52, + 0.3281818181818182, + 0.52, + 0.34045454545454545, + 0.4194117647058824, + 0.3409090909090909 + ] + ] + } + ] + }, + { + "label": "Quantity", + "key": null, + "value": [ + { + "page": 1, + "text": "20", + "boundingBoxes": [ + [ + 0.5064705882352941, + 0.4959090909090909, + 0.5252941176470588, + 0.495, + 0.5264705882352941, + 0.5081818181818182, + 0.5076470588235295, + 0.509090909090909 + ] + ] + } + ] + }, + { + "label": "Subtotal", + "key": null, + "value": [ + { + "page": 1, + "text": "$140.00", + "boundingBoxes": [ + [ + 0.8405882352941176, + 0.7145454545454546, + 0.9, + 0.7136363636363636, + 0.8994117647058824, + 0.7268181818181818, + 0.8405882352941176, + 0.7268181818181818 + ] + ] + } + ] + }, + { + "label": "Tax", + "key": null, + "value": [ + { + "page": 1, + "text": "$4.00", + "boundingBoxes": [ + [ + 0.8594117647058823, + 0.7340909090909091, + 0.9, + 0.7336363636363636, + 0.9, + 0.7459090909090909, + 0.8594117647058823, + 0.7463636363636363 + ] + ] + } + ] + }, + { + "label": "Signature", + "key": null, + "value": [ + { + "page": 1, + "text": "Bernie", + "boundingBoxes": [ + [ + 0.28411764705882353, + 0.76, + 0.3547058823529412, + 0.7595454545454545, + 0.35411764705882354, + 0.7759090909090909, + 0.28352941176470586, + 0.7759090909090909 + ] + ] + }, + { + "page": 1, + "text": "Sanders", + "boundingBoxes": [ + [ + 0.3611764705882353, + 0.7595454545454545, + 0.44941176470588234, + 0.759090909090909, + 0.44882352941176473, + 0.7768181818181819, + 0.36058823529411765, + 0.7763636363636364 + ] + ] + } + ] + }, + { + "label": "Total", + "key": null, + "value": [ + { + "page": 1, + "text": "$144.00", + "boundingBoxes": [ + [ + 0.8405882352941176, + 0.7595454545454545, + 0.8994117647058824, + 0.7586363636363637, + 0.9, + 0.7709090909090909, + 0.8405882352941176, + 0.7713636363636364 + ] + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.ocr.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.ocr.json new file mode 100644 index 000000000000..48ce7cd0920d --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_1.jpg.ocr.json @@ -0,0 +1,3243 @@ +{ + "status": "succeeded", + "createdDateTime": "2020-04-09T01:30:09Z", + "lastUpdatedDateTime": "2020-04-09T01:30:12Z", + "analyzeResult": { + "version": "2.0.0", + "readResults": [ + { + "page": 1, + "language": "en", + "angle": 0, + "width": 1700, + "height": 2200, + "unit": "pixel", + "lines": [ + { + "language": "en", + "boundingBox": [ + 137, + 140, + 351, + 140, + 351, + 167, + 137, + 166 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 137, + 140, + 263, + 140, + 263, + 168, + 138, + 166 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 271, + 140, + 351, + 140, + 351, + 168, + 272, + 168 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 620, + 204, + 1073, + 201, + 1074, + 264, + 620, + 266 + ], + "text": "Hero Limited", + "words": [ + { + "boundingBox": [ + 622, + 207, + 788, + 204, + 787, + 266, + 621, + 266 + ], + "text": "Hero", + "confidence": 0.959 + }, + { + "boundingBox": [ + 811, + 204, + 1075, + 202, + 1075, + 266, + 811, + 266 + ], + "text": "Limited", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 351, + 529, + 350, + 530, + 377, + 165, + 379 + ], + "text": "Company Phone: 555-348-6512", + "words": [ + { + "boundingBox": [ + 167, + 352, + 275, + 351, + 275, + 379, + 167, + 379 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 281, + 351, + 362, + 351, + 362, + 378, + 280, + 379 + ], + "text": "Phone:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 367, + 351, + 529, + 352, + 529, + 374, + 367, + 378 + ], + "text": "555-348-6512", + "confidence": 0.946 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 320, + 1551, + 320, + 1551, + 370, + 1114, + 370 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 1115, + 322, + 1377, + 320, + 1377, + 371, + 1117, + 371 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1396, + 321, + 1550, + 321, + 1549, + 371, + 1396, + 371 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 392, + 534, + 392, + 534, + 419, + 167, + 418 + ], + "text": "Website: www.herolimited.com", + "words": [ + { + "boundingBox": [ + 168, + 392, + 270, + 393, + 269, + 419, + 167, + 418 + ], + "text": "Website:", + "confidence": 0.957 + }, + { + "boundingBox": [ + 275, + 393, + 528, + 393, + 529, + 418, + 274, + 419 + ], + "text": "www.herolimited.com", + "confidence": 0.872 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 437, + 236, + 437, + 236, + 459, + 164, + 459 + ], + "text": "Email:", + "words": [ + { + "boundingBox": [ + 165, + 437, + 236, + 437, + 237, + 460, + 165, + 459 + ], + "text": "Email:", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 420, + 1317, + 419, + 1317, + 449, + 1025, + 449 + ], + "text": "Dated As: 12/20/2020", + "words": [ + { + "boundingBox": [ + 1026, + 420, + 1112, + 421, + 1112, + 450, + 1025, + 449 + ], + "text": "Dated", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1118, + 421, + 1163, + 421, + 1163, + 450, + 1117, + 450 + ], + "text": "As:", + "confidence": 0.957 + }, + { + "boundingBox": [ + 1169, + 421, + 1317, + 420, + 1317, + 450, + 1168, + 450 + ], + "text": "12/20/2020", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 480, + 482, + 479, + 482, + 502, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "words": [ + { + "boundingBox": [ + 166, + 484, + 475, + 480, + 473, + 503, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "confidence": 0.856 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 461, + 1376, + 461, + 1376, + 488, + 1025, + 490 + ], + "text": "Purchase Order #: 948284", + "words": [ + { + "boundingBox": [ + 1027, + 463, + 1154, + 461, + 1153, + 490, + 1026, + 489 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1161, + 461, + 1241, + 461, + 1240, + 490, + 1160, + 490 + ], + "text": "Order", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1246, + 461, + 1278, + 461, + 1277, + 489, + 1246, + 489 + ], + "text": "#:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1283, + 461, + 1377, + 462, + 1376, + 488, + 1282, + 489 + ], + "text": "948284", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 546, + 397, + 546, + 397, + 594, + 166, + 594 + ], + "text": "Shipped To", + "words": [ + { + "boundingBox": [ + 167, + 546, + 336, + 548, + 337, + 593, + 168, + 595 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 346, + 548, + 396, + 548, + 397, + 593, + 347, + 593 + ], + "text": "To", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 608, + 518, + 608, + 518, + 640, + 160, + 640 + ], + "text": "Vendor Name: Hillary Swank", + "words": [ + { + "boundingBox": [ + 162, + 610, + 257, + 610, + 255, + 640, + 160, + 637 + ], + "text": "Vendor", + "confidence": 0.959 + }, + { + "boundingBox": [ + 262, + 610, + 347, + 610, + 346, + 641, + 261, + 640 + ], + "text": "Name:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 352, + 610, + 434, + 609, + 433, + 641, + 351, + 641 + ], + "text": "Hillary", + "confidence": 0.959 + }, + { + "boundingBox": [ + 439, + 609, + 518, + 609, + 517, + 640, + 438, + 641 + ], + "text": "Swank", + "confidence": 0.954 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 648, + 628, + 645, + 629, + 680, + 160, + 682 + ], + "text": "Company Name: Higgly Wiggly Books", + "words": [ + { + "boundingBox": [ + 162, + 648, + 282, + 647, + 281, + 681, + 161, + 678 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 288, + 647, + 373, + 647, + 372, + 682, + 287, + 682 + ], + "text": "Name:", + "confidence": 0.911 + }, + { + "boundingBox": [ + 379, + 647, + 456, + 647, + 455, + 682, + 378, + 682 + ], + "text": "Higgly", + "confidence": 0.959 + }, + { + "boundingBox": [ + 462, + 647, + 549, + 646, + 548, + 679, + 461, + 682 + ], + "text": "Wiggly", + "confidence": 0.959 + }, + { + "boundingBox": [ + 555, + 646, + 629, + 646, + 628, + 676, + 554, + 679 + ], + "text": "Books", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 161, + 684, + 526, + 684, + 526, + 712, + 161, + 712 + ], + "text": "Address: 938 NE Burner Road", + "words": [ + { + "boundingBox": [ + 162, + 685, + 271, + 685, + 271, + 713, + 162, + 712 + ], + "text": "Address:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 277, + 685, + 324, + 685, + 324, + 713, + 277, + 713 + ], + "text": "938", + "confidence": 0.947 + }, + { + "boundingBox": [ + 330, + 685, + 365, + 685, + 365, + 713, + 329, + 713 + ], + "text": "NE", + "confidence": 0.958 + }, + { + "boundingBox": [ + 370, + 685, + 456, + 685, + 456, + 713, + 370, + 713 + ], + "text": "Burner", + "confidence": 0.958 + }, + { + "boundingBox": [ + 462, + 685, + 526, + 686, + 526, + 713, + 461, + 713 + ], + "text": "Road", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 274, + 722, + 603, + 720, + 604, + 751, + 274, + 754 + ], + "text": "Boulder City, CO 92848", + "words": [ + { + "boundingBox": [ + 279, + 723, + 375, + 721, + 374, + 754, + 278, + 754 + ], + "text": "Boulder", + "confidence": 0.959 + }, + { + "boundingBox": [ + 381, + 721, + 437, + 721, + 436, + 753, + 380, + 754 + ], + "text": "City,", + "confidence": 0.959 + }, + { + "boundingBox": [ + 443, + 721, + 479, + 721, + 478, + 753, + 442, + 753 + ], + "text": "CO", + "confidence": 0.886 + }, + { + "boundingBox": [ + 485, + 721, + 568, + 721, + 568, + 751, + 484, + 753 + ], + "text": "92848", + "confidence": 0.937 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 612, + 721, + 884, + 721, + 884, + 749, + 612, + 749 + ], + "text": "Phone: 938-294-2949", + "words": [ + { + "boundingBox": [ + 614, + 722, + 707, + 722, + 707, + 750, + 614, + 750 + ], + "text": "Phone:", + "confidence": 0.952 + }, + { + "boundingBox": [ + 713, + 722, + 884, + 722, + 884, + 749, + 713, + 750 + ], + "text": "938-294-2949", + "confidence": 0.956 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 783, + 451, + 783, + 451, + 827, + 166, + 830 + ], + "text": "Shipped From", + "words": [ + { + "boundingBox": [ + 167, + 784, + 336, + 784, + 335, + 829, + 166, + 830 + ], + "text": "Shipped", + "confidence": 0.867 + }, + { + "boundingBox": [ + 345, + 784, + 441, + 783, + 440, + 825, + 344, + 829 + ], + "text": "From", + "confidence": 0.918 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 851, + 446, + 851, + 446, + 881, + 165, + 880 + ], + "text": "Name: Bernie Sanders", + "words": [ + { + "boundingBox": [ + 166, + 851, + 252, + 853, + 251, + 880, + 165, + 881 + ], + "text": "Name:", + "confidence": 0.956 + }, + { + "boundingBox": [ + 258, + 853, + 339, + 854, + 337, + 880, + 257, + 880 + ], + "text": "Bernie", + "confidence": 0.958 + }, + { + "boundingBox": [ + 345, + 854, + 447, + 853, + 445, + 881, + 343, + 880 + ], + "text": "Sanders", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 889, + 629, + 889, + 629, + 920, + 164, + 920 + ], + "text": "Company Name: Jupiter Book Supply", + "words": [ + { + "boundingBox": [ + 167, + 891, + 287, + 890, + 287, + 920, + 166, + 920 + ], + "text": "Company", + "confidence": 0.958 + }, + { + "boundingBox": [ + 293, + 890, + 376, + 890, + 375, + 921, + 292, + 920 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 382, + 890, + 470, + 890, + 469, + 921, + 381, + 921 + ], + "text": "Jupiter", + "confidence": 0.958 + }, + { + "boundingBox": [ + 476, + 890, + 540, + 890, + 539, + 921, + 475, + 921 + ], + "text": "Book", + "confidence": 0.959 + }, + { + "boundingBox": [ + 546, + 890, + 629, + 890, + 629, + 921, + 545, + 921 + ], + "text": "Supply", + "confidence": 0.947 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 926, + 520, + 926, + 520, + 953, + 164, + 953 + ], + "text": "Address: 383 N Kinnick Road", + "words": [ + { + "boundingBox": [ + 166, + 927, + 277, + 927, + 277, + 953, + 165, + 954 + ], + "text": "Address:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 283, + 927, + 330, + 927, + 329, + 953, + 282, + 953 + ], + "text": "383", + "confidence": 0.958 + }, + { + "boundingBox": [ + 335, + 927, + 353, + 927, + 352, + 953, + 334, + 953 + ], + "text": "N", + "confidence": 0.888 + }, + { + "boundingBox": [ + 362, + 927, + 452, + 927, + 451, + 954, + 361, + 953 + ], + "text": "Kinnick", + "confidence": 0.958 + }, + { + "boundingBox": [ + 457, + 927, + 521, + 927, + 521, + 954, + 457, + 954 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 280, + 964, + 516, + 964, + 516, + 991, + 280, + 991 + ], + "text": "Seattle, WA 38383", + "words": [ + { + "boundingBox": [ + 284, + 965, + 381, + 965, + 380, + 992, + 283, + 992 + ], + "text": "Seattle,", + "confidence": 0.959 + }, + { + "boundingBox": [ + 386, + 965, + 432, + 965, + 431, + 992, + 385, + 992 + ], + "text": "WA", + "confidence": 0.944 + }, + { + "boundingBox": [ + 438, + 965, + 516, + 964, + 515, + 991, + 437, + 992 + ], + "text": "38383", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 759, + 963, + 1036, + 963, + 1036, + 991, + 759, + 991 + ], + "text": "Phone: 932-299-0292", + "words": [ + { + "boundingBox": [ + 761, + 964, + 854, + 963, + 852, + 991, + 760, + 990 + ], + "text": "Phone:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 859, + 963, + 1034, + 964, + 1032, + 991, + 857, + 991 + ], + "text": "932-299-0292", + "confidence": 0.953 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 447, + 1045, + 557, + 1045, + 557, + 1079, + 447, + 1079 + ], + "text": "Details", + "words": [ + { + "boundingBox": [ + 448, + 1048, + 555, + 1046, + 556, + 1080, + 449, + 1079 + ], + "text": "Details", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 889, + 1045, + 1030, + 1046, + 1030, + 1084, + 889, + 1084 + ], + "text": "Quantity", + "words": [ + { + "boundingBox": [ + 889, + 1046, + 1029, + 1046, + 1027, + 1084, + 890, + 1083 + ], + "text": "Quantity", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 1046, + 1271, + 1047, + 1271, + 1078, + 1114, + 1077 + ], + "text": "Unit Price", + "words": [ + { + "boundingBox": [ + 1114, + 1048, + 1184, + 1047, + 1184, + 1078, + 1114, + 1078 + ], + "text": "Unit", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1047, + 1271, + 1047, + 1271, + 1079, + 1190, + 1078 + ], + "text": "Price", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1384, + 1047, + 1469, + 1046, + 1470, + 1076, + 1385, + 1077 + ], + "text": "Total", + "words": [ + { + "boundingBox": [ + 1387, + 1047, + 1470, + 1046, + 1470, + 1076, + 1387, + 1077 + ], + "text": "Total", + "confidence": 0.858 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1094, + 280, + 1096, + 279, + 1124, + 172, + 1121 + ], + "text": "Bindings", + "words": [ + { + "boundingBox": [ + 172, + 1094, + 278, + 1097, + 278, + 1124, + 172, + 1121 + ], + "text": "Bindings", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 859, + 1091, + 894, + 1089, + 895, + 1118, + 860, + 1120 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1091, + 893, + 1089, + 895, + 1118, + 863, + 1120 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1241, + 1095, + 1296, + 1094, + 1296, + 1118, + 1241, + 1118 + ], + "text": "1.00", + "words": [ + { + "boundingBox": [ + 1242, + 1094, + 1295, + 1094, + 1295, + 1118, + 1242, + 1118 + ], + "text": "1.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1459, + 1095, + 1531, + 1093, + 1531, + 1118, + 1459, + 1119 + ], + "text": "20.00", + "words": [ + { + "boundingBox": [ + 1459, + 1094, + 1530, + 1093, + 1531, + 1118, + 1460, + 1119 + ], + "text": "20.00", + "confidence": 0.957 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 169, + 1135, + 329, + 1134, + 329, + 1162, + 169, + 1163 + ], + "text": "Covers Small", + "words": [ + { + "boundingBox": [ + 173, + 1135, + 257, + 1135, + 256, + 1163, + 172, + 1163 + ], + "text": "Covers", + "confidence": 0.959 + }, + { + "boundingBox": [ + 262, + 1135, + 329, + 1134, + 328, + 1163, + 262, + 1163 + ], + "text": "Small", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 860, + 1137, + 893, + 1135, + 893, + 1158, + 861, + 1160 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 862, + 1137, + 892, + 1135, + 893, + 1158, + 863, + 1160 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1239, + 1136, + 1294, + 1135, + 1294, + 1159, + 1239, + 1159 + ], + "text": "1.00", + "words": [ + { + "boundingBox": [ + 1243, + 1135, + 1293, + 1135, + 1293, + 1159, + 1243, + 1159 + ], + "text": "1.00", + "confidence": 0.908 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1457, + 1136, + 1532, + 1135, + 1532, + 1159, + 1457, + 1160 + ], + "text": "20.00", + "words": [ + { + "boundingBox": [ + 1459, + 1136, + 1529, + 1135, + 1530, + 1160, + 1459, + 1160 + ], + "text": "20.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1179, + 400, + 1178, + 400, + 1205, + 170, + 1206 + ], + "text": "Feather Bookmark", + "words": [ + { + "boundingBox": [ + 172, + 1180, + 271, + 1180, + 270, + 1206, + 171, + 1206 + ], + "text": "Feather", + "confidence": 0.959 + }, + { + "boundingBox": [ + 276, + 1180, + 401, + 1179, + 400, + 1206, + 275, + 1206 + ], + "text": "Bookmark", + "confidence": 0.949 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 863, + 1181, + 893, + 1180, + 893, + 1202, + 863, + 1203 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 863, + 1181, + 892, + 1180, + 892, + 1202, + 863, + 1203 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1239, + 1179, + 1295, + 1179, + 1295, + 1202, + 1239, + 1202 + ], + "text": "5,00", + "words": [ + { + "boundingBox": [ + 1241, + 1179, + 1294, + 1179, + 1294, + 1202, + 1241, + 1202 + ], + "text": "5,00", + "confidence": 0.423 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1180, + 1531, + 1179, + 1532, + 1203, + 1443, + 1204 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1446, + 1181, + 1530, + 1180, + 1529, + 1203, + 1446, + 1204 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1222, + 429, + 1221, + 429, + 1250, + 168, + 1252 + ], + "text": "Copper Swirl Marker", + "words": [ + { + "boundingBox": [ + 173, + 1223, + 263, + 1222, + 263, + 1252, + 172, + 1253 + ], + "text": "Copper", + "confidence": 0.959 + }, + { + "boundingBox": [ + 269, + 1222, + 332, + 1222, + 332, + 1251, + 269, + 1252 + ], + "text": "Swirl", + "confidence": 0.954 + }, + { + "boundingBox": [ + 338, + 1222, + 430, + 1222, + 430, + 1249, + 338, + 1251 + ], + "text": "Marker", + "confidence": 0.956 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1223, + 893, + 1222, + 893, + 1246, + 861, + 1248 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1223, + 892, + 1222, + 893, + 1246, + 862, + 1247 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1240, + 1222, + 1295, + 1223, + 1295, + 1246, + 1240, + 1245 + ], + "text": "5,00", + "words": [ + { + "boundingBox": [ + 1241, + 1222, + 1294, + 1223, + 1293, + 1246, + 1240, + 1245 + ], + "text": "5,00", + "confidence": 0.424 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1222, + 1531, + 1222, + 1531, + 1247, + 1443, + 1247 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1445, + 1223, + 1529, + 1222, + 1529, + 1248, + 1444, + 1248 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1148, + 1574, + 1296, + 1574, + 1296, + 1599, + 1148, + 1599 + ], + "text": "SUBTOTAL", + "words": [ + { + "boundingBox": [ + 1149, + 1574, + 1295, + 1575, + 1295, + 1600, + 1149, + 1600 + ], + "text": "SUBTOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1428, + 1571, + 1530, + 1570, + 1531, + 1598, + 1428, + 1599 + ], + "text": "$140.00", + "words": [ + { + "boundingBox": [ + 1429, + 1572, + 1530, + 1570, + 1529, + 1599, + 1429, + 1599 + ], + "text": "$140.00", + "confidence": 0.957 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1238, + 1619, + 1295, + 1618, + 1295, + 1642, + 1237, + 1642 + ], + "text": "TAX", + "words": [ + { + "boundingBox": [ + 1241, + 1618, + 1294, + 1618, + 1294, + 1641, + 1241, + 1642 + ], + "text": "TAX", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1460, + 1616, + 1531, + 1614, + 1531, + 1641, + 1460, + 1641 + ], + "text": "$4.00", + "words": [ + { + "boundingBox": [ + 1461, + 1615, + 1530, + 1614, + 1530, + 1641, + 1461, + 1642 + ], + "text": "$4.00", + "confidence": 0.939 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 481, + 1670, + 764, + 1670, + 764, + 1708, + 481, + 1708 + ], + "text": "Bernie Sanders", + "words": [ + { + "boundingBox": [ + 483, + 1672, + 603, + 1671, + 602, + 1707, + 482, + 1707 + ], + "text": "Bernie", + "confidence": 0.909 + }, + { + "boundingBox": [ + 614, + 1671, + 764, + 1670, + 763, + 1709, + 613, + 1708 + ], + "text": "Sanders", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1204, + 1672, + 1296, + 1672, + 1296, + 1699, + 1204, + 1699 + ], + "text": "TOTAL", + "words": [ + { + "boundingBox": [ + 1207, + 1674, + 1295, + 1672, + 1296, + 1700, + 1207, + 1699 + ], + "text": "TOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1426, + 1670, + 1530, + 1669, + 1530, + 1695, + 1426, + 1697 + ], + "text": "$144.00", + "words": [ + { + "boundingBox": [ + 1429, + 1671, + 1529, + 1669, + 1530, + 1696, + 1429, + 1697 + ], + "text": "$144.00", + "confidence": 0.949 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 543, + 1718, + 716, + 1719, + 716, + 1743, + 543, + 1742 + ], + "text": "Bernie Sanders", + "words": [ + { + "boundingBox": [ + 544, + 1719, + 621, + 1719, + 621, + 1743, + 544, + 1743 + ], + "text": "Bernie", + "confidence": 0.959 + }, + { + "boundingBox": [ + 626, + 1719, + 717, + 1720, + 716, + 1744, + 626, + 1743 + ], + "text": "Sanders", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 581, + 1754, + 681, + 1756, + 680, + 1777, + 581, + 1776 + ], + "text": "Manager", + "words": [ + { + "boundingBox": [ + 582, + 1755, + 681, + 1756, + 680, + 1778, + 581, + 1776 + ], + "text": "Manager", + "confidence": 0.957 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1796, + 480, + 1797, + 480, + 1832, + 173, + 1830 + ], + "text": "Additional Notes:", + "words": [ + { + "boundingBox": [ + 175, + 1798, + 360, + 1797, + 360, + 1833, + 174, + 1830 + ], + "text": "Additional", + "confidence": 0.959 + }, + { + "boundingBox": [ + 366, + 1797, + 481, + 1800, + 481, + 1832, + 366, + 1833 + ], + "text": "Notes:", + "confidence": 0.944 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1879, + 705, + 1880, + 705, + 1912, + 173, + 1910 + ], + "text": "Do not Jostle Box. Unpack carefully. Enjoy.", + "words": [ + { + "boundingBox": [ + 176, + 1883, + 209, + 1882, + 208, + 1907, + 174, + 1906 + ], + "text": "Do", + "confidence": 0.959 + }, + { + "boundingBox": [ + 215, + 1882, + 261, + 1881, + 260, + 1908, + 214, + 1907 + ], + "text": "not", + "confidence": 0.951 + }, + { + "boundingBox": [ + 266, + 1881, + 336, + 1881, + 335, + 1909, + 265, + 1908 + ], + "text": "Jostle", + "confidence": 0.958 + }, + { + "boundingBox": [ + 342, + 1881, + 403, + 1880, + 402, + 1910, + 341, + 1909 + ], + "text": "Box.", + "confidence": 0.892 + }, + { + "boundingBox": [ + 410, + 1880, + 504, + 1880, + 503, + 1912, + 408, + 1911 + ], + "text": "Unpack", + "confidence": 0.959 + }, + { + "boundingBox": [ + 510, + 1880, + 628, + 1880, + 627, + 1913, + 509, + 1912 + ], + "text": "carefully.", + "confidence": 0.958 + }, + { + "boundingBox": [ + 633, + 1880, + 705, + 1881, + 704, + 1913, + 632, + 1913 + ], + "text": "Enjoy.", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1923, + 1508, + 1924, + 1508, + 1959, + 172, + 1959 + ], + "text": "Jupiter Book Supply will refund you 50% per book if returned within 60 days of reading and", + "words": [ + { + "boundingBox": [ + 172, + 1925, + 273, + 1925, + 273, + 1959, + 172, + 1959 + ], + "text": "Jupiter", + "confidence": 0.955 + }, + { + "boundingBox": [ + 280, + 1924, + 359, + 1924, + 359, + 1959, + 280, + 1959 + ], + "text": "Book", + "confidence": 0.959 + }, + { + "boundingBox": [ + 366, + 1924, + 468, + 1924, + 467, + 1959, + 366, + 1959 + ], + "text": "Supply", + "confidence": 0.959 + }, + { + "boundingBox": [ + 474, + 1924, + 522, + 1924, + 521, + 1959, + 474, + 1959 + ], + "text": "will", + "confidence": 0.959 + }, + { + "boundingBox": [ + 529, + 1924, + 628, + 1924, + 628, + 1959, + 528, + 1959 + ], + "text": "refund", + "confidence": 0.958 + }, + { + "boundingBox": [ + 635, + 1924, + 692, + 1924, + 691, + 1959, + 634, + 1959 + ], + "text": "you", + "confidence": 0.958 + }, + { + "boundingBox": [ + 698, + 1924, + 762, + 1924, + 761, + 1959, + 698, + 1959 + ], + "text": "50%", + "confidence": 0.955 + }, + { + "boundingBox": [ + 773, + 1924, + 823, + 1924, + 822, + 1959, + 772, + 1959 + ], + "text": "per", + "confidence": 0.958 + }, + { + "boundingBox": [ + 830, + 1924, + 904, + 1924, + 903, + 1959, + 829, + 1959 + ], + "text": "book", + "confidence": 0.959 + }, + { + "boundingBox": [ + 911, + 1924, + 932, + 1924, + 931, + 1959, + 910, + 1959 + ], + "text": "if", + "confidence": 0.909 + }, + { + "boundingBox": [ + 938, + 1924, + 1065, + 1924, + 1064, + 1959, + 937, + 1959 + ], + "text": "returned", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1072, + 1924, + 1160, + 1924, + 1159, + 1959, + 1071, + 1959 + ], + "text": "within", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1167, + 1924, + 1208, + 1924, + 1206, + 1960, + 1166, + 1959 + ], + "text": "60", + "confidence": 0.929 + }, + { + "boundingBox": [ + 1215, + 1924, + 1287, + 1924, + 1285, + 1960, + 1213, + 1960 + ], + "text": "days", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1294, + 1924, + 1323, + 1924, + 1322, + 1960, + 1292, + 1960 + ], + "text": "of", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1330, + 1924, + 1443, + 1924, + 1441, + 1960, + 1328, + 1960 + ], + "text": "reading", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1450, + 1924, + 1508, + 1924, + 1506, + 1960, + 1448, + 1960 + ], + "text": "and", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 169, + 1957, + 786, + 1957, + 786, + 1993, + 169, + 1993 + ], + "text": "offer you 25% off you next total purchase.", + "words": [ + { + "boundingBox": [ + 171, + 1959, + 239, + 1958, + 238, + 1992, + 170, + 1991 + ], + "text": "offer", + "confidence": 0.959 + }, + { + "boundingBox": [ + 245, + 1958, + 302, + 1958, + 300, + 1993, + 244, + 1992 + ], + "text": "you", + "confidence": 0.959 + }, + { + "boundingBox": [ + 308, + 1958, + 371, + 1958, + 369, + 1994, + 307, + 1993 + ], + "text": "25%", + "confidence": 0.934 + }, + { + "boundingBox": [ + 385, + 1958, + 425, + 1958, + 424, + 1994, + 384, + 1994 + ], + "text": "off", + "confidence": 0.958 + }, + { + "boundingBox": [ + 431, + 1958, + 488, + 1958, + 487, + 1994, + 430, + 1994 + ], + "text": "you", + "confidence": 0.959 + }, + { + "boundingBox": [ + 494, + 1958, + 559, + 1958, + 558, + 1994, + 493, + 1994 + ], + "text": "next", + "confidence": 0.959 + }, + { + "boundingBox": [ + 565, + 1958, + 632, + 1959, + 631, + 1993, + 564, + 1994 + ], + "text": "total", + "confidence": 0.959 + }, + { + "boundingBox": [ + 638, + 1959, + 785, + 1960, + 785, + 1990, + 637, + 1993 + ], + "text": "purchase.", + "confidence": 0.959 + } + ] + } + ] + } + ], + "pageResults": [ + { + "page": 1, + "tables": [ + { + "rows": 4, + "columns": 3, + "cells": [ + { + "rowIndex": 1, + "columnIndex": 1, + "text": "SUBTOTAL", + "boundingBox": [ + 1072, + 1566, + 1309, + 1566, + 1309, + 1610, + 1072, + 1610 + ], + "elements": [ + "#/readResults/0/lines/41/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "$140.00", + "boundingBox": [ + 1309, + 1566, + 1544, + 1566, + 1544, + 1610, + 1309, + 1610 + ], + "elements": [ + "#/readResults/0/lines/42/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "TAX", + "boundingBox": [ + 1072, + 1610, + 1309, + 1610, + 1309, + 1658, + 1072, + 1658 + ], + "elements": [ + "#/readResults/0/lines/43/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "$4.00", + "boundingBox": [ + 1309, + 1610, + 1544, + 1610, + 1544, + 1658, + 1309, + 1658 + ], + "elements": [ + "#/readResults/0/lines/44/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "Bernie Sanders", + "boundingBox": [ + 482, + 1658, + 1072, + 1658, + 1072, + 1708, + 482, + 1708 + ], + "elements": [ + "#/readResults/0/lines/45/words/0", + "#/readResults/0/lines/45/words/1" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "TOTAL", + "boundingBox": [ + 1072, + 1658, + 1309, + 1658, + 1309, + 1708, + 1072, + 1708 + ], + "elements": [ + "#/readResults/0/lines/46/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "$144.00", + "boundingBox": [ + 1309, + 1658, + 1544, + 1658, + 1544, + 1708, + 1309, + 1708 + ], + "elements": [ + "#/readResults/0/lines/47/words/0" + ] + } + ] + }, + { + "rows": 6, + "columns": 4, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Details", + "boundingBox": [ + 156, + 1038, + 847, + 1038, + 847, + 1087, + 156, + 1087 + ], + "elements": [ + "#/readResults/0/lines/21/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 1, + "text": "Quantity", + "boundingBox": [ + 847, + 1038, + 1072, + 1038, + 1072, + 1087, + 847, + 1087 + ], + "elements": [ + "#/readResults/0/lines/22/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 2, + "text": "Unit Price", + "boundingBox": [ + 1072, + 1038, + 1309, + 1038, + 1309, + 1087, + 1072, + 1087 + ], + "elements": [ + "#/readResults/0/lines/23/words/0", + "#/readResults/0/lines/23/words/1" + ] + }, + { + "rowIndex": 0, + "columnIndex": 3, + "text": "Total", + "boundingBox": [ + 1309, + 1038, + 1544, + 1038, + 1544, + 1087, + 1309, + 1087 + ], + "elements": [ + "#/readResults/0/lines/24/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Bindings", + "boundingBox": [ + 156, + 1087, + 847, + 1087, + 847, + 1128, + 156, + 1128 + ], + "elements": [ + "#/readResults/0/lines/25/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1087, + 1072, + 1087, + 1072, + 1128, + 847, + 1128 + ], + "elements": [ + "#/readResults/0/lines/26/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "1.00", + "boundingBox": [ + 1072, + 1087, + 1309, + 1087, + 1309, + 1128, + 1072, + 1128 + ], + "elements": [ + "#/readResults/0/lines/27/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 3, + "text": "20.00", + "boundingBox": [ + 1309, + 1087, + 1544, + 1087, + 1544, + 1128, + 1309, + 1128 + ], + "elements": [ + "#/readResults/0/lines/28/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Covers Small", + "boundingBox": [ + 156, + 1128, + 847, + 1128, + 847, + 1172, + 156, + 1172 + ], + "elements": [ + "#/readResults/0/lines/29/words/0", + "#/readResults/0/lines/29/words/1" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1128, + 1072, + 1128, + 1072, + 1172, + 847, + 1172 + ], + "elements": [ + "#/readResults/0/lines/30/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "1.00", + "boundingBox": [ + 1072, + 1128, + 1309, + 1128, + 1309, + 1172, + 1072, + 1172 + ], + "elements": [ + "#/readResults/0/lines/31/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 3, + "text": "20.00", + "boundingBox": [ + 1309, + 1128, + 1544, + 1128, + 1544, + 1172, + 1309, + 1172 + ], + "elements": [ + "#/readResults/0/lines/32/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "Feather Bookmark", + "boundingBox": [ + 156, + 1172, + 847, + 1172, + 847, + 1216, + 156, + 1216 + ], + "elements": [ + "#/readResults/0/lines/33/words/0", + "#/readResults/0/lines/33/words/1" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1172, + 1072, + 1172, + 1072, + 1216, + 847, + 1216 + ], + "elements": [ + "#/readResults/0/lines/34/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "5,00", + "boundingBox": [ + 1072, + 1172, + 1309, + 1172, + 1309, + 1216, + 1072, + 1216 + ], + "elements": [ + "#/readResults/0/lines/35/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1172, + 1544, + 1172, + 1544, + 1216, + 1309, + 1216 + ], + "elements": [ + "#/readResults/0/lines/36/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 0, + "text": "Copper Swirl Marker", + "boundingBox": [ + 156, + 1216, + 847, + 1216, + 847, + 1260, + 156, + 1260 + ], + "elements": [ + "#/readResults/0/lines/37/words/0", + "#/readResults/0/lines/37/words/1", + "#/readResults/0/lines/37/words/2" + ] + }, + { + "rowIndex": 4, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1216, + 1072, + 1216, + 1072, + 1260, + 847, + 1260 + ], + "elements": [ + "#/readResults/0/lines/38/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 2, + "text": "5,00", + "boundingBox": [ + 1072, + 1216, + 1309, + 1216, + 1309, + 1260, + 1072, + 1260 + ], + "elements": [ + "#/readResults/0/lines/39/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1216, + 1544, + 1216, + 1544, + 1260, + 1309, + 1260 + ], + "elements": [ + "#/readResults/0/lines/40/words/0" + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg new file mode 100644 index 000000000000..afebb5077ce5 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.labels.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.labels.json new file mode 100644 index 000000000000..c33938bceb60 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.labels.json @@ -0,0 +1,495 @@ +{ + "document": "Form_2.jpg", + "labels": [ + { + "label": "Merchant", + "key": null, + "value": [ + { + "page": 1, + "text": "Hero", + "boundingBoxes": [ + [ + 0.3658823529411765, + 0.09409090909090909, + 0.46352941176470586, + 0.09272727272727273, + 0.46294117647058824, + 0.12090909090909091, + 0.3652941176470588, + 0.12090909090909091 + ] + ] + }, + { + "page": 1, + "text": "Limited", + "boundingBoxes": [ + [ + 0.47705882352941176, + 0.09272727272727273, + 0.6323529411764706, + 0.09181818181818181, + 0.6323529411764706, + 0.12090909090909091, + 0.47705882352941176, + 0.12090909090909091 + ] + ] + } + ] + }, + { + "label": "PhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "555-348-6512", + "boundingBoxes": [ + [ + 0.2164705882352941, + 0.15954545454545455, + 0.31176470588235294, + 0.16, + 0.31176470588235294, + 0.17, + 0.2164705882352941, + 0.17181818181818181 + ] + ] + } + ] + }, + { + "label": "Website", + "key": null, + "value": [ + { + "page": 1, + "text": "www.herolimited.com", + "boundingBoxes": [ + [ + 0.1623529411764706, + 0.17863636363636365, + 0.3088235294117647, + 0.17909090909090908, + 0.3088235294117647, + 0.19, + 0.16176470588235295, + 0.19045454545454546 + ] + ] + } + ] + }, + { + "label": "DatedAs", + "key": null, + "value": [ + { + "page": 1, + "text": "02/20/2020", + "boundingBoxes": [ + [ + 0.6858823529411765, + 0.19090909090909092, + 0.7752941176470588, + 0.19090909090909092, + 0.7752941176470588, + 0.20454545454545456, + 0.6858823529411765, + 0.20454545454545456 + ] + ] + } + ] + }, + { + "label": "Email", + "key": null, + "value": [ + { + "page": 1, + "text": "accounts@herolimited.com", + "boundingBoxes": [ + [ + 0.0976470588235294, + 0.22, + 0.27941176470588236, + 0.21818181818181817, + 0.2782352941176471, + 0.22863636363636364, + 0.0976470588235294, + 0.22863636363636364 + ] + ] + } + ] + }, + { + "label": "PurchaseOrderNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "942448", + "boundingBoxes": [ + [ + 0.7547058823529412, + 0.20954545454545453, + 0.8088235294117647, + 0.21, + 0.808235294117647, + 0.22181818181818183, + 0.7541176470588236, + 0.22227272727272726 + ] + ] + } + ] + }, + { + "label": "VendorName", + "key": null, + "value": [ + { + "page": 1, + "text": "Lori", + "boundingBoxes": [ + [ + 0.2076470588235294, + 0.2772727272727273, + 0.23647058823529413, + 0.2772727272727273, + 0.23588235294117646, + 0.29, + 0.20705882352941177, + 0.29 + ] + ] + }, + { + "page": 1, + "text": "Hanke", + "boundingBoxes": [ + [ + 0.23941176470588235, + 0.2772727272727273, + 0.2876470588235294, + 0.2768181818181818, + 0.2876470588235294, + 0.29, + 0.23941176470588235, + 0.29 + ] + ] + } + ] + }, + { + "label": "CompanyName", + "key": null, + "value": [ + { + "page": 1, + "text": "Buzz", + "boundingBoxes": [ + [ + 0.22294117647058823, + 0.29454545454545455, + 0.2576470588235294, + 0.29454545454545455, + 0.2570588235294118, + 0.30863636363636365, + 0.22294117647058823, + 0.30863636363636365 + ] + ] + }, + { + "page": 1, + "text": "Clothing", + "boundingBoxes": [ + [ + 0.2611764705882353, + 0.29454545454545455, + 0.32294117647058823, + 0.29409090909090907, + 0.32235294117647056, + 0.30863636363636365, + 0.2605882352941176, + 0.30863636363636365 + ] + ] + } + ] + }, + { + "label": "CompanyAddress", + "key": null, + "value": [ + { + "page": 1, + "text": "938", + "boundingBoxes": [ + [ + 0.1623529411764706, + 0.31136363636363634, + 0.19176470588235295, + 0.31136363636363634, + 0.19117647058823528, + 0.325, + 0.1623529411764706, + 0.3245454545454545 + ] + ] + }, + { + "page": 1, + "text": "N", + "boundingBoxes": [ + [ + 0.19470588235294117, + 0.31136363636363634, + 0.20470588235294118, + 0.31136363636363634, + 0.20470588235294118, + 0.325, + 0.19411764705882353, + 0.325 + ] + ] + }, + { + "page": 1, + "text": "Lumpy", + "boundingBoxes": [ + [ + 0.21, + 0.31136363636363634, + 0.25941176470588234, + 0.3118181818181818, + 0.25941176470588234, + 0.32636363636363636, + 0.21, + 0.32545454545454544 + ] + ] + }, + { + "page": 1, + "text": "Way", + "boundingBoxes": [ + [ + 0.26294117647058823, + 0.3118181818181818, + 0.2952941176470588, + 0.31227272727272726, + 0.29470588235294115, + 0.32727272727272727, + 0.26235294117647057, + 0.32636363636363636 + ] + ] + }, + { + "page": 1, + "text": "Denver,", + "boundingBoxes": [ + [ + 0.16470588235294117, + 0.3286363636363636, + 0.2223529411764706, + 0.3281818181818182, + 0.22176470588235295, + 0.34136363636363637, + 0.16411764705882353, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "CO", + "boundingBoxes": [ + [ + 0.2252941176470588, + 0.3281818181818182, + 0.24529411764705883, + 0.3281818181818182, + 0.2447058823529412, + 0.34136363636363637, + 0.22470588235294117, + 0.34136363636363637 + ] + ] + }, + { + "page": 1, + "text": "83757", + "boundingBoxes": [ + [ + 0.25, + 0.3281818181818182, + 0.2952941176470588, + 0.3281818181818182, + 0.29470588235294115, + 0.34136363636363637, + 0.24941176470588236, + 0.34136363636363637 + ] + ] + } + ] + }, + { + "label": "CompanyPhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "435-395-3954", + "boundingBoxes": [ + [ + 0.43941176470588234, + 0.3281818181818182, + 0.54, + 0.3281818181818182, + 0.5394117647058824, + 0.34045454545454545, + 0.43941176470588234, + 0.3409090909090909 + ] + ] + } + ] + }, + { + "label": "Quantity", + "key": null, + "value": [ + { + "page": 1, + "text": "10", + "boundingBoxes": [ + [ + 0.508235294117647, + 0.49772727272727274, + 0.5252941176470588, + 0.49727272727272726, + 0.5258823529411765, + 0.5081818181818182, + 0.508235294117647, + 0.5086363636363637 + ] + ] + } + ] + }, + { + "label": "Subtotal", + "key": null, + "value": [ + { + "page": 1, + "text": "$600.00", + "boundingBoxes": [ + [ + 0.8411764705882353, + 0.7145454545454546, + 0.9, + 0.7136363636363636, + 0.8994117647058824, + 0.7263636363636363, + 0.8411764705882353, + 0.7268181818181818 + ] + ] + } + ] + }, + { + "label": "Tax", + "key": null, + "value": [ + { + "page": 1, + "text": "$20.00", + "boundingBoxes": [ + [ + 0.8494117647058823, + 0.735, + 0.9005882352941177, + 0.7336363636363636, + 0.9005882352941177, + 0.7463636363636363, + 0.8494117647058823, + 0.7472727272727273 + ] + ] + } + ] + }, + { + "label": "Signature", + "key": null, + "value": [ + { + "page": 1, + "text": "Frank", + "boundingBoxes": [ + [ + 0.29352941176470587, + 0.7622727272727273, + 0.3558823529411765, + 0.7618181818181818, + 0.3558823529411765, + 0.7781818181818182, + 0.29294117647058826, + 0.7781818181818182 + ] + ] + }, + { + "page": 1, + "text": "Sinatra", + "boundingBoxes": [ + [ + 0.36411764705882355, + 0.7618181818181818, + 0.4435294117647059, + 0.7622727272727273, + 0.4435294117647059, + 0.7781818181818182, + 0.3635294117647059, + 0.7781818181818182 + ] + ] + } + ] + }, + { + "label": "Total", + "key": null, + "value": [ + { + "page": 1, + "text": "$620.00", + "boundingBoxes": [ + [ + 0.84, + 0.7595454545454545, + 0.9, + 0.759090909090909, + 0.9, + 0.7709090909090909, + 0.84, + 0.7722727272727272 + ] + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.ocr.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.ocr.json new file mode 100644 index 000000000000..cba95d44cab0 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_2.jpg.ocr.json @@ -0,0 +1,3677 @@ +{ + "status": "succeeded", + "createdDateTime": "2020-04-09T01:37:21Z", + "lastUpdatedDateTime": "2020-04-09T01:37:24Z", + "analyzeResult": { + "version": "2.0.0", + "readResults": [ + { + "page": 1, + "language": "en", + "angle": 0, + "width": 1700, + "height": 2200, + "unit": "pixel", + "lines": [ + { + "language": "en", + "boundingBox": [ + 137, + 140, + 351, + 140, + 351, + 167, + 137, + 166 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 137, + 140, + 263, + 140, + 263, + 168, + 138, + 166 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 271, + 140, + 351, + 140, + 351, + 168, + 272, + 168 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 620, + 204, + 1073, + 201, + 1074, + 264, + 620, + 266 + ], + "text": "Hero Limited", + "words": [ + { + "boundingBox": [ + 622, + 207, + 788, + 204, + 787, + 266, + 621, + 266 + ], + "text": "Hero", + "confidence": 0.959 + }, + { + "boundingBox": [ + 811, + 204, + 1075, + 202, + 1075, + 266, + 811, + 266 + ], + "text": "Limited", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 351, + 529, + 350, + 529, + 376, + 165, + 379 + ], + "text": "Company Phone: 555-348-6512", + "words": [ + { + "boundingBox": [ + 167, + 352, + 277, + 351, + 276, + 379, + 167, + 379 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 282, + 351, + 363, + 351, + 363, + 378, + 282, + 379 + ], + "text": "Phone:", + "confidence": 0.937 + }, + { + "boundingBox": [ + 368, + 351, + 530, + 352, + 530, + 374, + 368, + 378 + ], + "text": "555-348-6512", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 320, + 1551, + 320, + 1551, + 370, + 1114, + 370 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 1115, + 322, + 1377, + 320, + 1377, + 371, + 1117, + 371 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1396, + 321, + 1550, + 321, + 1549, + 371, + 1396, + 371 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 392, + 529, + 393, + 529, + 419, + 167, + 418 + ], + "text": "Website: www.herolimited.com", + "words": [ + { + "boundingBox": [ + 168, + 392, + 271, + 393, + 270, + 419, + 167, + 418 + ], + "text": "Website:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 276, + 393, + 525, + 394, + 525, + 418, + 275, + 419 + ], + "text": "www.herolimited.com", + "confidence": 0.829 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 437, + 236, + 437, + 236, + 459, + 164, + 459 + ], + "text": "Email:", + "words": [ + { + "boundingBox": [ + 165, + 437, + 236, + 437, + 236, + 460, + 165, + 459 + ], + "text": "Email:", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 419, + 1317, + 419, + 1317, + 449, + 1025, + 449 + ], + "text": "Dated As: 02/20/2020", + "words": [ + { + "boundingBox": [ + 1026, + 420, + 1111, + 420, + 1110, + 450, + 1025, + 450 + ], + "text": "Dated", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1119, + 420, + 1161, + 420, + 1160, + 450, + 1118, + 450 + ], + "text": "As:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1166, + 420, + 1318, + 420, + 1318, + 450, + 1166, + 450 + ], + "text": "02/20/2020", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 480, + 482, + 479, + 482, + 502, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "words": [ + { + "boundingBox": [ + 166, + 484, + 475, + 480, + 473, + 503, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "confidence": 0.856 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 461, + 1375, + 461, + 1375, + 488, + 1025, + 490 + ], + "text": "Purchase Order #: 942448", + "words": [ + { + "boundingBox": [ + 1027, + 462, + 1154, + 461, + 1153, + 490, + 1026, + 489 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1161, + 461, + 1241, + 461, + 1240, + 490, + 1160, + 490 + ], + "text": "Order", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1246, + 461, + 1278, + 461, + 1277, + 489, + 1245, + 490 + ], + "text": "#:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1283, + 461, + 1375, + 462, + 1374, + 488, + 1282, + 489 + ], + "text": "942448", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 546, + 395, + 546, + 395, + 594, + 166, + 594 + ], + "text": "Shipped To", + "words": [ + { + "boundingBox": [ + 167, + 546, + 340, + 548, + 340, + 593, + 168, + 595 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 349, + 548, + 396, + 547, + 396, + 593, + 349, + 593 + ], + "text": "To", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 609, + 490, + 609, + 490, + 637, + 160, + 638 + ], + "text": "Vendor Name: Lori Hanke", + "words": [ + { + "boundingBox": [ + 162, + 610, + 256, + 610, + 255, + 639, + 160, + 638 + ], + "text": "Vendor", + "confidence": 0.959 + }, + { + "boundingBox": [ + 262, + 610, + 347, + 610, + 347, + 638, + 261, + 639 + ], + "text": "Name:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 353, + 610, + 402, + 610, + 401, + 638, + 352, + 638 + ], + "text": "Lori", + "confidence": 0.958 + }, + { + "boundingBox": [ + 407, + 610, + 489, + 609, + 489, + 638, + 407, + 638 + ], + "text": "Hanke", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 647, + 549, + 647, + 549, + 678, + 160, + 678 + ], + "text": "Company Name: Buzz Clothing", + "words": [ + { + "boundingBox": [ + 161, + 648, + 282, + 648, + 281, + 679, + 160, + 679 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 288, + 648, + 373, + 648, + 372, + 679, + 287, + 679 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 379, + 648, + 438, + 648, + 437, + 679, + 379, + 679 + ], + "text": "Buzz", + "confidence": 0.959 + }, + { + "boundingBox": [ + 444, + 648, + 549, + 647, + 548, + 679, + 443, + 679 + ], + "text": "Clothing", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 161, + 684, + 502, + 686, + 501, + 719, + 161, + 714 + ], + "text": "Address: 938 N Lumpy Way", + "words": [ + { + "boundingBox": [ + 162, + 685, + 271, + 685, + 271, + 714, + 162, + 712 + ], + "text": "Address:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 276, + 685, + 326, + 685, + 325, + 715, + 276, + 714 + ], + "text": "938", + "confidence": 0.85 + }, + { + "boundingBox": [ + 331, + 685, + 348, + 685, + 348, + 715, + 330, + 715 + ], + "text": "N", + "confidence": 0.878 + }, + { + "boundingBox": [ + 357, + 685, + 441, + 686, + 441, + 718, + 357, + 716 + ], + "text": "Lumpy", + "confidence": 0.959 + }, + { + "boundingBox": [ + 447, + 686, + 502, + 687, + 501, + 720, + 446, + 718 + ], + "text": "Way", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 278, + 722, + 503, + 722, + 503, + 750, + 278, + 750 + ], + "text": "Denver, CO 83757", + "words": [ + { + "boundingBox": [ + 280, + 723, + 378, + 722, + 377, + 751, + 279, + 749 + ], + "text": "Denver,", + "confidence": 0.959 + }, + { + "boundingBox": [ + 383, + 722, + 417, + 722, + 416, + 751, + 382, + 751 + ], + "text": "CO", + "confidence": 0.909 + }, + { + "boundingBox": [ + 425, + 722, + 502, + 722, + 501, + 751, + 424, + 751 + ], + "text": "83757", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 647, + 721, + 918, + 721, + 918, + 749, + 647, + 749 + ], + "text": "Phone: 435-395-3954", + "words": [ + { + "boundingBox": [ + 648, + 722, + 742, + 722, + 742, + 750, + 647, + 749 + ], + "text": "Phone:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 747, + 722, + 918, + 722, + 917, + 749, + 747, + 750 + ], + "text": "435-395-3954", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 783, + 451, + 783, + 451, + 826, + 166, + 830 + ], + "text": "Shipped From", + "words": [ + { + "boundingBox": [ + 167, + 784, + 334, + 784, + 333, + 829, + 166, + 830 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 343, + 784, + 440, + 784, + 439, + 824, + 342, + 828 + ], + "text": "From", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 850, + 420, + 850, + 420, + 880, + 165, + 880 + ], + "text": "Name: Frank Sinatra", + "words": [ + { + "boundingBox": [ + 166, + 851, + 251, + 853, + 250, + 880, + 165, + 881 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 257, + 853, + 328, + 853, + 327, + 879, + 256, + 880 + ], + "text": "Frank", + "confidence": 0.959 + }, + { + "boundingBox": [ + 334, + 853, + 421, + 852, + 420, + 881, + 333, + 879 + ], + "text": "Sinatra", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 890, + 551, + 889, + 551, + 916, + 164, + 920 + ], + "text": "Company Name: Franks Goods", + "words": [ + { + "boundingBox": [ + 167, + 891, + 287, + 891, + 286, + 920, + 166, + 920 + ], + "text": "Company", + "confidence": 0.958 + }, + { + "boundingBox": [ + 293, + 891, + 379, + 890, + 378, + 919, + 292, + 919 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 385, + 890, + 466, + 890, + 465, + 917, + 384, + 918 + ], + "text": "Franks", + "confidence": 0.959 + }, + { + "boundingBox": [ + 471, + 890, + 551, + 889, + 550, + 915, + 470, + 917 + ], + "text": "Goods", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 926, + 505, + 926, + 505, + 953, + 167, + 953 + ], + "text": "Address: 838 NE Grail Road", + "words": [ + { + "boundingBox": [ + 169, + 927, + 277, + 927, + 276, + 954, + 168, + 953 + ], + "text": "Address:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 282, + 927, + 329, + 927, + 329, + 954, + 281, + 954 + ], + "text": "838", + "confidence": 0.958 + }, + { + "boundingBox": [ + 335, + 927, + 372, + 927, + 371, + 954, + 334, + 954 + ], + "text": "NE", + "confidence": 0.958 + }, + { + "boundingBox": [ + 377, + 927, + 435, + 927, + 435, + 953, + 377, + 954 + ], + "text": "Grail", + "confidence": 0.959 + }, + { + "boundingBox": [ + 440, + 927, + 504, + 927, + 504, + 953, + 440, + 953 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 276, + 964, + 560, + 962, + 560, + 994, + 276, + 996 + ], + "text": "Bellingham, WA 83748", + "words": [ + { + "boundingBox": [ + 277, + 965, + 421, + 963, + 421, + 996, + 277, + 996 + ], + "text": "Bellingham,", + "confidence": 0.941 + }, + { + "boundingBox": [ + 428, + 963, + 473, + 963, + 473, + 995, + 427, + 996 + ], + "text": "WA", + "confidence": 0.957 + }, + { + "boundingBox": [ + 480, + 963, + 560, + 962, + 559, + 995, + 479, + 995 + ], + "text": "83748", + "confidence": 0.953 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 681, + 962, + 956, + 961, + 956, + 992, + 682, + 994 + ], + "text": "Phone: 939-492-9595", + "words": [ + { + "boundingBox": [ + 683, + 964, + 775, + 962, + 775, + 993, + 683, + 995 + ], + "text": "Phone:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 781, + 962, + 955, + 962, + 955, + 993, + 781, + 993 + ], + "text": "939-492-9595", + "confidence": 0.936 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 447, + 1045, + 557, + 1045, + 557, + 1079, + 447, + 1079 + ], + "text": "Details", + "words": [ + { + "boundingBox": [ + 448, + 1048, + 556, + 1046, + 557, + 1080, + 449, + 1079 + ], + "text": "Details", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 889, + 1045, + 1032, + 1047, + 1031, + 1085, + 889, + 1083 + ], + "text": "Quantity", + "words": [ + { + "boundingBox": [ + 890, + 1046, + 1032, + 1047, + 1032, + 1085, + 891, + 1083 + ], + "text": "Quantity", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 1046, + 1271, + 1047, + 1271, + 1078, + 1114, + 1077 + ], + "text": "Unit Price", + "words": [ + { + "boundingBox": [ + 1114, + 1047, + 1184, + 1047, + 1184, + 1078, + 1114, + 1077 + ], + "text": "Unit", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1047, + 1272, + 1047, + 1272, + 1079, + 1190, + 1078 + ], + "text": "Price", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1384, + 1047, + 1469, + 1046, + 1470, + 1076, + 1384, + 1077 + ], + "text": "Total", + "words": [ + { + "boundingBox": [ + 1387, + 1046, + 1468, + 1046, + 1469, + 1076, + 1387, + 1077 + ], + "text": "Total", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1093, + 356, + 1094, + 356, + 1124, + 169, + 1123 + ], + "text": "Crow keychain", + "words": [ + { + "boundingBox": [ + 172, + 1093, + 233, + 1094, + 232, + 1124, + 171, + 1123 + ], + "text": "Crow", + "confidence": 0.959 + }, + { + "boundingBox": [ + 243, + 1094, + 357, + 1094, + 356, + 1125, + 242, + 1124 + ], + "text": "keychain", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 862, + 1095, + 894, + 1094, + 894, + 1118, + 862, + 1119 + ], + "text": "10", + "words": [ + { + "boundingBox": [ + 864, + 1095, + 893, + 1094, + 894, + 1118, + 864, + 1119 + ], + "text": "10", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1224, + 1094, + 1296, + 1093, + 1296, + 1118, + 1224, + 1120 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1096, + 1295, + 1094, + 1295, + 1119, + 1227, + 1119 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1095, + 1531, + 1093, + 1532, + 1118, + 1443, + 1120 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1445, + 1096, + 1528, + 1094, + 1528, + 1118, + 1445, + 1120 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1133, + 387, + 1133, + 386, + 1167, + 170, + 1167 + ], + "text": "Batman keychain", + "words": [ + { + "boundingBox": [ + 172, + 1135, + 268, + 1135, + 267, + 1165, + 170, + 1165 + ], + "text": "Batman", + "confidence": 0.959 + }, + { + "boundingBox": [ + 274, + 1135, + 386, + 1134, + 385, + 1168, + 273, + 1165 + ], + "text": "keychain", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1137, + 893, + 1135, + 893, + 1158, + 862, + 1160 + ], + "text": "10", + "words": [ + { + "boundingBox": [ + 863, + 1137, + 891, + 1135, + 893, + 1158, + 864, + 1160 + ], + "text": "10", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1225, + 1136, + 1296, + 1134, + 1296, + 1158, + 1225, + 1159 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1135, + 1295, + 1134, + 1295, + 1158, + 1227, + 1159 + ], + "text": "10.00", + "confidence": 0.57 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1136, + 1531, + 1135, + 1531, + 1159, + 1443, + 1159 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1446, + 1136, + 1529, + 1136, + 1529, + 1159, + 1445, + 1160 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1178, + 347, + 1178, + 346, + 1208, + 168, + 1208 + ], + "text": "Skull keychain", + "words": [ + { + "boundingBox": [ + 171, + 1178, + 229, + 1178, + 228, + 1209, + 169, + 1209 + ], + "text": "Skull", + "confidence": 0.959 + }, + { + "boundingBox": [ + 235, + 1179, + 347, + 1179, + 346, + 1209, + 234, + 1209 + ], + "text": "keychain", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1180, + 893, + 1178, + 893, + 1202, + 862, + 1204 + ], + "text": "10", + "words": [ + { + "boundingBox": [ + 863, + 1180, + 892, + 1178, + 894, + 1202, + 864, + 1204 + ], + "text": "10", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1223, + 1180, + 1295, + 1179, + 1296, + 1203, + 1223, + 1204 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1226, + 1180, + 1295, + 1180, + 1294, + 1203, + 1226, + 1204 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1180, + 1532, + 1180, + 1532, + 1203, + 1443, + 1204 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1446, + 1181, + 1529, + 1180, + 1528, + 1203, + 1446, + 1204 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1221, + 378, + 1221, + 378, + 1252, + 170, + 1252 + ], + "text": "Moose keychain", + "words": [ + { + "boundingBox": [ + 172, + 1222, + 256, + 1222, + 254, + 1252, + 170, + 1252 + ], + "text": "Moose", + "confidence": 0.959 + }, + { + "boundingBox": [ + 262, + 1222, + 377, + 1221, + 375, + 1253, + 260, + 1252 + ], + "text": "keychain", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1223, + 893, + 1222, + 893, + 1246, + 861, + 1247 + ], + "text": "10", + "words": [ + { + "boundingBox": [ + 863, + 1223, + 892, + 1222, + 893, + 1246, + 863, + 1247 + ], + "text": "10", + "confidence": 0.945 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1224, + 1222, + 1295, + 1223, + 1295, + 1246, + 1223, + 1246 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1222, + 1295, + 1222, + 1295, + 1246, + 1227, + 1246 + ], + "text": "10.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1223, + 1531, + 1223, + 1531, + 1247, + 1443, + 1247 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1445, + 1223, + 1530, + 1223, + 1530, + 1248, + 1445, + 1248 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1264, + 400, + 1264, + 400, + 1297, + 168, + 1297 + ], + "text": "Sodapop keychain", + "words": [ + { + "boundingBox": [ + 170, + 1265, + 279, + 1267, + 279, + 1298, + 170, + 1297 + ], + "text": "Sodapop", + "confidence": 0.959 + }, + { + "boundingBox": [ + 286, + 1267, + 400, + 1264, + 399, + 1298, + 285, + 1298 + ], + "text": "keychain", + "confidence": 0.948 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 862, + 1267, + 892, + 1266, + 893, + 1289, + 862, + 1290 + ], + "text": "10", + "words": [ + { + "boundingBox": [ + 864, + 1266, + 892, + 1266, + 892, + 1289, + 864, + 1290 + ], + "text": "10", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1226, + 1266, + 1296, + 1266, + 1296, + 1289, + 1226, + 1290 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1266, + 1295, + 1266, + 1295, + 1290, + 1227, + 1290 + ], + "text": "10.00", + "confidence": 0.946 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1267, + 1531, + 1266, + 1531, + 1290, + 1443, + 1291 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1444, + 1267, + 1531, + 1266, + 1530, + 1291, + 1445, + 1292 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1148, + 1574, + 1295, + 1574, + 1295, + 1600, + 1148, + 1599 + ], + "text": "SUBTOTAL", + "words": [ + { + "boundingBox": [ + 1149, + 1574, + 1296, + 1575, + 1295, + 1600, + 1149, + 1600 + ], + "text": "SUBTOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1429, + 1571, + 1530, + 1570, + 1530, + 1597, + 1429, + 1599 + ], + "text": "$600.00", + "words": [ + { + "boundingBox": [ + 1430, + 1572, + 1530, + 1570, + 1529, + 1598, + 1430, + 1599 + ], + "text": "$600.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1238, + 1619, + 1295, + 1619, + 1295, + 1642, + 1237, + 1642 + ], + "text": "TAX", + "words": [ + { + "boundingBox": [ + 1241, + 1619, + 1293, + 1619, + 1293, + 1642, + 1241, + 1642 + ], + "text": "TAX", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1442, + 1616, + 1530, + 1614, + 1531, + 1641, + 1442, + 1643 + ], + "text": "$20.00", + "words": [ + { + "boundingBox": [ + 1444, + 1617, + 1531, + 1614, + 1531, + 1642, + 1444, + 1644 + ], + "text": "$20.00", + "confidence": 0.914 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 494, + 1676, + 756, + 1676, + 756, + 1711, + 494, + 1711 + ], + "text": "Frank Sinatra", + "words": [ + { + "boundingBox": [ + 499, + 1677, + 605, + 1676, + 605, + 1712, + 498, + 1712 + ], + "text": "Frank", + "confidence": 0.844 + }, + { + "boundingBox": [ + 619, + 1676, + 754, + 1677, + 754, + 1712, + 618, + 1712 + ], + "text": "Sinatra", + "confidence": 0.915 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1204, + 1672, + 1296, + 1672, + 1296, + 1699, + 1204, + 1699 + ], + "text": "TOTAL", + "words": [ + { + "boundingBox": [ + 1207, + 1674, + 1295, + 1673, + 1296, + 1700, + 1207, + 1699 + ], + "text": "TOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1426, + 1670, + 1530, + 1669, + 1531, + 1696, + 1426, + 1699 + ], + "text": "$620.00", + "words": [ + { + "boundingBox": [ + 1428, + 1671, + 1530, + 1670, + 1530, + 1696, + 1428, + 1699 + ], + "text": "$620.00", + "confidence": 0.945 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 555, + 1718, + 706, + 1718, + 706, + 1742, + 555, + 1742 + ], + "text": "Frank Sinatra", + "words": [ + { + "boundingBox": [ + 555, + 1719, + 621, + 1719, + 621, + 1743, + 555, + 1743 + ], + "text": "Frank", + "confidence": 0.959 + }, + { + "boundingBox": [ + 626, + 1719, + 706, + 1719, + 706, + 1743, + 626, + 1743 + ], + "text": "Sinatra", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 591, + 1754, + 670, + 1754, + 670, + 1776, + 591, + 1775 + ], + "text": "Owner", + "words": [ + { + "boundingBox": [ + 592, + 1755, + 670, + 1755, + 670, + 1777, + 592, + 1776 + ], + "text": "Owner", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1796, + 480, + 1797, + 479, + 1832, + 173, + 1830 + ], + "text": "Additional Notes:", + "words": [ + { + "boundingBox": [ + 175, + 1798, + 359, + 1797, + 358, + 1833, + 174, + 1830 + ], + "text": "Additional", + "confidence": 0.959 + }, + { + "boundingBox": [ + 365, + 1797, + 480, + 1800, + 480, + 1832, + 365, + 1833 + ], + "text": "Notes:", + "confidence": 0.94 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1878, + 1456, + 1879, + 1456, + 1914, + 173, + 1911 + ], + "text": "Have fun with your new keychains. Franks offers the simplest products at the highest quality.", + "words": [ + { + "boundingBox": [ + 174, + 1881, + 238, + 1881, + 238, + 1908, + 174, + 1908 + ], + "text": "Have", + "confidence": 0.959 + }, + { + "boundingBox": [ + 243, + 1881, + 285, + 1880, + 285, + 1909, + 243, + 1908 + ], + "text": "fun", + "confidence": 0.958 + }, + { + "boundingBox": [ + 291, + 1880, + 347, + 1880, + 346, + 1909, + 290, + 1909 + ], + "text": "with", + "confidence": 0.959 + }, + { + "boundingBox": [ + 354, + 1880, + 410, + 1880, + 409, + 1910, + 353, + 1909 + ], + "text": "your", + "confidence": 0.959 + }, + { + "boundingBox": [ + 415, + 1880, + 466, + 1879, + 466, + 1910, + 415, + 1910 + ], + "text": "new", + "confidence": 0.958 + }, + { + "boundingBox": [ + 475, + 1879, + 612, + 1879, + 611, + 1911, + 474, + 1910 + ], + "text": "keychains.", + "confidence": 0.92 + }, + { + "boundingBox": [ + 617, + 1879, + 720, + 1879, + 720, + 1912, + 616, + 1911 + ], + "text": "Franks", + "confidence": 0.959 + }, + { + "boundingBox": [ + 727, + 1878, + 813, + 1878, + 813, + 1912, + 727, + 1912 + ], + "text": "offers", + "confidence": 0.958 + }, + { + "boundingBox": [ + 820, + 1878, + 866, + 1878, + 865, + 1912, + 820, + 1912 + ], + "text": "the", + "confidence": 0.956 + }, + { + "boundingBox": [ + 876, + 1878, + 1003, + 1878, + 1002, + 1913, + 876, + 1913 + ], + "text": "simplest", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1008, + 1878, + 1138, + 1878, + 1137, + 1914, + 1007, + 1913 + ], + "text": "products", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1145, + 1879, + 1176, + 1879, + 1175, + 1914, + 1144, + 1914 + ], + "text": "at", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1182, + 1879, + 1227, + 1879, + 1226, + 1914, + 1181, + 1914 + ], + "text": "the", + "confidence": 0.95 + }, + { + "boundingBox": [ + 1238, + 1879, + 1350, + 1879, + 1349, + 1915, + 1237, + 1914 + ], + "text": "highest", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1355, + 1879, + 1456, + 1880, + 1455, + 1915, + 1354, + 1915 + ], + "text": "quality.", + "confidence": 0.82 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1935, + 1409, + 1936, + 1409, + 1971, + 170, + 1969 + ], + "text": "A 30% off coupon will be issued upon the arrive of your products for your next order.", + "words": [ + { + "boundingBox": [ + 170, + 1936, + 191, + 1936, + 191, + 1966, + 170, + 1966 + ], + "text": "A", + "confidence": 0.828 + }, + { + "boundingBox": [ + 201, + 1936, + 263, + 1936, + 262, + 1967, + 201, + 1966 + ], + "text": "30%", + "confidence": 0.95 + }, + { + "boundingBox": [ + 276, + 1936, + 318, + 1936, + 317, + 1968, + 276, + 1967 + ], + "text": "off", + "confidence": 0.958 + }, + { + "boundingBox": [ + 324, + 1936, + 433, + 1936, + 432, + 1969, + 323, + 1968 + ], + "text": "coupon", + "confidence": 0.959 + }, + { + "boundingBox": [ + 441, + 1936, + 490, + 1936, + 490, + 1970, + 440, + 1969 + ], + "text": "will", + "confidence": 0.959 + }, + { + "boundingBox": [ + 496, + 1936, + 536, + 1936, + 535, + 1970, + 495, + 1970 + ], + "text": "be", + "confidence": 0.958 + }, + { + "boundingBox": [ + 542, + 1936, + 643, + 1936, + 642, + 1971, + 541, + 1970 + ], + "text": "issued", + "confidence": 0.959 + }, + { + "boundingBox": [ + 648, + 1936, + 724, + 1936, + 723, + 1971, + 648, + 1971 + ], + "text": "upon", + "confidence": 0.955 + }, + { + "boundingBox": [ + 732, + 1936, + 781, + 1936, + 780, + 1971, + 731, + 1971 + ], + "text": "the", + "confidence": 0.95 + }, + { + "boundingBox": [ + 789, + 1936, + 874, + 1936, + 873, + 1971, + 788, + 1971 + ], + "text": "arrive", + "confidence": 0.959 + }, + { + "boundingBox": [ + 882, + 1936, + 914, + 1936, + 913, + 1971, + 881, + 1971 + ], + "text": "of", + "confidence": 0.958 + }, + { + "boundingBox": [ + 920, + 1936, + 987, + 1936, + 986, + 1971, + 919, + 1971 + ], + "text": "your", + "confidence": 0.958 + }, + { + "boundingBox": [ + 993, + 1936, + 1123, + 1936, + 1123, + 1970, + 992, + 1971 + ], + "text": "products", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1129, + 1936, + 1173, + 1937, + 1172, + 1970, + 1128, + 1970 + ], + "text": "for", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1179, + 1937, + 1246, + 1937, + 1245, + 1969, + 1178, + 1970 + ], + "text": "your", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1252, + 1937, + 1319, + 1937, + 1318, + 1968, + 1251, + 1969 + ], + "text": "next", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1325, + 1937, + 1409, + 1937, + 1408, + 1967, + 1324, + 1968 + ], + "text": "order.", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 169, + 1969, + 1112, + 1970, + 1112, + 2003, + 169, + 2002 + ], + "text": "For orders over 100pcs you will recieve 40% off your next order.", + "words": [ + { + "boundingBox": [ + 170, + 1971, + 223, + 1971, + 223, + 2000, + 169, + 1999 + ], + "text": "For", + "confidence": 0.958 + }, + { + "boundingBox": [ + 229, + 1971, + 326, + 1970, + 325, + 2002, + 228, + 2000 + ], + "text": "orders", + "confidence": 0.959 + }, + { + "boundingBox": [ + 333, + 1970, + 404, + 1970, + 404, + 2002, + 333, + 2002 + ], + "text": "over", + "confidence": 0.959 + }, + { + "boundingBox": [ + 410, + 1970, + 516, + 1970, + 516, + 2003, + 409, + 2002 + ], + "text": "100pcs", + "confidence": 0.849 + }, + { + "boundingBox": [ + 524, + 1970, + 578, + 1970, + 577, + 2004, + 523, + 2003 + ], + "text": "you", + "confidence": 0.958 + }, + { + "boundingBox": [ + 585, + 1970, + 636, + 1970, + 635, + 2004, + 585, + 2004 + ], + "text": "will", + "confidence": 0.959 + }, + { + "boundingBox": [ + 641, + 1970, + 750, + 1970, + 749, + 2004, + 641, + 2004 + ], + "text": "recieve", + "confidence": 0.957 + }, + { + "boundingBox": [ + 763, + 1970, + 821, + 1970, + 820, + 2003, + 762, + 2004 + ], + "text": "40%", + "confidence": 0.958 + }, + { + "boundingBox": [ + 835, + 1970, + 875, + 1970, + 874, + 2003, + 835, + 2003 + ], + "text": "off", + "confidence": 0.914 + }, + { + "boundingBox": [ + 880, + 1970, + 949, + 1970, + 949, + 2002, + 880, + 2003 + ], + "text": "your", + "confidence": 0.959 + }, + { + "boundingBox": [ + 955, + 1970, + 1024, + 1971, + 1023, + 2002, + 954, + 2002 + ], + "text": "next", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1030, + 1971, + 1113, + 1971, + 1112, + 2000, + 1029, + 2002 + ], + "text": "order.", + "confidence": 0.959 + } + ] + } + ] + } + ], + "pageResults": [ + { + "page": 1, + "tables": [ + { + "rows": 3, + "columns": 2, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Address: 938 N Lumpy Way", + "boundingBox": [ + 162, + 685, + 647, + 685, + 647, + 719, + 162, + 719 + ], + "elements": [ + "#/readResults/0/lines/12/words/0", + "#/readResults/0/lines/12/words/1", + "#/readResults/0/lines/12/words/2", + "#/readResults/0/lines/12/words/3", + "#/readResults/0/lines/12/words/4" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Denver, CO 83757 Shipped From Name: Frank Sinatra Company Name: Franks Goods Address: 838 NE Grail Road", + "boundingBox": [ + 162, + 719, + 647, + 719, + 647, + 958, + 162, + 958 + ], + "elements": [ + "#/readResults/0/lines/13/words/0", + "#/readResults/0/lines/13/words/1", + "#/readResults/0/lines/13/words/2", + "#/readResults/0/lines/15/words/0", + "#/readResults/0/lines/15/words/1", + "#/readResults/0/lines/16/words/0", + "#/readResults/0/lines/16/words/1", + "#/readResults/0/lines/16/words/2", + "#/readResults/0/lines/17/words/0", + "#/readResults/0/lines/17/words/1", + "#/readResults/0/lines/17/words/2", + "#/readResults/0/lines/17/words/3", + "#/readResults/0/lines/18/words/0", + "#/readResults/0/lines/18/words/1", + "#/readResults/0/lines/18/words/2", + "#/readResults/0/lines/18/words/3", + "#/readResults/0/lines/18/words/4" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "Phone: 435-395-3954", + "boundingBox": [ + 647, + 719, + 955, + 719, + 955, + 958, + 647, + 958 + ], + "elements": [ + "#/readResults/0/lines/14/words/0", + "#/readResults/0/lines/14/words/1" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Bellingham, WA 83748", + "boundingBox": [ + 162, + 958, + 647, + 958, + 647, + 996, + 162, + 996 + ], + "elements": [ + "#/readResults/0/lines/19/words/0", + "#/readResults/0/lines/19/words/1", + "#/readResults/0/lines/19/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "Phone: 939-492-9595", + "boundingBox": [ + 647, + 958, + 955, + 958, + 955, + 996, + 647, + 996 + ], + "elements": [ + "#/readResults/0/lines/20/words/0", + "#/readResults/0/lines/20/words/1" + ] + } + ] + }, + { + "rows": 7, + "columns": 4, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Details", + "boundingBox": [ + 156, + 1038, + 847, + 1038, + 847, + 1087, + 156, + 1087 + ], + "elements": [ + "#/readResults/0/lines/21/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 1, + "text": "Quantity", + "boundingBox": [ + 847, + 1038, + 1072, + 1038, + 1072, + 1087, + 847, + 1087 + ], + "elements": [ + "#/readResults/0/lines/22/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 2, + "text": "Unit Price", + "boundingBox": [ + 1072, + 1038, + 1308, + 1038, + 1308, + 1087, + 1072, + 1087 + ], + "elements": [ + "#/readResults/0/lines/23/words/0", + "#/readResults/0/lines/23/words/1" + ] + }, + { + "rowIndex": 0, + "columnIndex": 3, + "text": "Total", + "boundingBox": [ + 1308, + 1038, + 1544, + 1038, + 1544, + 1087, + 1308, + 1087 + ], + "elements": [ + "#/readResults/0/lines/24/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Crow keychain", + "boundingBox": [ + 156, + 1087, + 847, + 1087, + 847, + 1128, + 156, + 1128 + ], + "elements": [ + "#/readResults/0/lines/25/words/0", + "#/readResults/0/lines/25/words/1" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "10", + "boundingBox": [ + 847, + 1087, + 1072, + 1087, + 1072, + 1128, + 847, + 1128 + ], + "elements": [ + "#/readResults/0/lines/26/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1087, + 1308, + 1087, + 1308, + 1128, + 1072, + 1128 + ], + "elements": [ + "#/readResults/0/lines/27/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1308, + 1087, + 1544, + 1087, + 1544, + 1128, + 1308, + 1128 + ], + "elements": [ + "#/readResults/0/lines/28/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Batman keychain", + "boundingBox": [ + 156, + 1128, + 847, + 1128, + 847, + 1172, + 156, + 1172 + ], + "elements": [ + "#/readResults/0/lines/29/words/0", + "#/readResults/0/lines/29/words/1" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "10", + "boundingBox": [ + 847, + 1128, + 1072, + 1128, + 1072, + 1172, + 847, + 1172 + ], + "elements": [ + "#/readResults/0/lines/30/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1128, + 1308, + 1128, + 1308, + 1172, + 1072, + 1172 + ], + "elements": [ + "#/readResults/0/lines/31/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1308, + 1128, + 1544, + 1128, + 1544, + 1172, + 1308, + 1172 + ], + "elements": [ + "#/readResults/0/lines/32/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "Skull keychain", + "boundingBox": [ + 156, + 1172, + 847, + 1172, + 847, + 1216, + 156, + 1216 + ], + "elements": [ + "#/readResults/0/lines/33/words/0", + "#/readResults/0/lines/33/words/1" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "10", + "boundingBox": [ + 847, + 1172, + 1072, + 1172, + 1072, + 1216, + 847, + 1216 + ], + "elements": [ + "#/readResults/0/lines/34/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1172, + 1308, + 1172, + 1308, + 1216, + 1072, + 1216 + ], + "elements": [ + "#/readResults/0/lines/35/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1308, + 1172, + 1544, + 1172, + 1544, + 1216, + 1308, + 1216 + ], + "elements": [ + "#/readResults/0/lines/36/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 0, + "text": "Moose keychain", + "boundingBox": [ + 156, + 1216, + 847, + 1216, + 847, + 1260, + 156, + 1260 + ], + "elements": [ + "#/readResults/0/lines/37/words/0", + "#/readResults/0/lines/37/words/1" + ] + }, + { + "rowIndex": 4, + "columnIndex": 1, + "text": "10", + "boundingBox": [ + 847, + 1216, + 1072, + 1216, + 1072, + 1260, + 847, + 1260 + ], + "elements": [ + "#/readResults/0/lines/38/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1216, + 1308, + 1216, + 1308, + 1260, + 1072, + 1260 + ], + "elements": [ + "#/readResults/0/lines/39/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1308, + 1216, + 1544, + 1216, + 1544, + 1260, + 1308, + 1260 + ], + "elements": [ + "#/readResults/0/lines/40/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 0, + "text": "Sodapop keychain", + "boundingBox": [ + 156, + 1260, + 847, + 1260, + 847, + 1303, + 156, + 1303 + ], + "elements": [ + "#/readResults/0/lines/41/words/0", + "#/readResults/0/lines/41/words/1" + ] + }, + { + "rowIndex": 5, + "columnIndex": 1, + "text": "10", + "boundingBox": [ + 847, + 1260, + 1072, + 1260, + 1072, + 1303, + 847, + 1303 + ], + "elements": [ + "#/readResults/0/lines/42/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1260, + 1308, + 1260, + 1308, + 1303, + 1072, + 1303 + ], + "elements": [ + "#/readResults/0/lines/43/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1308, + 1260, + 1544, + 1260, + 1544, + 1303, + 1308, + 1303 + ], + "elements": [ + "#/readResults/0/lines/44/words/0" + ] + } + ] + }, + { + "rows": 4, + "columns": 3, + "cells": [ + { + "rowIndex": 1, + "columnIndex": 1, + "text": "SUBTOTAL", + "boundingBox": [ + 1072, + 1566, + 1309, + 1566, + 1309, + 1610, + 1072, + 1610 + ], + "elements": [ + "#/readResults/0/lines/45/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "$600.00", + "boundingBox": [ + 1309, + 1566, + 1544, + 1566, + 1544, + 1610, + 1309, + 1610 + ], + "elements": [ + "#/readResults/0/lines/46/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "TAX", + "boundingBox": [ + 1072, + 1610, + 1309, + 1610, + 1309, + 1658, + 1072, + 1658 + ], + "elements": [ + "#/readResults/0/lines/47/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "$20.00", + "boundingBox": [ + 1309, + 1610, + 1544, + 1610, + 1544, + 1658, + 1309, + 1658 + ], + "elements": [ + "#/readResults/0/lines/48/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "TOTAL", + "boundingBox": [ + 1072, + 1658, + 1309, + 1658, + 1309, + 1708, + 1072, + 1708 + ], + "elements": [ + "#/readResults/0/lines/50/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "$620.00", + "boundingBox": [ + 1309, + 1658, + 1544, + 1658, + 1544, + 1708, + 1309, + 1708 + ], + "elements": [ + "#/readResults/0/lines/51/words/0" + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg new file mode 100644 index 000000000000..81fbd8a599bc Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.labels.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.labels.json new file mode 100644 index 000000000000..e919518d0fe3 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.labels.json @@ -0,0 +1,495 @@ +{ + "document": "Form_3.jpg", + "labels": [ + { + "label": "Merchant", + "key": null, + "value": [ + { + "page": 1, + "text": "Hero", + "boundingBoxes": [ + [ + 0.3658823529411765, + 0.09409090909090909, + 0.46352941176470586, + 0.09272727272727273, + 0.46294117647058824, + 0.12090909090909091, + 0.3652941176470588, + 0.12090909090909091 + ] + ] + }, + { + "page": 1, + "text": "Limited", + "boundingBoxes": [ + [ + 0.47705882352941176, + 0.09272727272727273, + 0.6323529411764706, + 0.09181818181818181, + 0.6323529411764706, + 0.12090909090909091, + 0.47705882352941176, + 0.12090909090909091 + ] + ] + } + ] + }, + { + "label": "PhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "555-348-6512", + "boundingBoxes": [ + [ + 0.2164705882352941, + 0.15954545454545455, + 0.31176470588235294, + 0.16, + 0.31176470588235294, + 0.17, + 0.2164705882352941, + 0.17181818181818181 + ] + ] + } + ] + }, + { + "label": "Website", + "key": null, + "value": [ + { + "page": 1, + "text": "www.herolimited.com", + "boundingBoxes": [ + [ + 0.1623529411764706, + 0.17863636363636365, + 0.3088235294117647, + 0.17909090909090908, + 0.3088235294117647, + 0.19, + 0.16176470588235295, + 0.19045454545454546 + ] + ] + } + ] + }, + { + "label": "DatedAs", + "key": null, + "value": [ + { + "page": 1, + "text": "02/10/2020", + "boundingBoxes": [ + [ + 0.6870588235294117, + 0.19090909090909092, + 0.7747058823529411, + 0.19045454545454546, + 0.7747058823529411, + 0.20454545454545456, + 0.6864705882352942, + 0.20454545454545456 + ] + ] + } + ] + }, + { + "label": "Email", + "key": null, + "value": [ + { + "page": 1, + "text": "accounts@herolimited.com", + "boundingBoxes": [ + [ + 0.0976470588235294, + 0.22, + 0.27941176470588236, + 0.21818181818181817, + 0.2788235294117647, + 0.22863636363636364, + 0.0976470588235294, + 0.22863636363636364 + ] + ] + } + ] + }, + { + "label": "PurchaseOrderNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "9328424", + "boundingBoxes": [ + [ + 0.7535294117647059, + 0.20954545454545453, + 0.8182352941176471, + 0.21, + 0.8182352941176471, + 0.22181818181818183, + 0.7535294117647059, + 0.22272727272727272 + ] + ] + } + ] + }, + { + "label": "VendorName", + "key": null, + "value": [ + { + "page": 1, + "text": "Tish", + "boundingBoxes": [ + [ + 0.2088235294117647, + 0.2772727272727273, + 0.2376470588235294, + 0.2772727272727273, + 0.2376470588235294, + 0.29045454545454547, + 0.20823529411764705, + 0.29045454545454547 + ] + ] + }, + { + "page": 1, + "text": "Williams", + "boundingBoxes": [ + [ + 0.2411764705882353, + 0.2772727272727273, + 0.30470588235294116, + 0.2768181818181818, + 0.30470588235294116, + 0.29, + 0.2411764705882353, + 0.29045454545454547 + ] + ] + } + ] + }, + { + "label": "CompanyName", + "key": null, + "value": [ + { + "page": 1, + "text": "Tish's", + "boundingBoxes": [ + [ + 0.2235294117647059, + 0.29454545454545455, + 0.2641176470588235, + 0.29409090909090907, + 0.2641176470588235, + 0.30772727272727274, + 0.2235294117647059, + 0.30818181818181817 + ] + ] + }, + { + "page": 1, + "text": "Wishes", + "boundingBoxes": [ + [ + 0.2676470588235294, + 0.29409090909090907, + 0.3205882352941177, + 0.29409090909090907, + 0.3211764705882353, + 0.30636363636363634, + 0.2676470588235294, + 0.30727272727272725 + ] + ] + } + ] + }, + { + "label": "CompanyAddress", + "key": null, + "value": [ + { + "page": 1, + "text": "932", + "boundingBoxes": [ + [ + 0.1635294117647059, + 0.31136363636363634, + 0.19117647058823528, + 0.31136363636363634, + 0.19058823529411764, + 0.3240909090909091, + 0.16294117647058823, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "N", + "boundingBoxes": [ + [ + 0.19470588235294117, + 0.31136363636363634, + 0.20529411764705882, + 0.31136363636363634, + 0.20470588235294118, + 0.3240909090909091, + 0.19411764705882353, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Cantaloupe", + "boundingBoxes": [ + [ + 0.20941176470588235, + 0.31136363636363634, + 0.29470588235294115, + 0.31136363636363634, + 0.29352941176470587, + 0.3245454545454545, + 0.2088235294117647, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Road", + "boundingBoxes": [ + [ + 0.29764705882352943, + 0.31136363636363634, + 0.33588235294117647, + 0.3109090909090909, + 0.3347058823529412, + 0.325, + 0.29705882352941176, + 0.3245454545454545 + ] + ] + }, + { + "page": 1, + "text": "Seattle,", + "boundingBoxes": [ + [ + 0.1623529411764706, + 0.3290909090909091, + 0.21941176470588236, + 0.3286363636363636, + 0.21823529411764706, + 0.34045454545454545, + 0.16176470588235295, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "WA", + "boundingBoxes": [ + [ + 0.2223529411764706, + 0.3286363636363636, + 0.24764705882352941, + 0.3281818181818182, + 0.24705882352941178, + 0.34045454545454545, + 0.2211764705882353, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "38383", + "boundingBoxes": [ + [ + 0.25176470588235295, + 0.3281818181818182, + 0.29823529411764704, + 0.3281818181818182, + 0.29764705882352943, + 0.34045454545454545, + 0.2511764705882353, + 0.34045454545454545 + ] + ] + } + ] + }, + { + "label": "CompanyPhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "323-245-2943", + "boundingBoxes": [ + [ + 0.5041176470588236, + 0.3281818181818182, + 0.6064705882352941, + 0.3281818181818182, + 0.6064705882352941, + 0.34045454545454545, + 0.5041176470588236, + 0.34045454545454545 + ] + ] + } + ] + }, + { + "label": "Quantity", + "key": null, + "value": [ + { + "page": 1, + "text": "20", + "boundingBoxes": [ + [ + 0.5064705882352941, + 0.4959090909090909, + 0.5252941176470588, + 0.495, + 0.5264705882352941, + 0.5081818181818182, + 0.5076470588235295, + 0.509090909090909 + ] + ] + } + ] + }, + { + "label": "Subtotal", + "key": null, + "value": [ + { + "page": 1, + "text": "$400.00", + "boundingBoxes": [ + [ + 0.84, + 0.7140909090909091, + 0.8994117647058824, + 0.7136363636363636, + 0.8994117647058824, + 0.7268181818181818, + 0.84, + 0.7268181818181818 + ] + ] + } + ] + }, + { + "label": "Tax", + "key": null, + "value": [ + { + "page": 1, + "text": "$14.00", + "boundingBoxes": [ + [ + 0.8494117647058823, + 0.7345454545454545, + 0.9005882352941177, + 0.7336363636363636, + 0.9005882352941177, + 0.7463636363636363, + 0.85, + 0.7468181818181818 + ] + ] + } + ] + }, + { + "label": "Signature", + "key": null, + "value": [ + { + "page": 1, + "text": "Larry", + "boundingBoxes": [ + [ + 0.26529411764705885, + 0.76, + 0.33705882352941174, + 0.7595454545454545, + 0.33705882352941174, + 0.7795454545454545, + 0.26529411764705885, + 0.7777272727272727 + ] + ] + }, + { + "page": 1, + "text": "Longshore", + "boundingBoxes": [ + [ + 0.3458823529411765, + 0.7595454545454545, + 0.4647058823529412, + 0.7581818181818182, + 0.4652941176470588, + 0.7809090909090909, + 0.34647058823529414, + 0.7795454545454545 + ] + ] + } + ] + }, + { + "label": "Total", + "key": null, + "value": [ + { + "page": 1, + "text": "$414.00", + "boundingBoxes": [ + [ + 0.8411764705882353, + 0.759090909090909, + 0.8994117647058824, + 0.7586363636363637, + 0.9, + 0.7709090909090909, + 0.8405882352941176, + 0.7713636363636364 + ] + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.ocr.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.ocr.json new file mode 100644 index 000000000000..4ac78362469b --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_3.jpg.ocr.json @@ -0,0 +1,3286 @@ +{ + "status": "succeeded", + "createdDateTime": "2020-04-09T01:33:11Z", + "lastUpdatedDateTime": "2020-04-09T01:33:14Z", + "analyzeResult": { + "version": "2.0.0", + "readResults": [ + { + "page": 1, + "language": "en", + "angle": -0.0663, + "width": 1700, + "height": 2200, + "unit": "pixel", + "lines": [ + { + "language": "en", + "boundingBox": [ + 137, + 140, + 351, + 140, + 351, + 167, + 137, + 166 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 137, + 140, + 263, + 140, + 263, + 168, + 138, + 166 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 271, + 140, + 351, + 140, + 351, + 168, + 272, + 168 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 620, + 204, + 1073, + 201, + 1074, + 264, + 620, + 266 + ], + "text": "Hero Limited", + "words": [ + { + "boundingBox": [ + 622, + 207, + 788, + 204, + 787, + 266, + 621, + 266 + ], + "text": "Hero", + "confidence": 0.959 + }, + { + "boundingBox": [ + 811, + 204, + 1075, + 202, + 1075, + 266, + 811, + 266 + ], + "text": "Limited", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 351, + 529, + 350, + 529, + 376, + 165, + 379 + ], + "text": "Company Phone: 555-348-6512", + "words": [ + { + "boundingBox": [ + 167, + 352, + 277, + 351, + 276, + 379, + 167, + 379 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 282, + 351, + 363, + 351, + 363, + 378, + 282, + 379 + ], + "text": "Phone:", + "confidence": 0.937 + }, + { + "boundingBox": [ + 368, + 351, + 530, + 352, + 530, + 374, + 368, + 378 + ], + "text": "555-348-6512", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 320, + 1551, + 320, + 1551, + 370, + 1114, + 370 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 1115, + 322, + 1377, + 321, + 1377, + 371, + 1117, + 371 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1396, + 321, + 1550, + 321, + 1549, + 371, + 1396, + 371 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 392, + 529, + 393, + 529, + 419, + 167, + 418 + ], + "text": "Website: www.herolimited.com", + "words": [ + { + "boundingBox": [ + 168, + 392, + 271, + 393, + 270, + 419, + 167, + 418 + ], + "text": "Website:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 276, + 393, + 525, + 394, + 525, + 418, + 275, + 419 + ], + "text": "www.herolimited.com", + "confidence": 0.829 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 437, + 236, + 437, + 236, + 459, + 164, + 459 + ], + "text": "Email:", + "words": [ + { + "boundingBox": [ + 165, + 437, + 236, + 437, + 236, + 460, + 165, + 459 + ], + "text": "Email:", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 419, + 1317, + 419, + 1317, + 449, + 1025, + 449 + ], + "text": "Dated As: 02/10/2020", + "words": [ + { + "boundingBox": [ + 1026, + 420, + 1111, + 420, + 1110, + 450, + 1025, + 449 + ], + "text": "Dated", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1118, + 420, + 1162, + 420, + 1161, + 450, + 1118, + 450 + ], + "text": "As:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1168, + 420, + 1317, + 419, + 1317, + 450, + 1167, + 450 + ], + "text": "02/10/2020", + "confidence": 0.955 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 480, + 482, + 479, + 482, + 502, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "words": [ + { + "boundingBox": [ + 166, + 484, + 475, + 480, + 474, + 503, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "confidence": 0.862 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 461, + 1391, + 461, + 1391, + 488, + 1025, + 489 + ], + "text": "Purchase Order #: 9328424", + "words": [ + { + "boundingBox": [ + 1027, + 462, + 1154, + 461, + 1154, + 490, + 1026, + 489 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1160, + 461, + 1241, + 461, + 1240, + 490, + 1159, + 490 + ], + "text": "Order", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1246, + 461, + 1276, + 461, + 1275, + 490, + 1245, + 490 + ], + "text": "#:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1281, + 461, + 1391, + 462, + 1391, + 488, + 1281, + 490 + ], + "text": "9328424", + "confidence": 0.95 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 546, + 397, + 546, + 397, + 594, + 166, + 594 + ], + "text": "Shipped To", + "words": [ + { + "boundingBox": [ + 167, + 546, + 336, + 548, + 337, + 593, + 168, + 595 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 346, + 548, + 396, + 548, + 397, + 593, + 347, + 593 + ], + "text": "To", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 609, + 517, + 608, + 518, + 637, + 160, + 638 + ], + "text": "Vendor Name: Tish Williams", + "words": [ + { + "boundingBox": [ + 162, + 610, + 257, + 610, + 256, + 639, + 160, + 638 + ], + "text": "Vendor", + "confidence": 0.957 + }, + { + "boundingBox": [ + 262, + 610, + 349, + 610, + 349, + 639, + 261, + 639 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 355, + 610, + 404, + 610, + 404, + 639, + 354, + 639 + ], + "text": "Tish", + "confidence": 0.959 + }, + { + "boundingBox": [ + 410, + 610, + 518, + 609, + 518, + 638, + 410, + 639 + ], + "text": "Williams", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 647, + 546, + 646, + 547, + 676, + 160, + 679 + ], + "text": "Company Name: Tish's Wishes", + "words": [ + { + "boundingBox": [ + 161, + 648, + 282, + 648, + 282, + 679, + 160, + 679 + ], + "text": "Company", + "confidence": 0.958 + }, + { + "boundingBox": [ + 288, + 648, + 374, + 648, + 374, + 678, + 288, + 679 + ], + "text": "Name:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 380, + 648, + 449, + 647, + 449, + 677, + 380, + 678 + ], + "text": "Tish's", + "confidence": 0.952 + }, + { + "boundingBox": [ + 455, + 647, + 545, + 647, + 546, + 674, + 455, + 676 + ], + "text": "Wishes", + "confidence": 0.955 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 161, + 684, + 571, + 684, + 571, + 714, + 161, + 713 + ], + "text": "Address: 932 N Cantaloupe Road", + "words": [ + { + "boundingBox": [ + 161, + 684, + 272, + 685, + 271, + 713, + 161, + 712 + ], + "text": "Address:", + "confidence": 0.943 + }, + { + "boundingBox": [ + 278, + 685, + 325, + 685, + 324, + 713, + 277, + 713 + ], + "text": "932", + "confidence": 0.958 + }, + { + "boundingBox": [ + 331, + 685, + 349, + 685, + 348, + 713, + 330, + 713 + ], + "text": "N", + "confidence": 0.873 + }, + { + "boundingBox": [ + 356, + 685, + 501, + 685, + 499, + 714, + 355, + 713 + ], + "text": "Cantaloupe", + "confidence": 0.958 + }, + { + "boundingBox": [ + 506, + 685, + 571, + 684, + 569, + 715, + 505, + 714 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 272, + 723, + 507, + 722, + 507, + 748, + 272, + 749 + ], + "text": "Seattle, WA 38383", + "words": [ + { + "boundingBox": [ + 276, + 724, + 373, + 723, + 371, + 749, + 275, + 749 + ], + "text": "Seattle,", + "confidence": 0.955 + }, + { + "boundingBox": [ + 378, + 723, + 421, + 722, + 420, + 749, + 376, + 749 + ], + "text": "WA", + "confidence": 0.958 + }, + { + "boundingBox": [ + 428, + 722, + 507, + 722, + 506, + 749, + 427, + 749 + ], + "text": "38383", + "confidence": 0.943 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 759, + 721, + 1032, + 721, + 1032, + 748, + 759, + 749 + ], + "text": "Phone: 323-245-2943", + "words": [ + { + "boundingBox": [ + 761, + 723, + 852, + 722, + 852, + 749, + 761, + 749 + ], + "text": "Phone:", + "confidence": 0.955 + }, + { + "boundingBox": [ + 857, + 722, + 1031, + 722, + 1031, + 749, + 857, + 749 + ], + "text": "323-245-2943", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 783, + 451, + 783, + 451, + 826, + 165, + 830 + ], + "text": "Shipped From", + "words": [ + { + "boundingBox": [ + 167, + 784, + 334, + 784, + 333, + 829, + 166, + 830 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 343, + 784, + 439, + 784, + 438, + 824, + 342, + 828 + ], + "text": "From", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 851, + 460, + 851, + 460, + 882, + 165, + 882 + ], + "text": "Name: Larry Longshore", + "words": [ + { + "boundingBox": [ + 167, + 851, + 251, + 853, + 249, + 882, + 165, + 882 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 257, + 853, + 319, + 853, + 318, + 883, + 255, + 883 + ], + "text": "Larry", + "confidence": 0.959 + }, + { + "boundingBox": [ + 325, + 853, + 460, + 852, + 459, + 883, + 324, + 883 + ], + "text": "Longshore", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 889, + 603, + 889, + 603, + 920, + 164, + 920 + ], + "text": "Company Name: Longshore Supply", + "words": [ + { + "boundingBox": [ + 167, + 891, + 286, + 890, + 285, + 920, + 166, + 919 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 292, + 890, + 378, + 890, + 377, + 920, + 291, + 920 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 383, + 890, + 514, + 890, + 514, + 921, + 383, + 920 + ], + "text": "Longshore", + "confidence": 0.959 + }, + { + "boundingBox": [ + 520, + 890, + 603, + 890, + 603, + 921, + 519, + 921 + ], + "text": "Supply", + "confidence": 0.946 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 926, + 487, + 926, + 487, + 953, + 166, + 953 + ], + "text": "Address: 382 N Cool Road", + "words": [ + { + "boundingBox": [ + 167, + 926, + 277, + 926, + 277, + 954, + 166, + 954 + ], + "text": "Address:", + "confidence": 0.957 + }, + { + "boundingBox": [ + 283, + 926, + 331, + 927, + 331, + 954, + 282, + 954 + ], + "text": "382", + "confidence": 0.958 + }, + { + "boundingBox": [ + 337, + 927, + 355, + 927, + 354, + 954, + 336, + 954 + ], + "text": "N", + "confidence": 0.884 + }, + { + "boundingBox": [ + 362, + 927, + 419, + 927, + 419, + 954, + 361, + 954 + ], + "text": "Cool", + "confidence": 0.932 + }, + { + "boundingBox": [ + 424, + 927, + 488, + 927, + 488, + 954, + 424, + 954 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 284, + 964, + 528, + 963, + 528, + 991, + 284, + 992 + ], + "text": "Bellevue WA 93939", + "words": [ + { + "boundingBox": [ + 285, + 965, + 393, + 965, + 392, + 991, + 285, + 991 + ], + "text": "Bellevue", + "confidence": 0.958 + }, + { + "boundingBox": [ + 398, + 965, + 444, + 964, + 443, + 992, + 397, + 991 + ], + "text": "WA", + "confidence": 0.958 + }, + { + "boundingBox": [ + 451, + 964, + 529, + 964, + 528, + 992, + 450, + 992 + ], + "text": "93939", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 758, + 963, + 1031, + 963, + 1031, + 991, + 758, + 991 + ], + "text": "Phone: 938-242-4924", + "words": [ + { + "boundingBox": [ + 759, + 965, + 851, + 963, + 851, + 991, + 759, + 990 + ], + "text": "Phone:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 856, + 963, + 1031, + 964, + 1031, + 991, + 856, + 992 + ], + "text": "938-242-4924", + "confidence": 0.944 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 446, + 1047, + 557, + 1047, + 558, + 1079, + 446, + 1080 + ], + "text": "Details", + "words": [ + { + "boundingBox": [ + 447, + 1049, + 557, + 1047, + 556, + 1080, + 447, + 1079 + ], + "text": "Details", + "confidence": 0.938 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 889, + 1045, + 1030, + 1046, + 1030, + 1084, + 889, + 1083 + ], + "text": "Quantity", + "words": [ + { + "boundingBox": [ + 889, + 1046, + 1029, + 1046, + 1027, + 1084, + 890, + 1083 + ], + "text": "Quantity", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 1046, + 1271, + 1047, + 1271, + 1078, + 1114, + 1077 + ], + "text": "Unit Price", + "words": [ + { + "boundingBox": [ + 1114, + 1048, + 1184, + 1047, + 1184, + 1078, + 1114, + 1077 + ], + "text": "Unit", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1047, + 1271, + 1047, + 1271, + 1079, + 1190, + 1078 + ], + "text": "Price", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1384, + 1047, + 1469, + 1046, + 1470, + 1076, + 1384, + 1077 + ], + "text": "Total", + "words": [ + { + "boundingBox": [ + 1387, + 1046, + 1468, + 1046, + 1469, + 1076, + 1387, + 1077 + ], + "text": "Total", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1094, + 404, + 1095, + 404, + 1123, + 170, + 1122 + ], + "text": "Party Favor purple", + "words": [ + { + "boundingBox": [ + 172, + 1095, + 239, + 1095, + 238, + 1123, + 171, + 1122 + ], + "text": "Party", + "confidence": 0.959 + }, + { + "boundingBox": [ + 244, + 1095, + 314, + 1096, + 313, + 1124, + 243, + 1123 + ], + "text": "Favor", + "confidence": 0.959 + }, + { + "boundingBox": [ + 320, + 1096, + 405, + 1096, + 404, + 1124, + 319, + 1124 + ], + "text": "purple", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 859, + 1091, + 894, + 1089, + 895, + 1118, + 860, + 1120 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1091, + 893, + 1089, + 895, + 1118, + 863, + 1120 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1239, + 1095, + 1296, + 1094, + 1296, + 1118, + 1239, + 1118 + ], + "text": "5.00", + "words": [ + { + "boundingBox": [ + 1241, + 1094, + 1295, + 1094, + 1295, + 1118, + 1241, + 1118 + ], + "text": "5.00", + "confidence": 0.917 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1095, + 1531, + 1093, + 1532, + 1118, + 1443, + 1120 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1445, + 1096, + 1528, + 1094, + 1528, + 1118, + 1445, + 1120 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1135, + 351, + 1135, + 351, + 1163, + 170, + 1163 + ], + "text": "Party Hat Blue", + "words": [ + { + "boundingBox": [ + 172, + 1136, + 238, + 1136, + 238, + 1163, + 171, + 1164 + ], + "text": "Party", + "confidence": 0.959 + }, + { + "boundingBox": [ + 244, + 1136, + 289, + 1136, + 288, + 1163, + 243, + 1163 + ], + "text": "Hat", + "confidence": 0.958 + }, + { + "boundingBox": [ + 294, + 1136, + 351, + 1135, + 351, + 1164, + 294, + 1163 + ], + "text": "Blue", + "confidence": 0.927 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 860, + 1137, + 893, + 1135, + 893, + 1158, + 861, + 1160 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 862, + 1137, + 892, + 1135, + 893, + 1158, + 863, + 1160 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1239, + 1136, + 1294, + 1135, + 1294, + 1159, + 1239, + 1159 + ], + "text": "5.00", + "words": [ + { + "boundingBox": [ + 1241, + 1135, + 1293, + 1135, + 1293, + 1159, + 1241, + 1159 + ], + "text": "5.00", + "confidence": 0.915 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1136, + 1531, + 1135, + 1531, + 1159, + 1443, + 1159 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1446, + 1136, + 1529, + 1136, + 1529, + 1159, + 1445, + 1160 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1178, + 394, + 1177, + 394, + 1206, + 170, + 1208 + ], + "text": "Party Cloth White", + "words": [ + { + "boundingBox": [ + 172, + 1179, + 239, + 1179, + 238, + 1207, + 170, + 1208 + ], + "text": "Party", + "confidence": 0.959 + }, + { + "boundingBox": [ + 244, + 1179, + 312, + 1179, + 312, + 1207, + 244, + 1207 + ], + "text": "Cloth", + "confidence": 0.959 + }, + { + "boundingBox": [ + 318, + 1179, + 394, + 1177, + 395, + 1207, + 318, + 1207 + ], + "text": "White", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 863, + 1181, + 893, + 1180, + 893, + 1202, + 863, + 1203 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 863, + 1181, + 892, + 1180, + 892, + 1202, + 863, + 1203 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1240, + 1179, + 1295, + 1179, + 1295, + 1202, + 1239, + 1202 + ], + "text": "5,00", + "words": [ + { + "boundingBox": [ + 1241, + 1179, + 1294, + 1179, + 1294, + 1202, + 1241, + 1202 + ], + "text": "5,00", + "confidence": 0.423 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1180, + 1531, + 1179, + 1532, + 1203, + 1443, + 1204 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1446, + 1181, + 1529, + 1180, + 1529, + 1203, + 1446, + 1204 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 171, + 1221, + 423, + 1219, + 423, + 1249, + 171, + 1251 + ], + "text": "Party Maraca White", + "words": [ + { + "boundingBox": [ + 172, + 1222, + 239, + 1222, + 238, + 1251, + 171, + 1250 + ], + "text": "Party", + "confidence": 0.959 + }, + { + "boundingBox": [ + 244, + 1222, + 338, + 1221, + 339, + 1251, + 244, + 1251 + ], + "text": "Maraca", + "confidence": 0.959 + }, + { + "boundingBox": [ + 344, + 1221, + 421, + 1219, + 422, + 1249, + 345, + 1251 + ], + "text": "White", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1223, + 894, + 1222, + 893, + 1246, + 861, + 1248 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1223, + 893, + 1222, + 894, + 1245, + 862, + 1247 + ], + "text": "20", + "confidence": 0.86 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1240, + 1222, + 1295, + 1223, + 1295, + 1246, + 1240, + 1245 + ], + "text": "5,00", + "words": [ + { + "boundingBox": [ + 1241, + 1222, + 1294, + 1223, + 1293, + 1246, + 1240, + 1245 + ], + "text": "5,00", + "confidence": 0.424 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1222, + 1531, + 1222, + 1531, + 1247, + 1443, + 1247 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1445, + 1223, + 1529, + 1222, + 1529, + 1248, + 1444, + 1248 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1148, + 1574, + 1296, + 1574, + 1295, + 1599, + 1148, + 1599 + ], + "text": "SUBTOTAL", + "words": [ + { + "boundingBox": [ + 1149, + 1574, + 1296, + 1575, + 1296, + 1599, + 1149, + 1600 + ], + "text": "SUBTOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1427, + 1570, + 1530, + 1569, + 1530, + 1598, + 1427, + 1598 + ], + "text": "$400.00", + "words": [ + { + "boundingBox": [ + 1428, + 1571, + 1529, + 1570, + 1529, + 1599, + 1428, + 1599 + ], + "text": "$400.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1238, + 1619, + 1295, + 1618, + 1295, + 1642, + 1237, + 1642 + ], + "text": "TAX", + "words": [ + { + "boundingBox": [ + 1241, + 1618, + 1294, + 1618, + 1294, + 1641, + 1241, + 1642 + ], + "text": "TAX", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1441, + 1615, + 1530, + 1614, + 1531, + 1641, + 1442, + 1643 + ], + "text": "$14.00", + "words": [ + { + "boundingBox": [ + 1444, + 1616, + 1531, + 1614, + 1531, + 1642, + 1445, + 1643 + ], + "text": "$14.00", + "confidence": 0.911 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 449, + 1668, + 791, + 1668, + 791, + 1717, + 449, + 1715 + ], + "text": "Larry Longshore", + "words": [ + { + "boundingBox": [ + 451, + 1672, + 573, + 1671, + 573, + 1715, + 451, + 1711 + ], + "text": "Larry", + "confidence": 0.488 + }, + { + "boundingBox": [ + 588, + 1671, + 790, + 1668, + 791, + 1718, + 589, + 1715 + ], + "text": "Longshore", + "confidence": 0.57 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1204, + 1672, + 1296, + 1672, + 1296, + 1699, + 1204, + 1699 + ], + "text": "TOTAL", + "words": [ + { + "boundingBox": [ + 1207, + 1674, + 1295, + 1673, + 1296, + 1700, + 1207, + 1699 + ], + "text": "TOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1426, + 1670, + 1530, + 1669, + 1531, + 1695, + 1426, + 1697 + ], + "text": "$414.00", + "words": [ + { + "boundingBox": [ + 1430, + 1670, + 1529, + 1669, + 1530, + 1696, + 1429, + 1697 + ], + "text": "$414.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 529, + 1714, + 723, + 1715, + 722, + 1745, + 529, + 1743 + ], + "text": "Carry Longshore", + "words": [ + { + "boundingBox": [ + 530, + 1715, + 595, + 1715, + 596, + 1745, + 531, + 1744 + ], + "text": "Carry", + "confidence": 0.434 + }, + { + "boundingBox": [ + 601, + 1715, + 723, + 1719, + 723, + 1743, + 602, + 1745 + ], + "text": "Longshore", + "confidence": 0.84 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 526, + 1751, + 735, + 1753, + 735, + 1779, + 526, + 1778 + ], + "text": "Shipping Manager", + "words": [ + { + "boundingBox": [ + 528, + 1751, + 626, + 1752, + 624, + 1779, + 526, + 1778 + ], + "text": "Shipping", + "confidence": 0.958 + }, + { + "boundingBox": [ + 631, + 1752, + 736, + 1754, + 735, + 1780, + 630, + 1779 + ], + "text": "Manager", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1796, + 480, + 1797, + 479, + 1832, + 173, + 1830 + ], + "text": "Additional Notes:", + "words": [ + { + "boundingBox": [ + 175, + 1798, + 358, + 1797, + 358, + 1833, + 174, + 1830 + ], + "text": "Additional", + "confidence": 0.959 + }, + { + "boundingBox": [ + 365, + 1797, + 479, + 1800, + 479, + 1832, + 364, + 1833 + ], + "text": "Notes:", + "confidence": 0.908 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 175, + 1877, + 1470, + 1877, + 1470, + 1914, + 175, + 1914 + ], + "text": "Unpack Carefully. Enjoy. Longshore Supply wishes you a happy party and is always here for", + "words": [ + { + "boundingBox": [ + 177, + 1880, + 269, + 1879, + 267, + 1911, + 175, + 1909 + ], + "text": "Unpack", + "confidence": 0.959 + }, + { + "boundingBox": [ + 274, + 1879, + 392, + 1879, + 391, + 1912, + 273, + 1911 + ], + "text": "Carefully.", + "confidence": 0.849 + }, + { + "boundingBox": [ + 398, + 1879, + 475, + 1879, + 474, + 1913, + 397, + 1912 + ], + "text": "Enjoy.", + "confidence": 0.958 + }, + { + "boundingBox": [ + 481, + 1879, + 640, + 1878, + 639, + 1915, + 480, + 1913 + ], + "text": "Longshore", + "confidence": 0.958 + }, + { + "boundingBox": [ + 651, + 1878, + 754, + 1878, + 753, + 1915, + 651, + 1915 + ], + "text": "Supply", + "confidence": 0.944 + }, + { + "boundingBox": [ + 760, + 1878, + 864, + 1878, + 864, + 1915, + 759, + 1915 + ], + "text": "wishes", + "confidence": 0.958 + }, + { + "boundingBox": [ + 870, + 1878, + 926, + 1878, + 926, + 1915, + 869, + 1915 + ], + "text": "you", + "confidence": 0.936 + }, + { + "boundingBox": [ + 934, + 1878, + 953, + 1878, + 953, + 1915, + 933, + 1915 + ], + "text": "a", + "confidence": 0.895 + }, + { + "boundingBox": [ + 961, + 1878, + 1056, + 1878, + 1055, + 1915, + 960, + 1915 + ], + "text": "happy", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1062, + 1878, + 1141, + 1878, + 1140, + 1915, + 1061, + 1915 + ], + "text": "party", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1147, + 1878, + 1203, + 1878, + 1202, + 1914, + 1146, + 1915 + ], + "text": "and", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1209, + 1878, + 1238, + 1878, + 1237, + 1914, + 1208, + 1914 + ], + "text": "is", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1243, + 1878, + 1350, + 1878, + 1349, + 1913, + 1243, + 1914 + ], + "text": "always", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1356, + 1878, + 1423, + 1878, + 1423, + 1912, + 1355, + 1913 + ], + "text": "here", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1431, + 1878, + 1471, + 1878, + 1470, + 1912, + 1431, + 1912 + ], + "text": "for", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1924, + 1468, + 1923, + 1468, + 1957, + 172, + 1959 + ], + "text": "for your party supply needs. For larger events and rentals please visit us at our affiliates", + "words": [ + { + "boundingBox": [ + 173, + 1924, + 214, + 1924, + 214, + 1958, + 173, + 1958 + ], + "text": "for", + "confidence": 0.958 + }, + { + "boundingBox": [ + 221, + 1924, + 288, + 1924, + 288, + 1959, + 221, + 1958 + ], + "text": "your", + "confidence": 0.959 + }, + { + "boundingBox": [ + 294, + 1924, + 370, + 1924, + 370, + 1959, + 294, + 1959 + ], + "text": "party", + "confidence": 0.958 + }, + { + "boundingBox": [ + 377, + 1924, + 477, + 1924, + 477, + 1959, + 377, + 1959 + ], + "text": "supply", + "confidence": 0.959 + }, + { + "boundingBox": [ + 484, + 1924, + 586, + 1923, + 586, + 1959, + 484, + 1959 + ], + "text": "needs.", + "confidence": 0.956 + }, + { + "boundingBox": [ + 593, + 1923, + 644, + 1923, + 644, + 1959, + 593, + 1959 + ], + "text": "For", + "confidence": 0.958 + }, + { + "boundingBox": [ + 651, + 1923, + 740, + 1923, + 740, + 1959, + 651, + 1959 + ], + "text": "larger", + "confidence": 0.958 + }, + { + "boundingBox": [ + 747, + 1923, + 847, + 1923, + 847, + 1959, + 747, + 1959 + ], + "text": "events", + "confidence": 0.958 + }, + { + "boundingBox": [ + 854, + 1923, + 911, + 1923, + 912, + 1959, + 854, + 1959 + ], + "text": "and", + "confidence": 0.958 + }, + { + "boundingBox": [ + 918, + 1923, + 1023, + 1923, + 1024, + 1958, + 919, + 1959 + ], + "text": "rentals", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1029, + 1923, + 1130, + 1923, + 1131, + 1958, + 1030, + 1958 + ], + "text": "please", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1136, + 1923, + 1197, + 1923, + 1198, + 1957, + 1137, + 1958 + ], + "text": "visit", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1203, + 1923, + 1241, + 1923, + 1242, + 1957, + 1204, + 1957 + ], + "text": "us", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1248, + 1923, + 1279, + 1923, + 1280, + 1957, + 1249, + 1957 + ], + "text": "at", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1286, + 1923, + 1335, + 1923, + 1336, + 1956, + 1287, + 1956 + ], + "text": "our", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1341, + 1923, + 1467, + 1923, + 1469, + 1955, + 1343, + 1956 + ], + "text": "affiliates", + "confidence": 0.938 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1959, + 319, + 1961, + 318, + 1992, + 172, + 1989 + ], + "text": "webpage:", + "words": [ + { + "boundingBox": [ + 173, + 1959, + 318, + 1962, + 316, + 1993, + 173, + 1989 + ], + "text": "webpage:", + "confidence": 0.933 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 459, + 1990, + 845, + 1992, + 845, + 2025, + 459, + 2023 + ], + "text": "www.longshoreevents.org", + "words": [ + { + "boundingBox": [ + 460, + 1991, + 846, + 1994, + 844, + 2024, + 459, + 2023 + ], + "text": "www.longshoreevents.org", + "confidence": 0.839 + } + ] + } + ] + } + ], + "pageResults": [ + { + "page": 1, + "tables": [ + { + "rows": 6, + "columns": 4, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Details", + "boundingBox": [ + 156, + 1038, + 847, + 1038, + 847, + 1087, + 156, + 1087 + ], + "elements": [ + "#/readResults/0/lines/21/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 1, + "text": "Quantity", + "boundingBox": [ + 847, + 1038, + 1072, + 1038, + 1072, + 1087, + 847, + 1087 + ], + "elements": [ + "#/readResults/0/lines/22/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 2, + "text": "Unit Price", + "boundingBox": [ + 1072, + 1038, + 1309, + 1038, + 1309, + 1087, + 1072, + 1087 + ], + "elements": [ + "#/readResults/0/lines/23/words/0", + "#/readResults/0/lines/23/words/1" + ] + }, + { + "rowIndex": 0, + "columnIndex": 3, + "text": "Total", + "boundingBox": [ + 1309, + 1038, + 1544, + 1038, + 1544, + 1087, + 1309, + 1087 + ], + "elements": [ + "#/readResults/0/lines/24/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Party Favor purple", + "boundingBox": [ + 156, + 1087, + 847, + 1087, + 847, + 1128, + 156, + 1128 + ], + "elements": [ + "#/readResults/0/lines/25/words/0", + "#/readResults/0/lines/25/words/1", + "#/readResults/0/lines/25/words/2" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1087, + 1072, + 1087, + 1072, + 1128, + 847, + 1128 + ], + "elements": [ + "#/readResults/0/lines/26/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "5.00", + "boundingBox": [ + 1072, + 1087, + 1309, + 1087, + 1309, + 1128, + 1072, + 1128 + ], + "elements": [ + "#/readResults/0/lines/27/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1087, + 1544, + 1087, + 1544, + 1128, + 1309, + 1128 + ], + "elements": [ + "#/readResults/0/lines/28/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Party Hat Blue", + "boundingBox": [ + 156, + 1128, + 847, + 1128, + 847, + 1172, + 156, + 1172 + ], + "elements": [ + "#/readResults/0/lines/29/words/0", + "#/readResults/0/lines/29/words/1", + "#/readResults/0/lines/29/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1128, + 1072, + 1128, + 1072, + 1172, + 847, + 1172 + ], + "elements": [ + "#/readResults/0/lines/30/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "5.00", + "boundingBox": [ + 1072, + 1128, + 1309, + 1128, + 1309, + 1172, + 1072, + 1172 + ], + "elements": [ + "#/readResults/0/lines/31/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1128, + 1544, + 1128, + 1544, + 1172, + 1309, + 1172 + ], + "elements": [ + "#/readResults/0/lines/32/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "Party Cloth White", + "boundingBox": [ + 156, + 1172, + 847, + 1172, + 847, + 1216, + 156, + 1216 + ], + "elements": [ + "#/readResults/0/lines/33/words/0", + "#/readResults/0/lines/33/words/1", + "#/readResults/0/lines/33/words/2" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1172, + 1072, + 1172, + 1072, + 1216, + 847, + 1216 + ], + "elements": [ + "#/readResults/0/lines/34/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "5,00", + "boundingBox": [ + 1072, + 1172, + 1309, + 1172, + 1309, + 1216, + 1072, + 1216 + ], + "elements": [ + "#/readResults/0/lines/35/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1172, + 1544, + 1172, + 1544, + 1216, + 1309, + 1216 + ], + "elements": [ + "#/readResults/0/lines/36/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 0, + "text": "Party Maraca White", + "boundingBox": [ + 156, + 1216, + 847, + 1216, + 847, + 1260, + 156, + 1260 + ], + "elements": [ + "#/readResults/0/lines/37/words/0", + "#/readResults/0/lines/37/words/1", + "#/readResults/0/lines/37/words/2" + ] + }, + { + "rowIndex": 4, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1216, + 1072, + 1216, + 1072, + 1260, + 847, + 1260 + ], + "elements": [ + "#/readResults/0/lines/38/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 2, + "text": "5,00", + "boundingBox": [ + 1072, + 1216, + 1309, + 1216, + 1309, + 1260, + 1072, + 1260 + ], + "elements": [ + "#/readResults/0/lines/39/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1216, + 1544, + 1216, + 1544, + 1260, + 1309, + 1260 + ], + "elements": [ + "#/readResults/0/lines/40/words/0" + ] + } + ] + }, + { + "rows": 4, + "columns": 3, + "cells": [ + { + "rowIndex": 1, + "columnIndex": 1, + "text": "SUBTOTAL", + "boundingBox": [ + 1072, + 1566, + 1309, + 1566, + 1309, + 1610, + 1072, + 1610 + ], + "elements": [ + "#/readResults/0/lines/41/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "$400.00", + "boundingBox": [ + 1309, + 1566, + 1544, + 1566, + 1544, + 1610, + 1309, + 1610 + ], + "elements": [ + "#/readResults/0/lines/42/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "TAX", + "boundingBox": [ + 1072, + 1610, + 1309, + 1610, + 1309, + 1658, + 1072, + 1658 + ], + "elements": [ + "#/readResults/0/lines/43/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "$14.00", + "boundingBox": [ + 1309, + 1610, + 1544, + 1610, + 1544, + 1658, + 1309, + 1658 + ], + "elements": [ + "#/readResults/0/lines/44/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "TOTAL", + "boundingBox": [ + 1072, + 1658, + 1309, + 1658, + 1309, + 1708, + 1072, + 1708 + ], + "elements": [ + "#/readResults/0/lines/46/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "$414.00", + "boundingBox": [ + 1309, + 1658, + 1544, + 1658, + 1544, + 1708, + 1309, + 1708 + ], + "elements": [ + "#/readResults/0/lines/47/words/0" + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg new file mode 100644 index 000000000000..d5ee64b5b6bc Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.labels.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.labels.json new file mode 100644 index 000000000000..c268869361bd --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.labels.json @@ -0,0 +1,511 @@ +{ + "document": "Form_4.jpg", + "labels": [ + { + "label": "Merchant", + "key": null, + "value": [ + { + "page": 1, + "text": "Hero", + "boundingBoxes": [ + [ + 0.3664705882352941, + 0.09409090909090909, + 0.4611764705882353, + 0.09272727272727273, + 0.46058823529411763, + 0.12136363636363637, + 0.3652941176470588, + 0.12090909090909091 + ] + ] + }, + { + "page": 1, + "text": "Limited", + "boundingBoxes": [ + [ + 0.47705882352941176, + 0.09272727272727273, + 0.6311764705882353, + 0.09181818181818181, + 0.6317647058823529, + 0.12090909090909091, + 0.4764705882352941, + 0.12136363636363637 + ] + ] + } + ] + }, + { + "label": "PhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "555-348-6512", + "boundingBoxes": [ + [ + 0.21705882352941178, + 0.15954545454545455, + 0.31176470588235294, + 0.16, + 0.31176470588235294, + 0.17, + 0.21705882352941178, + 0.17181818181818181 + ] + ] + } + ] + }, + { + "label": "Website", + "key": null, + "value": [ + { + "page": 1, + "text": "www.herolimited.com", + "boundingBoxes": [ + [ + 0.1623529411764706, + 0.17545454545454545, + 0.30823529411764705, + 0.17545454545454545, + 0.3088235294117647, + 0.18636363636363637, + 0.16176470588235295, + 0.18681818181818183 + ] + ] + } + ] + }, + { + "label": "Email", + "key": null, + "value": [ + { + "page": 1, + "text": "accounts@herolimited.com", + "boundingBoxes": [ + [ + 0.14294117647058824, + 0.19090909090909092, + 0.3241176470588235, + 0.19045454545454546, + 0.3241176470588235, + 0.20272727272727273, + 0.14294117647058824, + 0.20227272727272727 + ] + ] + } + ] + }, + { + "label": "DatedAs", + "key": null, + "value": [ + { + "page": 1, + "text": "04/04/2020", + "boundingBoxes": [ + [ + 0.6864705882352942, + 0.19090909090909092, + 0.7747058823529411, + 0.19045454545454546, + 0.7747058823529411, + 0.20454545454545456, + 0.6858823529411765, + 0.20454545454545456 + ] + ] + } + ] + }, + { + "label": "PurchaseOrderNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "3929423", + "boundingBoxes": [ + [ + 0.7541176470588236, + 0.20954545454545453, + 0.8170588235294117, + 0.20954545454545453, + 0.8164705882352942, + 0.22227272727272726, + 0.7535294117647059, + 0.22272727272727272 + ] + ] + } + ] + }, + { + "label": "VendorName", + "key": null, + "value": [ + { + "page": 1, + "text": "Seth", + "boundingBoxes": [ + [ + 0.2076470588235294, + 0.2772727272727273, + 0.2411764705882353, + 0.2772727272727273, + 0.2411764705882353, + 0.2909090909090909, + 0.20705882352941177, + 0.2909090909090909 + ] + ] + }, + { + "page": 1, + "text": "Stanley", + "boundingBoxes": [ + [ + 0.24411764705882352, + 0.2772727272727273, + 0.29764705882352943, + 0.2772727272727273, + 0.29764705882352943, + 0.2918181818181818, + 0.24411764705882352, + 0.2909090909090909 + ] + ] + } + ] + }, + { + "label": "CompanyName", + "key": null, + "value": [ + { + "page": 1, + "text": "Yoga", + "boundingBoxes": [ + [ + 0.2235294117647059, + 0.29409090909090907, + 0.26, + 0.29409090909090907, + 0.25882352941176473, + 0.30863636363636365, + 0.22294117647058823, + 0.3090909090909091 + ] + ] + }, + { + "page": 1, + "text": "for", + "boundingBoxes": [ + [ + 0.2635294117647059, + 0.29409090909090907, + 0.2847058823529412, + 0.29409090909090907, + 0.28352941176470586, + 0.30818181818181817, + 0.26235294117647057, + 0.30863636363636365 + ] + ] + }, + { + "page": 1, + "text": "You", + "boundingBoxes": [ + [ + 0.28823529411764703, + 0.29409090909090907, + 0.31470588235294117, + 0.29409090909090907, + 0.3135294117647059, + 0.30772727272727274, + 0.28705882352941176, + 0.30818181818181817 + ] + ] + } + ] + }, + { + "label": "CompanyAddress", + "key": null, + "value": [ + { + "page": 1, + "text": "343", + "boundingBoxes": [ + [ + 0.16294117647058823, + 0.31136363636363634, + 0.19117647058823528, + 0.31136363636363634, + 0.19117647058823528, + 0.3240909090909091, + 0.1623529411764706, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "E", + "boundingBoxes": [ + [ + 0.19470588235294117, + 0.31136363636363634, + 0.20352941176470588, + 0.31136363636363634, + 0.20352941176470588, + 0.3240909090909091, + 0.19470588235294117, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Winter", + "boundingBoxes": [ + [ + 0.20705882352941177, + 0.31136363636363634, + 0.25882352941176473, + 0.31136363636363634, + 0.25823529411764706, + 0.3240909090909091, + 0.20647058823529413, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Road", + "boundingBoxes": [ + [ + 0.26176470588235295, + 0.31136363636363634, + 0.3, + 0.31136363636363634, + 0.3, + 0.3240909090909091, + 0.26176470588235295, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Seattle,", + "boundingBoxes": [ + [ + 0.1635294117647059, + 0.3286363636363636, + 0.21941176470588236, + 0.3286363636363636, + 0.2188235294117647, + 0.3409090909090909, + 0.16294117647058823, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "WA", + "boundingBoxes": [ + [ + 0.2223529411764706, + 0.3286363636363636, + 0.2488235294117647, + 0.3281818181818182, + 0.24823529411764705, + 0.3409090909090909, + 0.22176470588235295, + 0.3409090909090909 + ] + ] + }, + { + "page": 1, + "text": "93849", + "boundingBoxes": [ + [ + 0.2529411764705882, + 0.3281818181818182, + 0.2988235294117647, + 0.3281818181818182, + 0.29823529411764704, + 0.3409090909090909, + 0.2523529411764706, + 0.3409090909090909 + ] + ] + } + ] + }, + { + "label": "CompanyPhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "234-986-6454", + "boundingBoxes": [ + [ + 0.36058823529411765, + 0.3281818181818182, + 0.4623529411764706, + 0.3277272727272727, + 0.46176470588235297, + 0.34, + 0.36, + 0.3409090909090909 + ] + ] + } + ] + }, + { + "label": "Quantity", + "key": null, + "value": [ + { + "page": 1, + "text": "50", + "boundingBoxes": [ + [ + 0.5076470588235295, + 0.49727272727272726, + 0.5252941176470588, + 0.49727272727272726, + 0.5252941176470588, + 0.5081818181818182, + 0.5076470588235295, + 0.5081818181818182 + ] + ] + } + ] + }, + { + "label": "Subtotal", + "key": null, + "value": [ + { + "page": 1, + "text": "$6750.00", + "boundingBoxes": [ + [ + 0.8311764705882353, + 0.7145454545454546, + 0.9005882352941177, + 0.7145454545454546, + 0.9, + 0.7268181818181818, + 0.831764705882353, + 0.7272727272727273 + ] + ] + } + ] + }, + { + "label": "Tax", + "key": null, + "value": [ + { + "page": 1, + "text": "$600.00", + "boundingBoxes": [ + [ + 0.8411764705882353, + 0.7345454545454545, + 0.9, + 0.7345454545454545, + 0.9, + 0.7459090909090909, + 0.8411764705882353, + 0.7468181818181818 + ] + ] + } + ] + }, + { + "label": "Signature", + "key": null, + "value": [ + { + "page": 1, + "text": "Josh", + "boundingBoxes": [ + [ + 0.25, + 0.7577272727272727, + 0.2917647058823529, + 0.7586363636363637, + 0.29058823529411765, + 0.775, + 0.2488235294117647, + 0.7731818181818182 + ] + ] + }, + { + "page": 1, + "text": "Granger", + "boundingBoxes": [ + [ + 0.2952941176470588, + 0.759090909090909, + 0.3688235294117647, + 0.7595454545454545, + 0.3688235294117647, + 0.7754545454545455, + 0.29470588235294115, + 0.775 + ] + ] + } + ] + }, + { + "label": "Total", + "key": null, + "value": [ + { + "page": 1, + "text": "$7350.00", + "boundingBoxes": [ + [ + 0.8311764705882353, + 0.759090909090909, + 0.9, + 0.759090909090909, + 0.9, + 0.7713636363636364, + 0.8311764705882353, + 0.7718181818181818 + ] + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.ocr.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.ocr.json new file mode 100644 index 000000000000..7591e39b5b6f --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_4.jpg.ocr.json @@ -0,0 +1,3382 @@ +{ + "status": "succeeded", + "createdDateTime": "2020-04-09T01:38:22Z", + "lastUpdatedDateTime": "2020-04-09T01:38:25Z", + "analyzeResult": { + "version": "2.0.0", + "readResults": [ + { + "page": 1, + "language": "en", + "angle": 0, + "width": 1700, + "height": 2200, + "unit": "pixel", + "lines": [ + { + "language": "en", + "boundingBox": [ + 137, + 140, + 351, + 140, + 351, + 167, + 137, + 166 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 137, + 141, + 263, + 140, + 264, + 168, + 138, + 166 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 272, + 140, + 350, + 140, + 351, + 168, + 272, + 168 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 620, + 204, + 1074, + 201, + 1074, + 264, + 620, + 267 + ], + "text": "Hero Limited", + "words": [ + { + "boundingBox": [ + 623, + 207, + 784, + 204, + 783, + 267, + 621, + 266 + ], + "text": "Hero", + "confidence": 0.959 + }, + { + "boundingBox": [ + 811, + 204, + 1073, + 202, + 1074, + 266, + 810, + 267 + ], + "text": "Limited", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 351, + 529, + 350, + 530, + 377, + 165, + 378 + ], + "text": "Company Phone: 555-348-6512", + "words": [ + { + "boundingBox": [ + 167, + 352, + 276, + 351, + 276, + 379, + 166, + 378 + ], + "text": "Company", + "confidence": 0.958 + }, + { + "boundingBox": [ + 282, + 351, + 364, + 351, + 364, + 378, + 281, + 379 + ], + "text": "Phone:", + "confidence": 0.951 + }, + { + "boundingBox": [ + 369, + 351, + 530, + 352, + 530, + 374, + 369, + 378 + ], + "text": "555-348-6512", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 320, + 1551, + 320, + 1551, + 370, + 1114, + 370 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 1115, + 322, + 1378, + 321, + 1378, + 371, + 1117, + 371 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1397, + 321, + 1551, + 322, + 1550, + 371, + 1397, + 371 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 385, + 530, + 385, + 530, + 410, + 166, + 410 + ], + "text": "Website: www.herolimited.com", + "words": [ + { + "boundingBox": [ + 168, + 386, + 271, + 386, + 271, + 411, + 166, + 410 + ], + "text": "Website:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 276, + 386, + 524, + 386, + 525, + 410, + 275, + 411 + ], + "text": "www.herolimited.com", + "confidence": 0.849 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 419, + 559, + 419, + 559, + 445, + 164, + 445 + ], + "text": "Email: accounts@herolimited.com", + "words": [ + { + "boundingBox": [ + 165, + 420, + 238, + 420, + 238, + 445, + 165, + 445 + ], + "text": "Email:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 243, + 420, + 551, + 419, + 551, + 446, + 243, + 445 + ], + "text": "accounts@herolimited.com", + "confidence": 0.844 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 419, + 1317, + 419, + 1317, + 449, + 1025, + 450 + ], + "text": "Dated As: 04/04/2020", + "words": [ + { + "boundingBox": [ + 1026, + 421, + 1111, + 420, + 1111, + 450, + 1025, + 450 + ], + "text": "Dated", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1117, + 420, + 1161, + 420, + 1161, + 450, + 1116, + 450 + ], + "text": "As:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1167, + 420, + 1317, + 419, + 1317, + 450, + 1166, + 450 + ], + "text": "04/04/2020", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 452, + 362, + 454, + 362, + 480, + 164, + 478 + ], + "text": "49823 Major Ave", + "words": [ + { + "boundingBox": [ + 167, + 453, + 237, + 454, + 236, + 479, + 166, + 478 + ], + "text": "49823", + "confidence": 0.959 + }, + { + "boundingBox": [ + 242, + 454, + 312, + 455, + 312, + 480, + 241, + 479 + ], + "text": "Major", + "confidence": 0.953 + }, + { + "boundingBox": [ + 317, + 455, + 362, + 454, + 361, + 481, + 317, + 480 + ], + "text": "Ave", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 461, + 1390, + 461, + 1390, + 488, + 1025, + 490 + ], + "text": "Purchase Order #: 3929423", + "words": [ + { + "boundingBox": [ + 1027, + 462, + 1153, + 461, + 1152, + 490, + 1026, + 489 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1160, + 461, + 1241, + 461, + 1240, + 490, + 1159, + 490 + ], + "text": "Order", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1247, + 461, + 1277, + 461, + 1276, + 490, + 1246, + 490 + ], + "text": "#:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1282, + 461, + 1389, + 461, + 1388, + 489, + 1281, + 490 + ], + "text": "3929423", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 162, + 485, + 368, + 485, + 368, + 512, + 162, + 512 + ], + "text": "Cheer, MS, 38601", + "words": [ + { + "boundingBox": [ + 166, + 487, + 241, + 487, + 240, + 511, + 165, + 512 + ], + "text": "Cheer,", + "confidence": 0.959 + }, + { + "boundingBox": [ + 246, + 487, + 291, + 486, + 290, + 511, + 245, + 511 + ], + "text": "MS,", + "confidence": 0.92 + }, + { + "boundingBox": [ + 296, + 486, + 368, + 486, + 368, + 513, + 295, + 512 + ], + "text": "38601", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 547, + 411, + 547, + 411, + 590, + 166, + 590 + ], + "text": "Shipped To:", + "words": [ + { + "boundingBox": [ + 167, + 547, + 336, + 549, + 336, + 591, + 167, + 591 + ], + "text": "Shipped", + "confidence": 0.849 + }, + { + "boundingBox": [ + 348, + 549, + 410, + 548, + 410, + 589, + 348, + 590 + ], + "text": "To:", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 609, + 506, + 609, + 506, + 641, + 160, + 639 + ], + "text": "Vendor Name: Seth Stanley", + "words": [ + { + "boundingBox": [ + 162, + 610, + 256, + 610, + 255, + 638, + 161, + 638 + ], + "text": "Vendor", + "confidence": 0.959 + }, + { + "boundingBox": [ + 261, + 610, + 347, + 610, + 347, + 639, + 260, + 638 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 353, + 610, + 410, + 610, + 410, + 640, + 352, + 640 + ], + "text": "Seth", + "confidence": 0.959 + }, + { + "boundingBox": [ + 415, + 610, + 506, + 610, + 506, + 642, + 415, + 640 + ], + "text": "Stanley", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 648, + 535, + 647, + 535, + 678, + 160, + 680 + ], + "text": "Company Name: Yoga for You", + "words": [ + { + "boundingBox": [ + 161, + 649, + 284, + 648, + 283, + 680, + 161, + 678 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 290, + 648, + 374, + 647, + 373, + 680, + 288, + 680 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 380, + 647, + 442, + 647, + 440, + 679, + 379, + 680 + ], + "text": "Yoga", + "confidence": 0.959 + }, + { + "boundingBox": [ + 448, + 647, + 484, + 647, + 482, + 678, + 446, + 679 + ], + "text": "for", + "confidence": 0.958 + }, + { + "boundingBox": [ + 490, + 647, + 535, + 647, + 533, + 677, + 488, + 678 + ], + "text": "You", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 161, + 684, + 509, + 684, + 509, + 712, + 161, + 712 + ], + "text": "Address: 343 E Winter Road", + "words": [ + { + "boundingBox": [ + 161, + 685, + 271, + 685, + 271, + 713, + 161, + 713 + ], + "text": "Address:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 277, + 685, + 325, + 685, + 325, + 713, + 276, + 713 + ], + "text": "343", + "confidence": 0.958 + }, + { + "boundingBox": [ + 331, + 685, + 346, + 685, + 346, + 713, + 331, + 713 + ], + "text": "E", + "confidence": 0.88 + }, + { + "boundingBox": [ + 352, + 685, + 440, + 685, + 439, + 713, + 351, + 713 + ], + "text": "Winter", + "confidence": 0.959 + }, + { + "boundingBox": [ + 445, + 685, + 510, + 685, + 510, + 713, + 445, + 713 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 275, + 722, + 786, + 721, + 786, + 749, + 275, + 750 + ], + "text": "Seattle, WA 93849 Phone: 234-986-6454", + "words": [ + { + "boundingBox": [ + 278, + 723, + 373, + 723, + 372, + 750, + 277, + 749 + ], + "text": "Seattle,", + "confidence": 0.944 + }, + { + "boundingBox": [ + 378, + 723, + 423, + 722, + 422, + 750, + 377, + 750 + ], + "text": "WA", + "confidence": 0.957 + }, + { + "boundingBox": [ + 430, + 722, + 508, + 722, + 507, + 750, + 429, + 750 + ], + "text": "93849", + "confidence": 0.958 + }, + { + "boundingBox": [ + 515, + 722, + 608, + 722, + 607, + 750, + 514, + 750 + ], + "text": "Phone:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 613, + 722, + 786, + 721, + 785, + 748, + 612, + 750 + ], + "text": "234-986-6454", + "confidence": 0.917 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 784, + 467, + 784, + 468, + 826, + 166, + 830 + ], + "text": "Shipped From:", + "words": [ + { + "boundingBox": [ + 167, + 784, + 337, + 784, + 336, + 829, + 166, + 830 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 346, + 784, + 468, + 784, + 467, + 823, + 345, + 828 + ], + "text": "From:", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 851, + 419, + 853, + 418, + 883, + 165, + 881 + ], + "text": "Name: Josh Granger", + "words": [ + { + "boundingBox": [ + 166, + 851, + 249, + 853, + 249, + 881, + 165, + 881 + ], + "text": "Name:", + "confidence": 0.909 + }, + { + "boundingBox": [ + 255, + 853, + 310, + 854, + 309, + 882, + 254, + 881 + ], + "text": "Josh", + "confidence": 0.959 + }, + { + "boundingBox": [ + 316, + 854, + 419, + 854, + 418, + 884, + 315, + 882 + ], + "text": "Granger", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 889, + 577, + 889, + 577, + 921, + 164, + 921 + ], + "text": "Company Name: Granger Supply", + "words": [ + { + "boundingBox": [ + 166, + 891, + 286, + 891, + 286, + 921, + 166, + 920 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 292, + 891, + 378, + 890, + 378, + 921, + 291, + 921 + ], + "text": "Name:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 384, + 890, + 485, + 890, + 485, + 922, + 383, + 921 + ], + "text": "Granger", + "confidence": 0.959 + }, + { + "boundingBox": [ + 491, + 890, + 576, + 890, + 576, + 922, + 490, + 922 + ], + "text": "Supply", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 925, + 489, + 926, + 489, + 956, + 166, + 954 + ], + "text": "Address: 922 N Ebby Lane", + "words": [ + { + "boundingBox": [ + 167, + 927, + 277, + 926, + 275, + 955, + 166, + 953 + ], + "text": "Address:", + "confidence": 0.954 + }, + { + "boundingBox": [ + 282, + 926, + 331, + 926, + 329, + 956, + 280, + 955 + ], + "text": "922", + "confidence": 0.958 + }, + { + "boundingBox": [ + 336, + 926, + 353, + 926, + 352, + 956, + 335, + 956 + ], + "text": "N", + "confidence": 0.883 + }, + { + "boundingBox": [ + 362, + 926, + 425, + 927, + 424, + 957, + 361, + 956 + ], + "text": "Ebby", + "confidence": 0.948 + }, + { + "boundingBox": [ + 430, + 927, + 489, + 928, + 487, + 957, + 429, + 957 + ], + "text": "Lane", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 278, + 964, + 787, + 963, + 787, + 991, + 278, + 992 + ], + "text": "Ft Lauderdale, FL Phone: 932-294-2958", + "words": [ + { + "boundingBox": [ + 280, + 965, + 304, + 965, + 301, + 991, + 278, + 991 + ], + "text": "Ft", + "confidence": 0.951 + }, + { + "boundingBox": [ + 309, + 965, + 455, + 964, + 453, + 992, + 307, + 991 + ], + "text": "Lauderdale,", + "confidence": 0.952 + }, + { + "boundingBox": [ + 460, + 964, + 491, + 964, + 489, + 992, + 458, + 992 + ], + "text": "FL", + "confidence": 0.942 + }, + { + "boundingBox": [ + 513, + 964, + 607, + 963, + 606, + 992, + 511, + 992 + ], + "text": "Phone:", + "confidence": 0.92 + }, + { + "boundingBox": [ + 613, + 963, + 786, + 963, + 785, + 991, + 611, + 992 + ], + "text": "932-294-2958", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 446, + 1047, + 557, + 1047, + 557, + 1079, + 446, + 1079 + ], + "text": "Details", + "words": [ + { + "boundingBox": [ + 446, + 1048, + 557, + 1047, + 556, + 1080, + 446, + 1079 + ], + "text": "Details", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 889, + 1045, + 1030, + 1046, + 1029, + 1084, + 889, + 1083 + ], + "text": "Quantity", + "words": [ + { + "boundingBox": [ + 889, + 1045, + 1029, + 1046, + 1027, + 1084, + 890, + 1083 + ], + "text": "Quantity", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 1046, + 1271, + 1047, + 1271, + 1078, + 1114, + 1077 + ], + "text": "Unit Price", + "words": [ + { + "boundingBox": [ + 1114, + 1047, + 1184, + 1047, + 1184, + 1078, + 1114, + 1077 + ], + "text": "Unit", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1047, + 1270, + 1047, + 1271, + 1079, + 1190, + 1078 + ], + "text": "Price", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1384, + 1047, + 1469, + 1047, + 1470, + 1076, + 1384, + 1077 + ], + "text": "Total", + "words": [ + { + "boundingBox": [ + 1387, + 1047, + 1470, + 1047, + 1470, + 1076, + 1387, + 1077 + ], + "text": "Total", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1094, + 360, + 1093, + 360, + 1124, + 170, + 1125 + ], + "text": "Long Yoga Mat", + "words": [ + { + "boundingBox": [ + 173, + 1094, + 233, + 1095, + 231, + 1125, + 171, + 1124 + ], + "text": "Long", + "confidence": 0.959 + }, + { + "boundingBox": [ + 239, + 1095, + 299, + 1094, + 297, + 1126, + 237, + 1125 + ], + "text": "Yoga", + "confidence": 0.944 + }, + { + "boundingBox": [ + 305, + 1094, + 359, + 1094, + 357, + 1125, + 303, + 1126 + ], + "text": "Mat", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 862, + 1094, + 895, + 1094, + 895, + 1118, + 862, + 1118 + ], + "text": "50", + "words": [ + { + "boundingBox": [ + 863, + 1094, + 893, + 1094, + 893, + 1118, + 863, + 1118 + ], + "text": "50", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1225, + 1094, + 1296, + 1094, + 1296, + 1118, + 1224, + 1119 + ], + "text": "50.00", + "words": [ + { + "boundingBox": [ + 1225, + 1094, + 1295, + 1094, + 1296, + 1118, + 1225, + 1119 + ], + "text": "50.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1427, + 1095, + 1531, + 1093, + 1531, + 1118, + 1427, + 1120 + ], + "text": "2500.00", + "words": [ + { + "boundingBox": [ + 1428, + 1095, + 1531, + 1094, + 1530, + 1118, + 1428, + 1120 + ], + "text": "2500.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1134, + 370, + 1134, + 370, + 1167, + 168, + 1166 + ], + "text": "Short Yoga Man", + "words": [ + { + "boundingBox": [ + 170, + 1135, + 239, + 1135, + 238, + 1166, + 169, + 1165 + ], + "text": "Short", + "confidence": 0.876 + }, + { + "boundingBox": [ + 245, + 1135, + 307, + 1135, + 306, + 1168, + 244, + 1167 + ], + "text": "Yoga", + "confidence": 0.955 + }, + { + "boundingBox": [ + 313, + 1135, + 370, + 1135, + 368, + 1168, + 311, + 1168 + ], + "text": "Man", + "confidence": 0.939 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 859, + 1136, + 894, + 1135, + 895, + 1158, + 859, + 1161 + ], + "text": "50", + "words": [ + { + "boundingBox": [ + 862, + 1136, + 893, + 1135, + 894, + 1158, + 863, + 1160 + ], + "text": "50", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1223, + 1135, + 1295, + 1134, + 1296, + 1158, + 1223, + 1160 + ], + "text": "50.00", + "words": [ + { + "boundingBox": [ + 1225, + 1135, + 1294, + 1134, + 1295, + 1159, + 1225, + 1160 + ], + "text": "50.00", + "confidence": 0.955 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1430, + 1136, + 1531, + 1135, + 1531, + 1159, + 1430, + 1160 + ], + "text": "2500.00", + "words": [ + { + "boundingBox": [ + 1430, + 1136, + 1530, + 1136, + 1530, + 1160, + 1430, + 1161 + ], + "text": "2500.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 169, + 1177, + 332, + 1177, + 332, + 1206, + 169, + 1205 + ], + "text": "Towel White", + "words": [ + { + "boundingBox": [ + 173, + 1177, + 248, + 1179, + 248, + 1206, + 172, + 1206 + ], + "text": "Towel", + "confidence": 0.951 + }, + { + "boundingBox": [ + 254, + 1179, + 332, + 1179, + 332, + 1205, + 254, + 1206 + ], + "text": "White", + "confidence": 0.955 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 863, + 1180, + 910, + 1179, + 909, + 1202, + 862, + 1203 + ], + "text": "100", + "words": [ + { + "boundingBox": [ + 864, + 1180, + 908, + 1179, + 909, + 1202, + 864, + 1203 + ], + "text": "100", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1222, + 1180, + 1296, + 1179, + 1296, + 1202, + 1222, + 1204 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1180, + 1296, + 1180, + 1295, + 1203, + 1227, + 1204 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1428, + 1180, + 1532, + 1180, + 1532, + 1203, + 1428, + 1204 + ], + "text": "1000.00", + "words": [ + { + "boundingBox": [ + 1431, + 1181, + 1529, + 1180, + 1529, + 1204, + 1431, + 1205 + ], + "text": "1000.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 171, + 1222, + 346, + 1222, + 346, + 1249, + 171, + 1249 + ], + "text": "Decal Stickers", + "words": [ + { + "boundingBox": [ + 173, + 1223, + 241, + 1223, + 241, + 1249, + 171, + 1250 + ], + "text": "Decal", + "confidence": 0.959 + }, + { + "boundingBox": [ + 247, + 1223, + 345, + 1223, + 346, + 1250, + 246, + 1249 + ], + "text": "Stickers", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 862, + 1223, + 894, + 1223, + 893, + 1246, + 861, + 1248 + ], + "text": "50", + "words": [ + { + "boundingBox": [ + 861, + 1223, + 892, + 1223, + 893, + 1247, + 862, + 1248 + ], + "text": "50", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1240, + 1222, + 1296, + 1223, + 1294, + 1246, + 1239, + 1245 + ], + "text": "5.00", + "words": [ + { + "boundingBox": [ + 1241, + 1222, + 1296, + 1223, + 1295, + 1246, + 1241, + 1245 + ], + "text": "5.00", + "confidence": 0.491 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1442, + 1222, + 1531, + 1222, + 1531, + 1247, + 1442, + 1247 + ], + "text": "250.00", + "words": [ + { + "boundingBox": [ + 1444, + 1223, + 1530, + 1223, + 1529, + 1248, + 1443, + 1248 + ], + "text": "250.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 171, + 1266, + 397, + 1266, + 397, + 1293, + 171, + 1292 + ], + "text": "Water Bottle Blue", + "words": [ + { + "boundingBox": [ + 172, + 1267, + 252, + 1268, + 253, + 1293, + 173, + 1291 + ], + "text": "Water", + "confidence": 0.959 + }, + { + "boundingBox": [ + 257, + 1268, + 333, + 1267, + 333, + 1293, + 257, + 1293 + ], + "text": "Bottle", + "confidence": 0.959 + }, + { + "boundingBox": [ + 339, + 1267, + 394, + 1266, + 394, + 1293, + 339, + 1293 + ], + "text": "Blue", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 863, + 1267, + 894, + 1266, + 894, + 1290, + 863, + 1290 + ], + "text": "50", + "words": [ + { + "boundingBox": [ + 863, + 1266, + 893, + 1266, + 893, + 1290, + 863, + 1290 + ], + "text": "50", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1224, + 1267, + 1296, + 1266, + 1297, + 1290, + 1225, + 1291 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1226, + 1267, + 1296, + 1266, + 1296, + 1290, + 1226, + 1291 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1444, + 1267, + 1531, + 1266, + 1531, + 1290, + 1444, + 1291 + ], + "text": "500.00", + "words": [ + { + "boundingBox": [ + 1444, + 1267, + 1529, + 1266, + 1528, + 1291, + 1444, + 1292 + ], + "text": "500.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1148, + 1574, + 1296, + 1574, + 1296, + 1599, + 1148, + 1599 + ], + "text": "SUBTOTAL", + "words": [ + { + "boundingBox": [ + 1149, + 1574, + 1295, + 1575, + 1295, + 1600, + 1149, + 1600 + ], + "text": "SUBTOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1411, + 1572, + 1531, + 1571, + 1531, + 1598, + 1411, + 1599 + ], + "text": "$6750.00", + "words": [ + { + "boundingBox": [ + 1413, + 1572, + 1531, + 1572, + 1530, + 1599, + 1414, + 1600 + ], + "text": "$6750.00", + "confidence": 0.944 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1239, + 1618, + 1295, + 1618, + 1295, + 1642, + 1239, + 1643 + ], + "text": "TAX", + "words": [ + { + "boundingBox": [ + 1241, + 1618, + 1293, + 1618, + 1293, + 1643, + 1241, + 1643 + ], + "text": "TAX", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1429, + 1616, + 1531, + 1615, + 1531, + 1641, + 1429, + 1642 + ], + "text": "$600.00", + "words": [ + { + "boundingBox": [ + 1430, + 1616, + 1530, + 1616, + 1530, + 1641, + 1430, + 1643 + ], + "text": "$600.00", + "confidence": 0.883 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 423, + 1667, + 627, + 1671, + 626, + 1706, + 423, + 1702 + ], + "text": "Josh Granger", + "words": [ + { + "boundingBox": [ + 425, + 1667, + 496, + 1669, + 494, + 1705, + 423, + 1701 + ], + "text": "Josh", + "confidence": 0.959 + }, + { + "boundingBox": [ + 502, + 1670, + 627, + 1671, + 627, + 1706, + 501, + 1705 + ], + "text": "Granger", + "confidence": 0.957 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1204, + 1672, + 1296, + 1672, + 1296, + 1699, + 1204, + 1699 + ], + "text": "TOTAL", + "words": [ + { + "boundingBox": [ + 1207, + 1674, + 1296, + 1673, + 1296, + 1699, + 1207, + 1699 + ], + "text": "TOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1411, + 1670, + 1530, + 1670, + 1530, + 1696, + 1411, + 1697 + ], + "text": "$7350.00", + "words": [ + { + "boundingBox": [ + 1413, + 1670, + 1530, + 1670, + 1530, + 1697, + 1413, + 1698 + ], + "text": "$7350.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 558, + 1719, + 704, + 1721, + 704, + 1744, + 557, + 1742 + ], + "text": "Josh Granger", + "words": [ + { + "boundingBox": [ + 559, + 1719, + 606, + 1720, + 605, + 1743, + 558, + 1742 + ], + "text": "Josh", + "confidence": 0.839 + }, + { + "boundingBox": [ + 612, + 1720, + 704, + 1721, + 703, + 1745, + 611, + 1743 + ], + "text": "Granger", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 543, + 1752, + 718, + 1754, + 718, + 1780, + 543, + 1778 + ], + "text": "Supply Manger", + "words": [ + { + "boundingBox": [ + 545, + 1752, + 623, + 1753, + 621, + 1780, + 543, + 1778 + ], + "text": "Supply", + "confidence": 0.959 + }, + { + "boundingBox": [ + 628, + 1753, + 719, + 1754, + 718, + 1781, + 626, + 1780 + ], + "text": "Manger", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1796, + 480, + 1797, + 479, + 1832, + 173, + 1830 + ], + "text": "Additional Notes:", + "words": [ + { + "boundingBox": [ + 175, + 1798, + 359, + 1797, + 358, + 1832, + 174, + 1830 + ], + "text": "Additional", + "confidence": 0.959 + }, + { + "boundingBox": [ + 365, + 1797, + 479, + 1800, + 479, + 1832, + 365, + 1832 + ], + "text": "Notes:", + "confidence": 0.948 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1879, + 1483, + 1878, + 1483, + 1914, + 172, + 1914 + ], + "text": "Enjoy. Namaste. If you have any issues with your Yoga supplies please contact us directly", + "words": [ + { + "boundingBox": [ + 174, + 1880, + 253, + 1880, + 251, + 1911, + 172, + 1910 + ], + "text": "Enjoy.", + "confidence": 0.956 + }, + { + "boundingBox": [ + 258, + 1880, + 403, + 1880, + 402, + 1913, + 257, + 1911 + ], + "text": "Namaste.", + "confidence": 0.949 + }, + { + "boundingBox": [ + 409, + 1880, + 431, + 1879, + 430, + 1913, + 408, + 1913 + ], + "text": "If", + "confidence": 0.958 + }, + { + "boundingBox": [ + 437, + 1879, + 493, + 1879, + 491, + 1913, + 436, + 1913 + ], + "text": "you", + "confidence": 0.958 + }, + { + "boundingBox": [ + 499, + 1879, + 574, + 1879, + 572, + 1914, + 497, + 1913 + ], + "text": "have", + "confidence": 0.959 + }, + { + "boundingBox": [ + 582, + 1879, + 638, + 1879, + 636, + 1914, + 580, + 1914 + ], + "text": "any", + "confidence": 0.958 + }, + { + "boundingBox": [ + 644, + 1879, + 743, + 1879, + 741, + 1915, + 642, + 1914 + ], + "text": "issues", + "confidence": 0.959 + }, + { + "boundingBox": [ + 749, + 1879, + 809, + 1879, + 807, + 1915, + 747, + 1915 + ], + "text": "with", + "confidence": 0.959 + }, + { + "boundingBox": [ + 816, + 1879, + 888, + 1879, + 886, + 1915, + 815, + 1915 + ], + "text": "your", + "confidence": 0.917 + }, + { + "boundingBox": [ + 894, + 1879, + 971, + 1879, + 970, + 1915, + 892, + 1915 + ], + "text": "Yoga", + "confidence": 0.958 + }, + { + "boundingBox": [ + 979, + 1879, + 1104, + 1879, + 1103, + 1914, + 977, + 1915 + ], + "text": "supplies", + "confidence": 0.955 + }, + { + "boundingBox": [ + 1110, + 1879, + 1212, + 1879, + 1210, + 1913, + 1108, + 1914 + ], + "text": "please", + "confidence": 0.948 + }, + { + "boundingBox": [ + 1218, + 1879, + 1329, + 1879, + 1327, + 1913, + 1216, + 1913 + ], + "text": "contact", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1335, + 1879, + 1374, + 1879, + 1372, + 1912, + 1333, + 1912 + ], + "text": "us", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1380, + 1879, + 1483, + 1879, + 1481, + 1911, + 1378, + 1912 + ], + "text": "directly", + "confidence": 0.939 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1926, + 935, + 1927, + 935, + 1961, + 168, + 1960 + ], + "text": "via email or at 250-209-1294 during business hours.", + "words": [ + { + "boundingBox": [ + 169, + 1929, + 210, + 1928, + 210, + 1959, + 168, + 1958 + ], + "text": "via", + "confidence": 0.862 + }, + { + "boundingBox": [ + 218, + 1928, + 303, + 1927, + 302, + 1960, + 218, + 1959 + ], + "text": "email", + "confidence": 0.897 + }, + { + "boundingBox": [ + 308, + 1927, + 339, + 1927, + 339, + 1960, + 308, + 1960 + ], + "text": "or", + "confidence": 0.958 + }, + { + "boundingBox": [ + 345, + 1927, + 378, + 1927, + 377, + 1961, + 345, + 1960 + ], + "text": "at", + "confidence": 0.909 + }, + { + "boundingBox": [ + 383, + 1927, + 595, + 1927, + 595, + 1962, + 383, + 1961 + ], + "text": "250-209-1294", + "confidence": 0.945 + }, + { + "boundingBox": [ + 601, + 1927, + 695, + 1927, + 695, + 1962, + 601, + 1962 + ], + "text": "during", + "confidence": 0.959 + }, + { + "boundingBox": [ + 701, + 1927, + 836, + 1928, + 836, + 1961, + 701, + 1962 + ], + "text": "business", + "confidence": 0.958 + }, + { + "boundingBox": [ + 842, + 1929, + 935, + 1930, + 935, + 1960, + 841, + 1961 + ], + "text": "hours.", + "confidence": 0.959 + } + ] + } + ] + } + ], + "pageResults": [ + { + "page": 1, + "tables": [ + { + "rows": 3, + "columns": 2, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Company Phone: 555-348-6512 Website: www.herolimited.com", + "boundingBox": [ + 165, + 351, + 815, + 351, + 815, + 415, + 165, + 415 + ], + "elements": [ + "#/readResults/0/lines/2/words/0", + "#/readResults/0/lines/2/words/1", + "#/readResults/0/lines/2/words/2", + "#/readResults/0/lines/4/words/0", + "#/readResults/0/lines/4/words/1" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Email: accounts@herolimited.com", + "boundingBox": [ + 165, + 415, + 815, + 415, + 815, + 453, + 165, + 453 + ], + "elements": [ + "#/readResults/0/lines/5/words/0", + "#/readResults/0/lines/5/words/1" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "Dated As: 04/04/2020", + "boundingBox": [ + 815, + 415, + 1389, + 415, + 1389, + 453, + 815, + 453 + ], + "elements": [ + "#/readResults/0/lines/6/words/0", + "#/readResults/0/lines/6/words/1", + "#/readResults/0/lines/6/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "49823 Major Ave", + "boundingBox": [ + 165, + 453, + 815, + 453, + 815, + 490, + 165, + 490 + ], + "elements": [ + "#/readResults/0/lines/7/words/0", + "#/readResults/0/lines/7/words/1", + "#/readResults/0/lines/7/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "Purchase Order #: 3929423", + "boundingBox": [ + 815, + 453, + 1389, + 453, + 1389, + 490, + 815, + 490 + ], + "elements": [ + "#/readResults/0/lines/8/words/0", + "#/readResults/0/lines/8/words/1", + "#/readResults/0/lines/8/words/2", + "#/readResults/0/lines/8/words/3" + ] + } + ] + }, + { + "rows": 7, + "columns": 4, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Details", + "boundingBox": [ + 156, + 1038, + 847, + 1038, + 847, + 1087, + 156, + 1087 + ], + "elements": [ + "#/readResults/0/lines/20/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 1, + "text": "Quantity", + "boundingBox": [ + 847, + 1038, + 1072, + 1038, + 1072, + 1087, + 847, + 1087 + ], + "elements": [ + "#/readResults/0/lines/21/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 2, + "text": "Unit Price", + "boundingBox": [ + 1072, + 1038, + 1309, + 1038, + 1309, + 1087, + 1072, + 1087 + ], + "elements": [ + "#/readResults/0/lines/22/words/0", + "#/readResults/0/lines/22/words/1" + ] + }, + { + "rowIndex": 0, + "columnIndex": 3, + "text": "Total", + "boundingBox": [ + 1309, + 1038, + 1544, + 1038, + 1544, + 1087, + 1309, + 1087 + ], + "elements": [ + "#/readResults/0/lines/23/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Long Yoga Mat", + "boundingBox": [ + 156, + 1087, + 847, + 1087, + 847, + 1128, + 156, + 1128 + ], + "elements": [ + "#/readResults/0/lines/24/words/0", + "#/readResults/0/lines/24/words/1", + "#/readResults/0/lines/24/words/2" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "50", + "boundingBox": [ + 847, + 1087, + 1072, + 1087, + 1072, + 1128, + 847, + 1128 + ], + "elements": [ + "#/readResults/0/lines/25/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "50.00", + "boundingBox": [ + 1072, + 1087, + 1309, + 1087, + 1309, + 1128, + 1072, + 1128 + ], + "elements": [ + "#/readResults/0/lines/26/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 3, + "text": "2500.00", + "boundingBox": [ + 1309, + 1087, + 1544, + 1087, + 1544, + 1128, + 1309, + 1128 + ], + "elements": [ + "#/readResults/0/lines/27/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Short Yoga Man", + "boundingBox": [ + 156, + 1128, + 847, + 1128, + 847, + 1172, + 156, + 1172 + ], + "elements": [ + "#/readResults/0/lines/28/words/0", + "#/readResults/0/lines/28/words/1", + "#/readResults/0/lines/28/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "50", + "boundingBox": [ + 847, + 1128, + 1072, + 1128, + 1072, + 1172, + 847, + 1172 + ], + "elements": [ + "#/readResults/0/lines/29/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "50.00", + "boundingBox": [ + 1072, + 1128, + 1309, + 1128, + 1309, + 1172, + 1072, + 1172 + ], + "elements": [ + "#/readResults/0/lines/30/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 3, + "text": "2500.00", + "boundingBox": [ + 1309, + 1128, + 1544, + 1128, + 1544, + 1172, + 1309, + 1172 + ], + "elements": [ + "#/readResults/0/lines/31/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "Towel White", + "boundingBox": [ + 156, + 1172, + 847, + 1172, + 847, + 1216, + 156, + 1216 + ], + "elements": [ + "#/readResults/0/lines/32/words/0", + "#/readResults/0/lines/32/words/1" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "100", + "boundingBox": [ + 847, + 1172, + 1072, + 1172, + 1072, + 1216, + 847, + 1216 + ], + "elements": [ + "#/readResults/0/lines/33/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1172, + 1309, + 1172, + 1309, + 1216, + 1072, + 1216 + ], + "elements": [ + "#/readResults/0/lines/34/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 3, + "text": "1000.00", + "boundingBox": [ + 1309, + 1172, + 1544, + 1172, + 1544, + 1216, + 1309, + 1216 + ], + "elements": [ + "#/readResults/0/lines/35/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 0, + "text": "Decal Stickers", + "boundingBox": [ + 156, + 1216, + 847, + 1216, + 847, + 1260, + 156, + 1260 + ], + "elements": [ + "#/readResults/0/lines/36/words/0", + "#/readResults/0/lines/36/words/1" + ] + }, + { + "rowIndex": 4, + "columnIndex": 1, + "text": "50", + "boundingBox": [ + 847, + 1216, + 1072, + 1216, + 1072, + 1260, + 847, + 1260 + ], + "elements": [ + "#/readResults/0/lines/37/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 2, + "text": "5.00", + "boundingBox": [ + 1072, + 1216, + 1309, + 1216, + 1309, + 1260, + 1072, + 1260 + ], + "elements": [ + "#/readResults/0/lines/38/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 3, + "text": "250.00", + "boundingBox": [ + 1309, + 1216, + 1544, + 1216, + 1544, + 1260, + 1309, + 1260 + ], + "elements": [ + "#/readResults/0/lines/39/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 0, + "text": "Water Bottle Blue", + "boundingBox": [ + 156, + 1260, + 847, + 1260, + 847, + 1303, + 156, + 1303 + ], + "elements": [ + "#/readResults/0/lines/40/words/0", + "#/readResults/0/lines/40/words/1", + "#/readResults/0/lines/40/words/2" + ] + }, + { + "rowIndex": 5, + "columnIndex": 1, + "text": "50", + "boundingBox": [ + 847, + 1260, + 1072, + 1260, + 1072, + 1303, + 847, + 1303 + ], + "elements": [ + "#/readResults/0/lines/41/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1260, + 1309, + 1260, + 1309, + 1303, + 1072, + 1303 + ], + "elements": [ + "#/readResults/0/lines/42/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 3, + "text": "500.00", + "boundingBox": [ + 1309, + 1260, + 1544, + 1260, + 1544, + 1303, + 1309, + 1303 + ], + "elements": [ + "#/readResults/0/lines/43/words/0" + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg new file mode 100644 index 000000000000..266cfecffdbe Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.labels.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.labels.json new file mode 100644 index 000000000000..287b6eb7a62c --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.labels.json @@ -0,0 +1,495 @@ +{ + "document": "Form_5.jpg", + "labels": [ + { + "label": "Merchant", + "key": null, + "value": [ + { + "page": 1, + "text": "Hero", + "boundingBoxes": [ + [ + 0.3658823529411765, + 0.09409090909090909, + 0.46352941176470586, + 0.09272727272727273, + 0.46294117647058824, + 0.12090909090909091, + 0.3652941176470588, + 0.12090909090909091 + ] + ] + }, + { + "page": 1, + "text": "Limited", + "boundingBoxes": [ + [ + 0.47705882352941176, + 0.09272727272727273, + 0.6323529411764706, + 0.09181818181818181, + 0.6323529411764706, + 0.12090909090909091, + 0.47705882352941176, + 0.12090909090909091 + ] + ] + } + ] + }, + { + "label": "PhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "555-348-6512", + "boundingBoxes": [ + [ + 0.21588235294117647, + 0.15954545454545455, + 0.3111764705882353, + 0.16, + 0.3111764705882353, + 0.17, + 0.21588235294117647, + 0.17181818181818181 + ] + ] + } + ] + }, + { + "label": "Website", + "key": null, + "value": [ + { + "page": 1, + "text": "www.herolimited.com", + "boundingBoxes": [ + [ + 0.16176470588235295, + 0.17863636363636365, + 0.31058823529411766, + 0.17863636363636365, + 0.3111764705882353, + 0.19, + 0.16117647058823528, + 0.19045454545454546 + ] + ] + } + ] + }, + { + "label": "DatedAs", + "key": null, + "value": [ + { + "page": 1, + "text": "02/09/2020", + "boundingBoxes": [ + [ + 0.6858823529411765, + 0.19090909090909092, + 0.7747058823529411, + 0.19090909090909092, + 0.7747058823529411, + 0.20454545454545456, + 0.6852941176470588, + 0.20454545454545456 + ] + ] + } + ] + }, + { + "label": "Email", + "key": null, + "value": [ + { + "page": 1, + "text": "accounts@herolimited.com", + "boundingBoxes": [ + [ + 0.0976470588235294, + 0.22, + 0.27941176470588236, + 0.21818181818181817, + 0.2782352941176471, + 0.22863636363636364, + 0.0976470588235294, + 0.22863636363636364 + ] + ] + } + ] + }, + { + "label": "PurchaseOrderNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "2992848", + "boundingBoxes": [ + [ + 0.7535294117647059, + 0.20954545454545453, + 0.8170588235294117, + 0.20954545454545453, + 0.8164705882352942, + 0.22181818181818183, + 0.7529411764705882, + 0.22272727272727272 + ] + ] + } + ] + }, + { + "label": "VendorName", + "key": null, + "value": [ + { + "page": 1, + "text": "Jack", + "boundingBoxes": [ + [ + 0.20588235294117646, + 0.2772727272727273, + 0.2388235294117647, + 0.2772727272727273, + 0.23823529411764705, + 0.2913636363636364, + 0.20588235294117646, + 0.2909090909090909 + ] + ] + }, + { + "page": 1, + "text": "Sprat", + "boundingBoxes": [ + [ + 0.24176470588235294, + 0.2772727272727273, + 0.2811764705882353, + 0.2772727272727273, + 0.2811764705882353, + 0.2918181818181818, + 0.24176470588235294, + 0.2913636363636364 + ] + ] + } + ] + }, + { + "label": "CompanyName", + "key": null, + "value": [ + { + "page": 1, + "text": "Jackrabbit", + "boundingBoxes": [ + [ + 0.2211764705882353, + 0.29409090909090907, + 0.2958823529411765, + 0.29409090909090907, + 0.2958823529411765, + 0.30863636363636365, + 0.2211764705882353, + 0.30863636363636365 + ] + ] + }, + { + "page": 1, + "text": "Printing", + "boundingBoxes": [ + [ + 0.3, + 0.29409090909090907, + 0.36, + 0.29363636363636364, + 0.3594117647058824, + 0.30954545454545457, + 0.3, + 0.30863636363636365 + ] + ] + } + ] + }, + { + "label": "CompanyAddress", + "key": null, + "value": [ + { + "page": 1, + "text": "342", + "boundingBoxes": [ + [ + 0.16176470588235295, + 0.31136363636363634, + 0.19058823529411764, + 0.31136363636363634, + 0.19058823529411764, + 0.3236363636363636, + 0.16176470588235295, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "W", + "boundingBoxes": [ + [ + 0.19411764705882353, + 0.31136363636363634, + 0.20529411764705882, + 0.31136363636363634, + 0.20529411764705882, + 0.3240909090909091, + 0.19411764705882353, + 0.3236363636363636 + ] + ] + }, + { + "page": 1, + "text": "Wrinkle", + "boundingBoxes": [ + [ + 0.21411764705882352, + 0.31136363636363634, + 0.27176470588235296, + 0.31136363636363634, + 0.27176470588235296, + 0.3240909090909091, + 0.21411764705882352, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Road", + "boundingBoxes": [ + [ + 0.2752941176470588, + 0.31136363636363634, + 0.3135294117647059, + 0.31136363636363634, + 0.3135294117647059, + 0.3240909090909091, + 0.2752941176470588, + 0.3240909090909091 + ] + ] + }, + { + "page": 1, + "text": "Bozeman", + "boundingBoxes": [ + [ + 0.16117647058823528, + 0.3290909090909091, + 0.22764705882352942, + 0.3286363636363636, + 0.22705882352941176, + 0.34045454545454545, + 0.16058823529411764, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "MT", + "boundingBoxes": [ + [ + 0.23176470588235293, + 0.3286363636363636, + 0.2570588235294118, + 0.3286363636363636, + 0.2564705882352941, + 0.34045454545454545, + 0.2311764705882353, + 0.34045454545454545 + ] + ] + }, + { + "page": 1, + "text": "83839", + "boundingBoxes": [ + [ + 0.26, + 0.3286363636363636, + 0.30470588235294116, + 0.3286363636363636, + 0.30470588235294116, + 0.34, + 0.25941176470588234, + 0.34045454545454545 + ] + ] + } + ] + }, + { + "label": "CompanyPhoneNumber", + "key": null, + "value": [ + { + "page": 1, + "text": "938-294-2949", + "boundingBoxes": [ + [ + 0.5041176470588236, + 0.3281818181818182, + 0.6070588235294118, + 0.3281818181818182, + 0.6064705882352941, + 0.34, + 0.5041176470588236, + 0.34045454545454545 + ] + ] + } + ] + }, + { + "label": "Quantity", + "key": null, + "value": [ + { + "page": 1, + "text": "20", + "boundingBoxes": [ + [ + 0.5064705882352941, + 0.4959090909090909, + 0.5252941176470588, + 0.495, + 0.5264705882352941, + 0.5081818181818182, + 0.5076470588235295, + 0.509090909090909 + ] + ] + } + ] + }, + { + "label": "Subtotal", + "key": null, + "value": [ + { + "page": 1, + "text": "$900.00", + "boundingBoxes": [ + [ + 0.8405882352941176, + 0.7140909090909091, + 0.9, + 0.7136363636363636, + 0.9, + 0.7263636363636363, + 0.8405882352941176, + 0.7268181818181818 + ] + ] + } + ] + }, + { + "label": "Tax", + "key": null, + "value": [ + { + "page": 1, + "text": "$100.00", + "boundingBoxes": [ + [ + 0.84, + 0.7345454545454545, + 0.9005882352941177, + 0.7336363636363636, + 0.9005882352941177, + 0.7459090909090909, + 0.8405882352941176, + 0.7468181818181818 + ] + ] + } + ] + }, + { + "label": "Signature", + "key": null, + "value": [ + { + "page": 1, + "text": "Wesley", + "boundingBoxes": [ + [ + 0.3123529411764706, + 0.759090909090909, + 0.3735294117647059, + 0.7595454545454545, + 0.3729411764705882, + 0.7777272727272727, + 0.31176470588235294, + 0.7781818181818182 + ] + ] + }, + { + "page": 1, + "text": "Snipes", + "boundingBoxes": [ + [ + 0.37823529411764706, + 0.7595454545454545, + 0.4323529411764706, + 0.7595454545454545, + 0.43176470588235294, + 0.7786363636363637, + 0.37823529411764706, + 0.7777272727272727 + ] + ] + } + ] + }, + { + "label": "Total", + "key": null, + "value": [ + { + "page": 1, + "text": "$1000.00", + "boundingBoxes": [ + [ + 0.8305882352941176, + 0.7595454545454545, + 0.9, + 0.7586363636363637, + 0.9005882352941177, + 0.7709090909090909, + 0.8305882352941176, + 0.7722727272727272 + ] + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.ocr.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.ocr.json new file mode 100644 index 000000000000..ce52e1712656 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/Form_5.jpg.ocr.json @@ -0,0 +1,3489 @@ +{ + "status": "succeeded", + "createdDateTime": "2020-04-09T01:36:12Z", + "lastUpdatedDateTime": "2020-04-09T01:36:15Z", + "analyzeResult": { + "version": "2.0.0", + "readResults": [ + { + "page": 1, + "language": "en", + "angle": -0.0425, + "width": 1700, + "height": 2200, + "unit": "pixel", + "lines": [ + { + "language": "en", + "boundingBox": [ + 137, + 140, + 351, + 140, + 351, + 167, + 137, + 166 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 137, + 140, + 263, + 140, + 263, + 168, + 138, + 166 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 271, + 140, + 351, + 140, + 351, + 168, + 272, + 168 + ], + "text": "Order", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 620, + 204, + 1073, + 201, + 1074, + 264, + 620, + 266 + ], + "text": "Hero Limited", + "words": [ + { + "boundingBox": [ + 622, + 207, + 788, + 204, + 787, + 266, + 621, + 266 + ], + "text": "Hero", + "confidence": 0.959 + }, + { + "boundingBox": [ + 811, + 204, + 1075, + 202, + 1075, + 266, + 811, + 266 + ], + "text": "Limited", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 351, + 529, + 350, + 530, + 377, + 165, + 379 + ], + "text": "Company Phone: 555-348-6512", + "words": [ + { + "boundingBox": [ + 167, + 352, + 275, + 351, + 275, + 379, + 167, + 379 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 281, + 351, + 362, + 351, + 362, + 378, + 280, + 379 + ], + "text": "Phone:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 367, + 351, + 529, + 352, + 529, + 374, + 367, + 378 + ], + "text": "555-348-6512", + "confidence": 0.946 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 320, + 1551, + 320, + 1551, + 370, + 1114, + 370 + ], + "text": "Purchase Order", + "words": [ + { + "boundingBox": [ + 1115, + 322, + 1377, + 321, + 1377, + 371, + 1117, + 371 + ], + "text": "Purchase", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1396, + 321, + 1551, + 321, + 1549, + 371, + 1396, + 371 + ], + "text": "Order", + "confidence": 0.951 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 392, + 534, + 392, + 534, + 419, + 167, + 418 + ], + "text": "Website: www.herolimited.com", + "words": [ + { + "boundingBox": [ + 168, + 392, + 270, + 393, + 269, + 419, + 167, + 418 + ], + "text": "Website:", + "confidence": 0.957 + }, + { + "boundingBox": [ + 275, + 393, + 528, + 393, + 529, + 418, + 274, + 419 + ], + "text": "www.herolimited.com", + "confidence": 0.872 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 437, + 236, + 437, + 236, + 459, + 164, + 459 + ], + "text": "Email:", + "words": [ + { + "boundingBox": [ + 165, + 437, + 236, + 437, + 237, + 460, + 165, + 459 + ], + "text": "Email:", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 420, + 1317, + 419, + 1317, + 449, + 1025, + 449 + ], + "text": "Dated As: 02/09/2020", + "words": [ + { + "boundingBox": [ + 1026, + 421, + 1111, + 420, + 1110, + 450, + 1025, + 450 + ], + "text": "Dated", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1118, + 420, + 1160, + 420, + 1159, + 450, + 1118, + 450 + ], + "text": "As:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1166, + 420, + 1317, + 420, + 1317, + 450, + 1165, + 450 + ], + "text": "02/09/2020", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 480, + 482, + 479, + 482, + 502, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "words": [ + { + "boundingBox": [ + 166, + 484, + 475, + 480, + 473, + 503, + 166, + 503 + ], + "text": "accounts@herolimited.com", + "confidence": 0.856 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1025, + 461, + 1389, + 461, + 1389, + 489, + 1025, + 490 + ], + "text": "Purchase Order #: 2992848", + "words": [ + { + "boundingBox": [ + 1027, + 462, + 1154, + 461, + 1153, + 490, + 1026, + 489 + ], + "text": "Purchase", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1160, + 461, + 1241, + 461, + 1240, + 490, + 1159, + 490 + ], + "text": "Order", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1246, + 461, + 1276, + 461, + 1275, + 490, + 1245, + 490 + ], + "text": "#:", + "confidence": 0.941 + }, + { + "boundingBox": [ + 1281, + 461, + 1389, + 461, + 1388, + 488, + 1280, + 490 + ], + "text": "2992848", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 166, + 546, + 394, + 546, + 394, + 594, + 166, + 594 + ], + "text": "Shipped To", + "words": [ + { + "boundingBox": [ + 167, + 546, + 336, + 548, + 337, + 593, + 168, + 595 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 346, + 548, + 393, + 547, + 393, + 593, + 346, + 593 + ], + "text": "To", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 609, + 479, + 609, + 479, + 641, + 160, + 639 + ], + "text": "Vendor Name: Jack Sprat", + "words": [ + { + "boundingBox": [ + 162, + 610, + 257, + 610, + 256, + 639, + 160, + 638 + ], + "text": "Vendor", + "confidence": 0.958 + }, + { + "boundingBox": [ + 262, + 610, + 345, + 610, + 344, + 640, + 261, + 639 + ], + "text": "Name:", + "confidence": 0.945 + }, + { + "boundingBox": [ + 350, + 610, + 406, + 610, + 405, + 641, + 350, + 640 + ], + "text": "Jack", + "confidence": 0.959 + }, + { + "boundingBox": [ + 411, + 610, + 478, + 610, + 478, + 642, + 411, + 641 + ], + "text": "Sprat", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 160, + 646, + 612, + 646, + 612, + 680, + 160, + 680 + ], + "text": "Company Name: Jackrabbit Printing", + "words": [ + { + "boundingBox": [ + 160, + 647, + 280, + 647, + 280, + 679, + 160, + 681 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 287, + 647, + 369, + 647, + 369, + 679, + 287, + 679 + ], + "text": "Name:", + "confidence": 0.909 + }, + { + "boundingBox": [ + 376, + 647, + 503, + 647, + 503, + 679, + 376, + 679 + ], + "text": "Jackrabbit", + "confidence": 0.95 + }, + { + "boundingBox": [ + 510, + 647, + 612, + 646, + 611, + 681, + 510, + 679 + ], + "text": "Printing", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 161, + 684, + 534, + 684, + 534, + 713, + 161, + 712 + ], + "text": "Address: 342 W Wrinkle Road", + "words": [ + { + "boundingBox": [ + 161, + 684, + 270, + 685, + 270, + 713, + 161, + 713 + ], + "text": "Address:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 275, + 685, + 324, + 685, + 324, + 712, + 275, + 713 + ], + "text": "342", + "confidence": 0.958 + }, + { + "boundingBox": [ + 330, + 685, + 349, + 685, + 349, + 713, + 330, + 712 + ], + "text": "W", + "confidence": 0.888 + }, + { + "boundingBox": [ + 364, + 685, + 462, + 685, + 462, + 713, + 364, + 713 + ], + "text": "Wrinkle", + "confidence": 0.959 + }, + { + "boundingBox": [ + 468, + 685, + 533, + 685, + 533, + 713, + 468, + 713 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 272, + 723, + 518, + 723, + 518, + 748, + 272, + 748 + ], + "text": "Bozeman MT 83839", + "words": [ + { + "boundingBox": [ + 274, + 724, + 387, + 723, + 386, + 749, + 273, + 749 + ], + "text": "Bozeman", + "confidence": 0.958 + }, + { + "boundingBox": [ + 394, + 723, + 437, + 723, + 436, + 749, + 393, + 749 + ], + "text": "MT", + "confidence": 0.948 + }, + { + "boundingBox": [ + 442, + 723, + 518, + 723, + 518, + 748, + 441, + 749 + ], + "text": "83839", + "confidence": 0.949 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 759, + 721, + 1032, + 721, + 1032, + 748, + 759, + 749 + ], + "text": "Phone: 938-294-2949", + "words": [ + { + "boundingBox": [ + 761, + 723, + 852, + 722, + 852, + 749, + 761, + 748 + ], + "text": "Phone:", + "confidence": 0.959 + }, + { + "boundingBox": [ + 857, + 722, + 1032, + 722, + 1031, + 748, + 857, + 749 + ], + "text": "938-294-2949", + "confidence": 0.934 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 783, + 450, + 783, + 451, + 826, + 165, + 830 + ], + "text": "Shipped From", + "words": [ + { + "boundingBox": [ + 166, + 784, + 336, + 784, + 335, + 829, + 166, + 830 + ], + "text": "Shipped", + "confidence": 0.959 + }, + { + "boundingBox": [ + 345, + 784, + 441, + 783, + 440, + 824, + 344, + 828 + ], + "text": "From", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 165, + 851, + 436, + 852, + 436, + 883, + 164, + 881 + ], + "text": "Name: Wesley Snipes", + "words": [ + { + "boundingBox": [ + 166, + 851, + 252, + 852, + 250, + 882, + 165, + 882 + ], + "text": "Name:", + "confidence": 0.958 + }, + { + "boundingBox": [ + 258, + 852, + 348, + 853, + 347, + 882, + 256, + 882 + ], + "text": "Wesley", + "confidence": 0.959 + }, + { + "boundingBox": [ + 354, + 853, + 435, + 853, + 434, + 884, + 353, + 882 + ], + "text": "Snipes", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 164, + 890, + 486, + 889, + 487, + 917, + 164, + 920 + ], + "text": "Company Name: We Sew", + "words": [ + { + "boundingBox": [ + 167, + 890, + 287, + 890, + 287, + 920, + 166, + 920 + ], + "text": "Company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 293, + 890, + 377, + 890, + 377, + 918, + 293, + 920 + ], + "text": "Name:", + "confidence": 0.917 + }, + { + "boundingBox": [ + 383, + 890, + 427, + 890, + 427, + 917, + 383, + 918 + ], + "text": "We", + "confidence": 0.958 + }, + { + "boundingBox": [ + 433, + 890, + 481, + 890, + 481, + 915, + 433, + 917 + ], + "text": "Sew", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 167, + 926, + 523, + 926, + 523, + 952, + 167, + 953 + ], + "text": "Address: 998 N Groove Road", + "words": [ + { + "boundingBox": [ + 169, + 927, + 276, + 926, + 275, + 954, + 168, + 954 + ], + "text": "Address:", + "confidence": 0.916 + }, + { + "boundingBox": [ + 282, + 926, + 330, + 926, + 328, + 954, + 280, + 954 + ], + "text": "998", + "confidence": 0.958 + }, + { + "boundingBox": [ + 335, + 926, + 353, + 926, + 351, + 954, + 334, + 954 + ], + "text": "N", + "confidence": 0.879 + }, + { + "boundingBox": [ + 362, + 926, + 454, + 926, + 452, + 953, + 360, + 954 + ], + "text": "Groove", + "confidence": 0.887 + }, + { + "boundingBox": [ + 459, + 926, + 524, + 927, + 522, + 953, + 458, + 953 + ], + "text": "Road", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 272, + 965, + 497, + 964, + 497, + 991, + 272, + 992 + ], + "text": "Seattle WA 83838", + "words": [ + { + "boundingBox": [ + 273, + 966, + 362, + 965, + 362, + 990, + 273, + 992 + ], + "text": "Seattle", + "confidence": 0.959 + }, + { + "boundingBox": [ + 367, + 965, + 413, + 965, + 413, + 990, + 367, + 990 + ], + "text": "WA", + "confidence": 0.958 + }, + { + "boundingBox": [ + 420, + 965, + 498, + 964, + 498, + 992, + 420, + 990 + ], + "text": "83838", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 649, + 963, + 918, + 963, + 919, + 990, + 649, + 991 + ], + "text": "Phone: 334-244-2949", + "words": [ + { + "boundingBox": [ + 649, + 964, + 742, + 964, + 742, + 991, + 649, + 992 + ], + "text": "Phone:", + "confidence": 0.93 + }, + { + "boundingBox": [ + 748, + 963, + 919, + 963, + 918, + 990, + 748, + 991 + ], + "text": "334-244-2949", + "confidence": 0.943 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 447, + 1045, + 557, + 1045, + 557, + 1079, + 447, + 1079 + ], + "text": "Details", + "words": [ + { + "boundingBox": [ + 448, + 1048, + 555, + 1046, + 556, + 1080, + 449, + 1079 + ], + "text": "Details", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 888, + 1045, + 1032, + 1046, + 1032, + 1084, + 888, + 1083 + ], + "text": "Quantity", + "words": [ + { + "boundingBox": [ + 889, + 1046, + 1033, + 1047, + 1032, + 1083, + 888, + 1082 + ], + "text": "Quantity", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1114, + 1046, + 1271, + 1047, + 1271, + 1078, + 1113, + 1077 + ], + "text": "Unit Price", + "words": [ + { + "boundingBox": [ + 1114, + 1047, + 1184, + 1047, + 1184, + 1078, + 1114, + 1077 + ], + "text": "Unit", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1047, + 1272, + 1047, + 1272, + 1079, + 1190, + 1078 + ], + "text": "Price", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1384, + 1047, + 1469, + 1046, + 1470, + 1076, + 1384, + 1077 + ], + "text": "Total", + "words": [ + { + "boundingBox": [ + 1387, + 1046, + 1468, + 1046, + 1469, + 1076, + 1387, + 1077 + ], + "text": "Total", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 169, + 1094, + 334, + 1095, + 334, + 1120, + 169, + 1120 + ], + "text": "Black Sweats", + "words": [ + { + "boundingBox": [ + 172, + 1095, + 239, + 1095, + 238, + 1121, + 171, + 1121 + ], + "text": "Black", + "confidence": 0.959 + }, + { + "boundingBox": [ + 244, + 1095, + 335, + 1096, + 335, + 1121, + 244, + 1121 + ], + "text": "Sweats", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 859, + 1091, + 894, + 1089, + 895, + 1118, + 860, + 1120 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1091, + 893, + 1089, + 895, + 1118, + 863, + 1120 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1224, + 1094, + 1296, + 1093, + 1296, + 1118, + 1224, + 1120 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1096, + 1295, + 1094, + 1295, + 1119, + 1227, + 1119 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1442, + 1095, + 1531, + 1093, + 1532, + 1118, + 1443, + 1120 + ], + "text": "200.00", + "words": [ + { + "boundingBox": [ + 1444, + 1096, + 1528, + 1093, + 1528, + 1119, + 1444, + 1119 + ], + "text": "200.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1135, + 379, + 1135, + 379, + 1165, + 170, + 1165 + ], + "text": "Black Yoga Pants", + "words": [ + { + "boundingBox": [ + 172, + 1135, + 239, + 1135, + 238, + 1166, + 171, + 1165 + ], + "text": "Black", + "confidence": 0.959 + }, + { + "boundingBox": [ + 245, + 1135, + 305, + 1135, + 304, + 1166, + 243, + 1166 + ], + "text": "Yoga", + "confidence": 0.958 + }, + { + "boundingBox": [ + 311, + 1135, + 380, + 1135, + 379, + 1166, + 310, + 1166 + ], + "text": "Pants", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 860, + 1137, + 893, + 1135, + 893, + 1158, + 861, + 1160 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 862, + 1137, + 892, + 1135, + 893, + 1158, + 863, + 1160 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1225, + 1136, + 1296, + 1134, + 1296, + 1158, + 1225, + 1159 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1135, + 1295, + 1134, + 1295, + 1158, + 1227, + 1159 + ], + "text": "10.00", + "confidence": 0.57 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1441, + 1136, + 1531, + 1135, + 1531, + 1159, + 1441, + 1160 + ], + "text": "200.00", + "words": [ + { + "boundingBox": [ + 1445, + 1136, + 1530, + 1136, + 1530, + 1159, + 1444, + 1160 + ], + "text": "200.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 172, + 1177, + 345, + 1178, + 345, + 1206, + 172, + 1204 + ], + "text": "White Sweats", + "words": [ + { + "boundingBox": [ + 173, + 1177, + 249, + 1180, + 249, + 1206, + 173, + 1205 + ], + "text": "White", + "confidence": 0.959 + }, + { + "boundingBox": [ + 255, + 1180, + 345, + 1179, + 345, + 1206, + 254, + 1206 + ], + "text": "Sweats", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 863, + 1181, + 893, + 1180, + 893, + 1202, + 863, + 1203 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 863, + 1181, + 892, + 1180, + 892, + 1202, + 863, + 1203 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1223, + 1180, + 1295, + 1179, + 1296, + 1203, + 1223, + 1204 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1226, + 1180, + 1295, + 1180, + 1294, + 1203, + 1226, + 1204 + ], + "text": "10.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1442, + 1180, + 1532, + 1180, + 1532, + 1203, + 1442, + 1204 + ], + "text": "200.00", + "words": [ + { + "boundingBox": [ + 1444, + 1180, + 1529, + 1180, + 1529, + 1203, + 1444, + 1204 + ], + "text": "200.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 170, + 1221, + 353, + 1221, + 353, + 1248, + 170, + 1248 + ], + "text": "Yellow T Shirts", + "words": [ + { + "boundingBox": [ + 172, + 1222, + 251, + 1222, + 250, + 1249, + 172, + 1248 + ], + "text": "Yellow", + "confidence": 0.959 + }, + { + "boundingBox": [ + 263, + 1222, + 278, + 1222, + 278, + 1249, + 262, + 1249 + ], + "text": "T", + "confidence": 0.884 + }, + { + "boundingBox": [ + 283, + 1222, + 354, + 1222, + 354, + 1249, + 283, + 1249 + ], + "text": "Shirts", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1223, + 893, + 1222, + 893, + 1246, + 861, + 1248 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1223, + 892, + 1222, + 893, + 1246, + 862, + 1247 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1224, + 1222, + 1295, + 1223, + 1295, + 1246, + 1223, + 1246 + ], + "text": "10.00", + "words": [ + { + "boundingBox": [ + 1227, + 1222, + 1295, + 1222, + 1295, + 1246, + 1227, + 1246 + ], + "text": "10.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1223, + 1531, + 1223, + 1531, + 1247, + 1443, + 1247 + ], + "text": "200.00", + "words": [ + { + "boundingBox": [ + 1444, + 1223, + 1530, + 1223, + 1529, + 1248, + 1443, + 1247 + ], + "text": "200.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 171, + 1267, + 337, + 1266, + 337, + 1294, + 171, + 1295 + ], + "text": "Logo Stickers", + "words": [ + { + "boundingBox": [ + 173, + 1267, + 233, + 1267, + 232, + 1296, + 172, + 1295 + ], + "text": "Logo", + "confidence": 0.959 + }, + { + "boundingBox": [ + 239, + 1267, + 337, + 1266, + 337, + 1294, + 238, + 1296 + ], + "text": "Stickers", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 861, + 1267, + 893, + 1266, + 893, + 1290, + 861, + 1290 + ], + "text": "20", + "words": [ + { + "boundingBox": [ + 861, + 1266, + 893, + 1266, + 893, + 1289, + 862, + 1290 + ], + "text": "20", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1240, + 1266, + 1296, + 1266, + 1296, + 1289, + 1240, + 1289 + ], + "text": "5,00", + "words": [ + { + "boundingBox": [ + 1241, + 1266, + 1294, + 1266, + 1294, + 1289, + 1241, + 1289 + ], + "text": "5,00", + "confidence": 0.423 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1443, + 1267, + 1531, + 1266, + 1531, + 1290, + 1443, + 1291 + ], + "text": "100.00", + "words": [ + { + "boundingBox": [ + 1444, + 1267, + 1531, + 1266, + 1529, + 1291, + 1445, + 1292 + ], + "text": "100.00", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1148, + 1574, + 1296, + 1574, + 1296, + 1599, + 1148, + 1599 + ], + "text": "SUBTOTAL", + "words": [ + { + "boundingBox": [ + 1149, + 1574, + 1296, + 1575, + 1296, + 1599, + 1149, + 1600 + ], + "text": "SUBTOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1427, + 1570, + 1530, + 1570, + 1530, + 1597, + 1428, + 1598 + ], + "text": "$900.00", + "words": [ + { + "boundingBox": [ + 1429, + 1571, + 1530, + 1570, + 1530, + 1598, + 1429, + 1599 + ], + "text": "$900.00", + "confidence": 0.917 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1238, + 1619, + 1295, + 1618, + 1295, + 1642, + 1237, + 1642 + ], + "text": "TAX", + "words": [ + { + "boundingBox": [ + 1241, + 1618, + 1294, + 1618, + 1294, + 1641, + 1241, + 1642 + ], + "text": "TAX", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1427, + 1615, + 1530, + 1614, + 1531, + 1640, + 1427, + 1642 + ], + "text": "$100.00", + "words": [ + { + "boundingBox": [ + 1428, + 1616, + 1531, + 1614, + 1531, + 1641, + 1429, + 1643 + ], + "text": "$100.00", + "confidence": 0.888 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 529, + 1670, + 735, + 1671, + 735, + 1712, + 529, + 1711 + ], + "text": "Wesley Snipes", + "words": [ + { + "boundingBox": [ + 531, + 1670, + 635, + 1671, + 634, + 1711, + 530, + 1712 + ], + "text": "Wesley", + "confidence": 0.799 + }, + { + "boundingBox": [ + 643, + 1671, + 735, + 1671, + 734, + 1713, + 643, + 1711 + ], + "text": "Snipes", + "confidence": 0.817 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1204, + 1672, + 1296, + 1672, + 1296, + 1699, + 1204, + 1699 + ], + "text": "TOTAL", + "words": [ + { + "boundingBox": [ + 1207, + 1674, + 1295, + 1672, + 1296, + 1700, + 1207, + 1699 + ], + "text": "TOTAL", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 1410, + 1670, + 1530, + 1669, + 1531, + 1696, + 1410, + 1698 + ], + "text": "$1000.00", + "words": [ + { + "boundingBox": [ + 1412, + 1671, + 1530, + 1669, + 1531, + 1696, + 1412, + 1699 + ], + "text": "$1000.00", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 548, + 1717, + 713, + 1718, + 713, + 1744, + 548, + 1744 + ], + "text": "Wesley Snipes", + "words": [ + { + "boundingBox": [ + 549, + 1717, + 633, + 1718, + 632, + 1744, + 548, + 1745 + ], + "text": "Wesley", + "confidence": 0.959 + }, + { + "boundingBox": [ + 638, + 1718, + 712, + 1720, + 713, + 1744, + 638, + 1744 + ], + "text": "Snipes", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 581, + 1754, + 682, + 1756, + 681, + 1778, + 581, + 1776 + ], + "text": "Manager", + "words": [ + { + "boundingBox": [ + 582, + 1754, + 683, + 1757, + 682, + 1778, + 581, + 1777 + ], + "text": "Manager", + "confidence": 0.959 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 173, + 1796, + 480, + 1797, + 479, + 1832, + 173, + 1830 + ], + "text": "Additional Notes:", + "words": [ + { + "boundingBox": [ + 175, + 1798, + 358, + 1797, + 358, + 1832, + 174, + 1830 + ], + "text": "Additional", + "confidence": 0.959 + }, + { + "boundingBox": [ + 365, + 1797, + 479, + 1799, + 479, + 1832, + 364, + 1832 + ], + "text": "Notes:", + "confidence": 0.932 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 174, + 1875, + 1449, + 1875, + 1449, + 1910, + 174, + 1911 + ], + "text": "We love to Print! Contact us about special offers on personalizing your future orders with", + "words": [ + { + "boundingBox": [ + 174, + 1881, + 216, + 1880, + 217, + 1905, + 174, + 1904 + ], + "text": "We", + "confidence": 0.873 + }, + { + "boundingBox": [ + 221, + 1880, + 277, + 1880, + 277, + 1906, + 221, + 1905 + ], + "text": "love", + "confidence": 0.958 + }, + { + "boundingBox": [ + 283, + 1879, + 309, + 1879, + 309, + 1907, + 283, + 1906 + ], + "text": "to", + "confidence": 0.959 + }, + { + "boundingBox": [ + 315, + 1879, + 391, + 1878, + 391, + 1908, + 315, + 1907 + ], + "text": "Print!", + "confidence": 0.959 + }, + { + "boundingBox": [ + 398, + 1878, + 517, + 1877, + 517, + 1910, + 398, + 1908 + ], + "text": "Contact", + "confidence": 0.849 + }, + { + "boundingBox": [ + 521, + 1877, + 555, + 1877, + 555, + 1910, + 522, + 1910 + ], + "text": "us", + "confidence": 0.958 + }, + { + "boundingBox": [ + 565, + 1877, + 654, + 1877, + 654, + 1911, + 565, + 1910 + ], + "text": "about", + "confidence": 0.959 + }, + { + "boundingBox": [ + 659, + 1877, + 768, + 1876, + 768, + 1911, + 659, + 1911 + ], + "text": "special", + "confidence": 0.959 + }, + { + "boundingBox": [ + 773, + 1876, + 853, + 1876, + 853, + 1912, + 773, + 1911 + ], + "text": "offers", + "confidence": 0.918 + }, + { + "boundingBox": [ + 863, + 1876, + 897, + 1876, + 897, + 1912, + 863, + 1912 + ], + "text": "on", + "confidence": 0.958 + }, + { + "boundingBox": [ + 910, + 1876, + 1107, + 1875, + 1107, + 1911, + 910, + 1912 + ], + "text": "personalizing", + "confidence": 0.917 + }, + { + "boundingBox": [ + 1116, + 1875, + 1185, + 1876, + 1185, + 1910, + 1116, + 1911 + ], + "text": "your", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1190, + 1876, + 1272, + 1876, + 1272, + 1910, + 1190, + 1910 + ], + "text": "future", + "confidence": 0.959 + }, + { + "boundingBox": [ + 1286, + 1876, + 1378, + 1876, + 1378, + 1908, + 1285, + 1909 + ], + "text": "orders", + "confidence": 0.946 + }, + { + "boundingBox": [ + 1389, + 1876, + 1444, + 1876, + 1444, + 1907, + 1389, + 1908 + ], + "text": "with", + "confidence": 0.935 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 168, + 1928, + 1515, + 1927, + 1515, + 1964, + 168, + 1965 + ], + "text": "company logos, cool designs, signatures, or pictures! We can put anything on clothing and", + "words": [ + { + "boundingBox": [ + 170, + 1930, + 304, + 1930, + 302, + 1965, + 169, + 1965 + ], + "text": "company", + "confidence": 0.959 + }, + { + "boundingBox": [ + 310, + 1930, + 406, + 1929, + 405, + 1965, + 309, + 1965 + ], + "text": "logos,", + "confidence": 0.927 + }, + { + "boundingBox": [ + 413, + 1929, + 475, + 1929, + 473, + 1965, + 412, + 1965 + ], + "text": "cool", + "confidence": 0.941 + }, + { + "boundingBox": [ + 481, + 1929, + 609, + 1929, + 608, + 1964, + 480, + 1965 + ], + "text": "designs,", + "confidence": 0.929 + }, + { + "boundingBox": [ + 616, + 1929, + 783, + 1928, + 781, + 1964, + 615, + 1964 + ], + "text": "signatures,", + "confidence": 0.957 + }, + { + "boundingBox": [ + 789, + 1928, + 819, + 1928, + 818, + 1964, + 788, + 1964 + ], + "text": "or", + "confidence": 0.958 + }, + { + "boundingBox": [ + 826, + 1928, + 965, + 1928, + 964, + 1964, + 825, + 1964 + ], + "text": "pictures!", + "confidence": 0.958 + }, + { + "boundingBox": [ + 972, + 1928, + 1024, + 1928, + 1023, + 1964, + 971, + 1964 + ], + "text": "We", + "confidence": 0.955 + }, + { + "boundingBox": [ + 1031, + 1928, + 1086, + 1928, + 1085, + 1964, + 1030, + 1964 + ], + "text": "can", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1093, + 1928, + 1143, + 1928, + 1142, + 1964, + 1091, + 1964 + ], + "text": "put", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1150, + 1928, + 1280, + 1928, + 1278, + 1964, + 1148, + 1964 + ], + "text": "anything", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1287, + 1928, + 1325, + 1928, + 1324, + 1965, + 1285, + 1964 + ], + "text": "on", + "confidence": 0.958 + }, + { + "boundingBox": [ + 1332, + 1928, + 1449, + 1928, + 1447, + 1965, + 1331, + 1965 + ], + "text": "clothing", + "confidence": 0.915 + }, + { + "boundingBox": [ + 1456, + 1928, + 1516, + 1928, + 1515, + 1965, + 1454, + 1965 + ], + "text": "and", + "confidence": 0.958 + } + ] + }, + { + "language": "en", + "boundingBox": [ + 163, + 1980, + 820, + 1980, + 820, + 2015, + 163, + 2015 + ], + "text": "look forward to you being a return customer!", + "words": [ + { + "boundingBox": [ + 164, + 1980, + 229, + 1980, + 229, + 2013, + 164, + 2011 + ], + "text": "look", + "confidence": 0.958 + }, + { + "boundingBox": [ + 235, + 1980, + 349, + 1980, + 349, + 2015, + 235, + 2013 + ], + "text": "forward", + "confidence": 0.959 + }, + { + "boundingBox": [ + 355, + 1980, + 387, + 1980, + 387, + 2016, + 355, + 2016 + ], + "text": "to", + "confidence": 0.958 + }, + { + "boundingBox": [ + 393, + 1980, + 449, + 1980, + 449, + 2016, + 393, + 2016 + ], + "text": "you", + "confidence": 0.958 + }, + { + "boundingBox": [ + 455, + 1980, + 541, + 1981, + 541, + 2016, + 455, + 2016 + ], + "text": "being", + "confidence": 0.956 + }, + { + "boundingBox": [ + 547, + 1981, + 567, + 1981, + 567, + 2016, + 547, + 2016 + ], + "text": "a", + "confidence": 0.895 + }, + { + "boundingBox": [ + 575, + 1981, + 663, + 1981, + 663, + 2014, + 575, + 2016 + ], + "text": "return", + "confidence": 0.958 + }, + { + "boundingBox": [ + 673, + 1981, + 820, + 1981, + 820, + 2010, + 673, + 2014 + ], + "text": "customer!", + "confidence": 0.959 + } + ] + } + ] + } + ], + "pageResults": [ + { + "page": 1, + "tables": [ + { + "rows": 7, + "columns": 4, + "cells": [ + { + "rowIndex": 0, + "columnIndex": 0, + "text": "Details", + "boundingBox": [ + 156, + 1038, + 847, + 1038, + 847, + 1087, + 156, + 1087 + ], + "elements": [ + "#/readResults/0/lines/21/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 1, + "text": "Quantity", + "boundingBox": [ + 847, + 1038, + 1072, + 1038, + 1072, + 1087, + 847, + 1087 + ], + "elements": [ + "#/readResults/0/lines/22/words/0" + ] + }, + { + "rowIndex": 0, + "columnIndex": 2, + "text": "Unit Price", + "boundingBox": [ + 1072, + 1038, + 1309, + 1038, + 1309, + 1087, + 1072, + 1087 + ], + "elements": [ + "#/readResults/0/lines/23/words/0", + "#/readResults/0/lines/23/words/1" + ] + }, + { + "rowIndex": 0, + "columnIndex": 3, + "text": "Total", + "boundingBox": [ + 1309, + 1038, + 1544, + 1038, + 1544, + 1087, + 1309, + 1087 + ], + "elements": [ + "#/readResults/0/lines/24/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 0, + "text": "Black Sweats", + "boundingBox": [ + 156, + 1087, + 847, + 1087, + 847, + 1128, + 156, + 1128 + ], + "elements": [ + "#/readResults/0/lines/25/words/0", + "#/readResults/0/lines/25/words/1" + ] + }, + { + "rowIndex": 1, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1087, + 1072, + 1087, + 1072, + 1128, + 847, + 1128 + ], + "elements": [ + "#/readResults/0/lines/26/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1087, + 1309, + 1087, + 1309, + 1128, + 1072, + 1128 + ], + "elements": [ + "#/readResults/0/lines/27/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 3, + "text": "200.00", + "boundingBox": [ + 1309, + 1087, + 1544, + 1087, + 1544, + 1128, + 1309, + 1128 + ], + "elements": [ + "#/readResults/0/lines/28/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 0, + "text": "Black Yoga Pants", + "boundingBox": [ + 156, + 1128, + 847, + 1128, + 847, + 1172, + 156, + 1172 + ], + "elements": [ + "#/readResults/0/lines/29/words/0", + "#/readResults/0/lines/29/words/1", + "#/readResults/0/lines/29/words/2" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1128, + 1072, + 1128, + 1072, + 1172, + 847, + 1172 + ], + "elements": [ + "#/readResults/0/lines/30/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1128, + 1309, + 1128, + 1309, + 1172, + 1072, + 1172 + ], + "elements": [ + "#/readResults/0/lines/31/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 3, + "text": "200.00", + "boundingBox": [ + 1309, + 1128, + 1544, + 1128, + 1544, + 1172, + 1309, + 1172 + ], + "elements": [ + "#/readResults/0/lines/32/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 0, + "text": "White Sweats", + "boundingBox": [ + 156, + 1172, + 847, + 1172, + 847, + 1216, + 156, + 1216 + ], + "elements": [ + "#/readResults/0/lines/33/words/0", + "#/readResults/0/lines/33/words/1" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1172, + 1072, + 1172, + 1072, + 1216, + 847, + 1216 + ], + "elements": [ + "#/readResults/0/lines/34/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1172, + 1309, + 1172, + 1309, + 1216, + 1072, + 1216 + ], + "elements": [ + "#/readResults/0/lines/35/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 3, + "text": "200.00", + "boundingBox": [ + 1309, + 1172, + 1544, + 1172, + 1544, + 1216, + 1309, + 1216 + ], + "elements": [ + "#/readResults/0/lines/36/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 0, + "text": "Yellow T Shirts", + "boundingBox": [ + 156, + 1216, + 847, + 1216, + 847, + 1260, + 156, + 1260 + ], + "elements": [ + "#/readResults/0/lines/37/words/0", + "#/readResults/0/lines/37/words/1", + "#/readResults/0/lines/37/words/2" + ] + }, + { + "rowIndex": 4, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1216, + 1072, + 1216, + 1072, + 1260, + 847, + 1260 + ], + "elements": [ + "#/readResults/0/lines/38/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 2, + "text": "10.00", + "boundingBox": [ + 1072, + 1216, + 1309, + 1216, + 1309, + 1260, + 1072, + 1260 + ], + "elements": [ + "#/readResults/0/lines/39/words/0" + ] + }, + { + "rowIndex": 4, + "columnIndex": 3, + "text": "200.00", + "boundingBox": [ + 1309, + 1216, + 1544, + 1216, + 1544, + 1260, + 1309, + 1260 + ], + "elements": [ + "#/readResults/0/lines/40/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 0, + "text": "Logo Stickers", + "boundingBox": [ + 156, + 1260, + 847, + 1260, + 847, + 1303, + 156, + 1303 + ], + "elements": [ + "#/readResults/0/lines/41/words/0", + "#/readResults/0/lines/41/words/1" + ] + }, + { + "rowIndex": 5, + "columnIndex": 1, + "text": "20", + "boundingBox": [ + 847, + 1260, + 1072, + 1260, + 1072, + 1303, + 847, + 1303 + ], + "elements": [ + "#/readResults/0/lines/42/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 2, + "text": "5,00", + "boundingBox": [ + 1072, + 1260, + 1309, + 1260, + 1309, + 1303, + 1072, + 1303 + ], + "elements": [ + "#/readResults/0/lines/43/words/0" + ] + }, + { + "rowIndex": 5, + "columnIndex": 3, + "text": "100.00", + "boundingBox": [ + 1309, + 1260, + 1544, + 1260, + 1544, + 1303, + 1309, + 1303 + ], + "elements": [ + "#/readResults/0/lines/44/words/0" + ] + } + ] + }, + { + "rows": 4, + "columns": 3, + "cells": [ + { + "rowIndex": 1, + "columnIndex": 1, + "text": "SUBTOTAL", + "boundingBox": [ + 1072, + 1566, + 1309, + 1566, + 1309, + 1610, + 1072, + 1610 + ], + "elements": [ + "#/readResults/0/lines/45/words/0" + ] + }, + { + "rowIndex": 1, + "columnIndex": 2, + "text": "$900.00", + "boundingBox": [ + 1309, + 1566, + 1544, + 1566, + 1544, + 1610, + 1309, + 1610 + ], + "elements": [ + "#/readResults/0/lines/46/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 1, + "text": "TAX", + "boundingBox": [ + 1072, + 1610, + 1309, + 1610, + 1309, + 1658, + 1072, + 1658 + ], + "elements": [ + "#/readResults/0/lines/47/words/0" + ] + }, + { + "rowIndex": 2, + "columnIndex": 2, + "text": "$100.00", + "boundingBox": [ + 1309, + 1610, + 1544, + 1610, + 1544, + 1658, + 1309, + 1658 + ], + "elements": [ + "#/readResults/0/lines/48/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 1, + "text": "TOTAL", + "boundingBox": [ + 1072, + 1658, + 1309, + 1658, + 1309, + 1708, + 1072, + 1708 + ], + "elements": [ + "#/readResults/0/lines/50/words/0" + ] + }, + { + "rowIndex": 3, + "columnIndex": 2, + "text": "$1000.00", + "boundingBox": [ + 1309, + 1658, + 1544, + 1658, + 1544, + 1708, + 1309, + 1708 + ], + "elements": [ + "#/readResults/0/lines/51/words/0" + ] + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/fields.json b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/fields.json new file mode 100644 index 000000000000..e105e277a664 --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/training/fields.json @@ -0,0 +1,79 @@ +{ + "fields": [ + { + "fieldKey": "Merchant", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "PhoneNumber", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Website", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Email", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "PurchaseOrderNumber", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "DatedAs", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "VendorName", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "CompanyName", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "CompanyAddress", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "CompanyPhoneNumber", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Subtotal", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Tax", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Total", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Signature", + "fieldType": "string", + "fieldFormat": "not-specified" + }, + { + "fieldKey": "Quantity", + "fieldType": "number", + "fieldFormat": "not-specified" + } + ] +} \ No newline at end of file diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/w2/Sample-W2.jpg b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/w2/Sample-W2.jpg new file mode 100644 index 000000000000..6b0cbf510238 Binary files /dev/null and b/sdk/documentintelligence/azure-ai-documentintelligence/src/samples/resources/sample-forms/w2/Sample-W2.jpg differ diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml b/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml new file mode 100644 index 000000000000..820db7e096fe --- /dev/null +++ b/sdk/documentintelligence/azure-ai-documentintelligence/tsp-location.yaml @@ -0,0 +1,3 @@ +directory: specification/cognitiveservices/DocumentIntelligence +commit: a3ead5890e6c6b2b41a2c7077c21efcdc406ea52 +repo: Azure/azure-rest-api-specs-pr diff --git a/sdk/documentintelligence/ci.yml b/sdk/documentintelligence/ci.yml new file mode 100644 index 000000000000..bc0e1dea025e --- /dev/null +++ b/sdk/documentintelligence/ci.yml @@ -0,0 +1,44 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/documentintelligence/ + exclude: + - sdk/documentintelligence/pom.xml + - sdk/documentintelligence/azure-ai-documentintelligence/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/documentintelligence/ + exclude: + - sdk/documentintelligence/pom.xml + - sdk/documentintelligence/azure-ai-documentintelligence/pom.xml + +parameters: +- name: release_dependsonlivetests + displayName: 'Release depends on live tests' + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: documentintelligence + EnableBatchRelease: true + Artifacts: + - name: azure-ai-documentintelligence + groupId: com.azure + safeName: azureaidocumentintelligence diff --git a/sdk/documentintelligence/pom.xml b/sdk/documentintelligence/pom.xml new file mode 100644 index 000000000000..b0e7eaa469d1 --- /dev/null +++ b/sdk/documentintelligence/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + com.azure + azure-documentintelligence-service + pom + 1.0.0 + + azure-ai-documentintelligence + + diff --git a/sdk/documentintelligence/test-resources.json b/sdk/documentintelligence/test-resources.json new file mode 100644 index 000000000000..94929cdf387f --- /dev/null +++ b/sdk/documentintelligence/test-resources.json @@ -0,0 +1,224 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "baseName": { + "type": "string", + "defaultValue": "[resourceGroup().name]", + "metadata": { + "description": "The base resource name." + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "metadata": { + "description": "The location of the resource. By default, this is the same as the resource group." + } + } + }, + "testApplicationOid": { + "type": "string", + "metadata": { + "description": "The principal to assign the role to. This is application object id." + } + }, + "tenantId": { + "type": "string", + "metadata": { + "description": "The tenant id to which the application and resources belong." + } + }, + "testApplicationId": { + "type": "string", + "metadata": { + "description": "The application client id used to run tests." + } + }, + "testApplicationSecret": { + "type": "string", + "metadata": { + "description": "The application client secret used to run tests." + } + }, + "cognitiveServicesEndpointSuffix": { + "defaultValue": ".cognitiveservices.azure.com/", + "type": "string" + }, + "blobStorageAccount": { + "type": "string", + "defaultValue": "azuresdktrainingdata" + }, + "trainingDataContainer": { + "type": "string", + "defaultValue": "trainingdata" + }, + "errorTrainingDataContainer": { + "type": "string", + "defaultValue": "trainingdata-error" + }, + "blobResourceId": { + "type": "string", + "defaultValue": "[resourceId(subscription().subscriptionId, 'TrainingData', 'Microsoft.Storage/storageAccounts', parameters('blobStorageAccount'))]" + }, + "classifierTrainingDataContainer": { + "type": "string", + "defaultValue": "training-data-classifier" + }, + "trainingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('trainingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + }, + "errorTrainingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('errorTrainingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + }, + "testingDataContainer": { + "type": "string", + "defaultValue": "testingdata" + }, + "selectionMarkTrainingDataContainer": { + "type": "string", + "defaultValue": "selectionmark" + }, + "testingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('testingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + }, + "multiPageTestingDataContainer": { + "type": "string", + "defaultValue": "multipage-training-data" + }, + "multiPageTestingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('multiPageTestingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + }, + "selectionMarkTrainingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('selectionMarkTrainingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + }, + "classifierTrainingDataSasProperties": { + "type": "object", + "defaultValue": { + "canonicalizedResource": "[concat('/blob/', parameters('blobStorageAccount'), '/', parameters('classifierTrainingDataContainer'))]", + "signedExpiry": "[dateTimeAdd(utcNow('u'), 'PT3H')]", + "signedPermission": "rl", + "signedResource": "c" + } + } + }, + "variables": { + "authorizationApiVersion": "2018-09-01-preview", + "formRecognizerBaseName": "[concat('formRecognizer', parameters('baseName'))]", + "formRecognizerApiVersion": "2017-04-18", + "azureFormRecognizerUrl": "[concat('https://', variables('formRecognizerBaseName'), parameters('cognitiveServicesEndpointSuffix'))]", + "cognitiveServiceUserRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]" + }, + "resources": [ + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "[variables('authorizationApiVersion')]", + "name": "[guid(concat(variables('cognitiveServiceUserRoleId'), variables('formRecognizerBaseName')))]", + "dependsOn": [ + "[variables('formRecognizerBaseName')]" + ], + "properties": { + "principalId": "[parameters('testApplicationOid')]", + "roleDefinitionId": "[variables('cognitiveServiceUserRoleId')]" + } + }, + { + "type": "Microsoft.CognitiveServices/accounts", + "name": "[variables('formRecognizerBaseName')]", + "apiVersion": "[variables('formRecognizerApiVersion')]", + "sku": { + "name": "S0" + }, + "kind": "FormRecognizer", + "location": "[parameters('location')]", + "properties": { + "customSubDomainName": "[variables('formRecognizerBaseName')]" + } + } + ], + "outputs": { + "AZURE_TENANT_ID": { + "type": "string", + "value": "[parameters('tenantId')]" + }, + "AZURE_CLIENT_ID": { + "type": "string", + "value": "[parameters('testApplicationId')]" + }, + "AZURE_CLIENT_SECRET": { + "type": "string", + "value": "[parameters('testApplicationSecret')]" + }, + "AZURE_FORM_RECOGNIZER_API_KEY": { + "type": "string", + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('formRecognizerBaseName')), variables('formRecognizerApiVersion')).key1]" + }, + "AZURE_FORM_RECOGNIZER_ENDPOINT": { + "type": "string", + "value": "[variables('azureFormRecognizerUrl')]" + }, + "FORM_RECOGNIZER_TRAINING_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('trainingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('trainingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_ERROR_TRAINING_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('errorTrainingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('errorTrainingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_TESTING_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('testingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('testingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_MULTIPAGE_TRAINING_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('multiPageTestingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('multiPageTestingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_SELECTION_MARK_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('selectionMarkTrainingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('selectionMarkTrainingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_CLASSIFIER_TRAINING_BLOB_CONTAINER_SAS_URL": { + "type": "string", + "value": "[concat(reference(parameters('blobResourceId'), '2019-06-01').primaryEndpoints.blob, parameters('classifierTrainingDataContainer'), '?', listServiceSas(parameters('blobResourceId'), '2019-06-01', parameters('classifierTrainingDataSasProperties')).serviceSasToken)]" + }, + "FORM_RECOGNIZER_TARGET_RESOURCE_REGION": { + "type": "string", + "value": "[parameters('location')]" + }, + "FORM_RECOGNIZER_TARGET_RESOURCE_ID": { + "type": "string", + "value": "[resourceId('Microsoft.CognitiveServices/accounts', variables('formRecognizerBaseName'))]" + } + } +} diff --git a/sdk/documentintelligence/tests.native.yml b/sdk/documentintelligence/tests.native.yml new file mode 100644 index 000000000000..4fcec3def8e6 --- /dev/null +++ b/sdk/documentintelligence/tests.native.yml @@ -0,0 +1,16 @@ +trigger: none + +stages: + - template: /eng/pipelines/templates/stages/archetype-sdk-native-tests.yml + parameters: + ServiceDirectory: documentintelligence + timeoutInMinutes: 150 # how long to run the job before automatically cancelling + Artifacts: + - name: azure-ai-documentintelligence + groupId: com.azure + safeName: azureaidocumentintelligence + CloudConfig: + Public: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + Location: 'eastus' + SupportedClouds: 'Public' diff --git a/sdk/documentintelligence/tests.yml b/sdk/documentintelligence/tests.yml new file mode 100644 index 000000000000..dd63b52a854c --- /dev/null +++ b/sdk/documentintelligence/tests.yml @@ -0,0 +1,16 @@ +trigger: none + +stages: + - template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml + parameters: + ServiceDirectory: documentintelligence + timeoutInMinutes: 150 # how long to run the job before automatically cancelling + Artifacts: + - name: azure-ai-documentintelligence + groupId: com.azure + safeName: azureaidocumentintelligence + CloudConfig: + Public: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + Location: 'centraluseuap' + SupportedClouds: 'Public'