Class DocumentModelAdministrationClient
- java.lang.Object
-
- com.azure.ai.formrecognizer.administration.DocumentModelAdministrationClient
-
public final class DocumentModelAdministrationClient extends Object
This class provides a synchronous client that contains model management the operations that apply to Azure Form Recognizer. Operations allowed by the client are creating, building of custom document analysis models, deleting models, listing models, copying a custom-built model to another Form Recognizer account, composing models from component models, getting operation information and getting account information.Instantiating a synchronous Document Model Administration Client
DocumentModelAdministrationClient documentModelAdministrationClient = new DocumentModelAdministrationClientBuilder().buildClient();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginBuildModel(String trainingFilesUrl, DocumentBuildMode buildMode, String modelId)
Builds a custom document analysis model.com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginBuildModel(String trainingFilesUrl, DocumentBuildMode buildMode, String modelId, BuildModelOptions buildModelOptions, com.azure.core.util.Context context)
Builds a custom document analysis model.com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginCopyModel(String modelId, CopyAuthorization target)
Copy a custom model stored in this resource (the source) to the user specified target Form Recognizer resource.com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginCopyModel(String modelId, CopyAuthorization target, com.azure.core.util.Context context)
Copy a custom model stored in this resource (the source) to the user specified target Form Recognizer resource.com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginCreateComposedModel(List<String> modelIDs, String modelId)
Create a composed model from the provided list of existing models in the account.com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel>
beginCreateComposedModel(List<String> modelIDs, String modelId, CreateComposedModelOptions createComposedModelOptions, com.azure.core.util.Context context)
Create a composed model from the provided list of existing models in the account.void
deleteModel(String modelId)
Deletes the specified custom document analysis model.com.azure.core.http.rest.Response<Void>
deleteModelWithResponse(String modelId, com.azure.core.util.Context context)
Deletes the specified custom document analysis model.AccountProperties
getAccountProperties()
Get account information of the Form Recognizer account.com.azure.core.http.rest.Response<AccountProperties>
getAccountPropertiesWithResponse(com.azure.core.util.Context context)
Get account information of the Form Recognizer account with an Http response and a specifiedContext
.CopyAuthorization
getCopyAuthorization(String modelId)
Generate authorization for copying a custom model into the target Form Recognizer resource.com.azure.core.http.rest.Response<CopyAuthorization>
getCopyAuthorizationWithResponse(String modelId, CopyAuthorizationOptions copyAuthorizationOptions, com.azure.core.util.Context context)
Generate authorization for copying a custom model into the target Form Recognizer resource.DocumentAnalysisClient
getDocumentAnalysisClient()
Creates a newDocumentAnalysisClient
object.DocumentModel
getModel(String modelId)
Get detailed information for a specified model ID.com.azure.core.http.rest.Response<DocumentModel>
getModelWithResponse(String modelId, com.azure.core.util.Context context)
Get detailed information for a specified model ID.ModelOperation
getOperation(String operationId)
Get detailed operation information for the specified ID with Http response.com.azure.core.http.rest.Response<ModelOperation>
getOperationWithResponse(String operationId, com.azure.core.util.Context context)
Get detailed operation information for the specified ID with Http response.com.azure.core.http.rest.PagedIterable<DocumentModelInfo>
listModels()
List information for each model on the Form Recognizer account that were built successfully.com.azure.core.http.rest.PagedIterable<DocumentModelInfo>
listModels(com.azure.core.util.Context context)
List information for each model on the Form Recognizer account that were built successfully with a Http response and a specifiedContext
.com.azure.core.http.rest.PagedIterable<ModelOperationInfo>
listOperations()
List information for each model operation on the Form Recognizer account in the past 24 hours.com.azure.core.http.rest.PagedIterable<ModelOperationInfo>
listOperations(com.azure.core.util.Context context)
List information for each operation on the Form Recognizer account in the past 24 hours with an HTTP response and a specifiedContext
.
-
-
-
Method Detail
-
getDocumentAnalysisClient
public DocumentAnalysisClient getDocumentAnalysisClient()
Creates a newDocumentAnalysisClient
object. The newDocumentAnalysisClient
uses the same request policy pipeline as theDocumentAnalysisClient
.- Returns:
- A new
DocumentAnalysisClient
object.
-
beginBuildModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginBuildModel(String trainingFilesUrl, DocumentBuildMode buildMode, String modelId)
Builds a custom document analysis model.Models are built using documents that are of the following content type - 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff', image/bmp. Other type of content is ignored.
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; DocumentModel documentModel = documentModelAdministrationClient.beginBuildModel(trainingFilesUrl, DocumentBuildMode.TEMPLATE, "my-model" ).getFinalResult(); System.out.printf("Model ID: %s%n", documentModel.getModelId()); System.out.printf("Model Created on: %s%n", documentModel.getCreatedOn()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
trainingFilesUrl
- an externally accessible Azure storage blob container Url (preferably a Shared Access Signature Url). For instructions on setting up forms for administration in an Azure Storage Blob Container, see here.buildMode
- the preferred technique for creating models. For faster training of models useDocumentBuildMode.TEMPLATE
. See here for more information on building mode for custom documents.modelId
- unique model identifier. If not specified, a model ID will be created for you.- Returns:
- A
SyncPoller
that polls the building model operation until it has completed, has failed, or has been cancelled. The completed operation returns the trainedcustom document analysis model
. - Throws:
DocumentModelOperationException
- If building model fails withOperationStatus.FAILED
is created.NullPointerException
- IftrainingFilesUrl
is null.
-
beginBuildModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginBuildModel(String trainingFilesUrl, DocumentBuildMode buildMode, String modelId, BuildModelOptions buildModelOptions, com.azure.core.util.Context context)
Builds a custom document analysis model.Models are built using documents that are of the following content type - 'application/pdf', 'image/jpeg', 'image/png', 'image/tiff', image/bmp. Other type of content is ignored.
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String trainingFilesUrl = "{SAS-URL-of-your-container-in-blob-storage}"; String prefix = "Invoice"; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("createdBy", "sample"); DocumentModel documentModel = documentModelAdministrationClient.beginBuildModel(trainingFilesUrl, DocumentBuildMode.TEMPLATE, "my-model", new BuildModelOptions() .setDescription("model desc") .setPrefix(prefix) .setTags(attrs), Context.NONE) .getFinalResult(); 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.getCreatedOn()); System.out.printf("Model assigned tags: %s%n", documentModel.getTags()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
trainingFilesUrl
- an externally accessible Azure storage blob container Url (preferably a Shared Access Signature Url). For instructions on setting up forms for administration in an Azure Storage Blob Container, see here.buildMode
- the preferred technique for creating models. For faster training of models useDocumentBuildMode.TEMPLATE
. See here for more information on building mode for custom documents.modelId
- unique model identifier. If not specified, a model ID will be created for you.buildModelOptions
- The configurableoptions
to pass when building a custom document analysis model.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
SyncPoller
that polls the building model operation until it has completed, has failed, or has been cancelled. The completed operation returns the builtcustom document analysis model
. - Throws:
DocumentModelOperationException
- If building the model fails withOperationStatus.FAILED
is created.NullPointerException
- IftrainingFilesUrl
is null.
-
getAccountProperties
public AccountProperties getAccountProperties()
Get account information of the Form Recognizer account.Code sample
AccountProperties accountProperties = documentModelAdministrationClient.getAccountProperties(); System.out.printf("Max number of models that can be build for this account: %d%n", accountProperties.getDocumentModelLimit()); System.out.printf("Current count of built document analysis models: %d%n", accountProperties.getDocumentModelCount());
- Returns:
- The requested account information of the Form Recognizer account.
-
getAccountPropertiesWithResponse
public com.azure.core.http.rest.Response<AccountProperties> getAccountPropertiesWithResponse(com.azure.core.util.Context context)
Get account information of the Form Recognizer account with an Http response and a specifiedContext
.Code sample
Response<AccountProperties> response = documentModelAdministrationClient.getAccountPropertiesWithResponse(Context.NONE); System.out.printf("Response Status Code: %d.", response.getStatusCode()); AccountProperties accountProperties = response.getValue(); System.out.printf("Max number of models that can be build for this account: %d%n", accountProperties.getDocumentModelLimit()); System.out.printf("Current count of built document analysis models: %d%n", accountProperties.getDocumentModelCount());
- Parameters:
context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The requested account information of the Form Recognizer account.
-
deleteModel
public void deleteModel(String modelId)
Deletes the specified custom document analysis model.Code sample
String modelId = "{model_id}"; documentModelAdministrationClient.deleteModel(modelId); System.out.printf("Model ID: %s is deleted.%n", modelId);
- Parameters:
modelId
- The unique model identifier.- Throws:
IllegalArgumentException
- IfmodelId
is null or empty.
-
deleteModelWithResponse
public com.azure.core.http.rest.Response<Void> deleteModelWithResponse(String modelId, com.azure.core.util.Context context)
Deletes the specified custom document analysis model.Code sample
String modelId = "{model_id}"; Response<Void> response = documentModelAdministrationClient.deleteModelWithResponse(modelId, Context.NONE); System.out.printf("Response Status Code: %d.", response.getStatusCode()); System.out.printf("Model ID: %s is deleted.%n", modelId);
- Parameters:
modelId
- The unique model identifier.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
containing containing status code and HTTP headers. - Throws:
IllegalArgumentException
- IfmodelId
is null or empty.
-
getCopyAuthorization
public CopyAuthorization getCopyAuthorization(String modelId)
Generate authorization for copying a custom model into the target Form Recognizer resource.This should be called by the target resource (where the model will be copied to) and the output can be passed as the target parameter into
beginCopyModel(String, CopyAuthorization)
.- Parameters:
modelId
- A unique ID for your copied model. If not specified, a model ID will be created for you.Code sample
String modelId = "my-copied-model"; CopyAuthorization copyAuthorization = documentModelAdministrationClient.getCopyAuthorization(modelId); 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.getExpiresOn(), copyAuthorization.getTargetResourceId(), copyAuthorization.getTargetResourceRegion() );
- Returns:
- The
CopyAuthorization
-
getCopyAuthorizationWithResponse
public com.azure.core.http.rest.Response<CopyAuthorization> getCopyAuthorizationWithResponse(String modelId, CopyAuthorizationOptions copyAuthorizationOptions, com.azure.core.util.Context context)
Generate authorization for copying a custom model into the target Form Recognizer resource.This should be called by the target resource (where the model will be copied to) and the output can be passed as the target parameter into
beginCopyModel(String, CopyAuthorization)
.- Parameters:
modelId
- A unique ID for your copied model. If not specified, a model ID will be created for you.copyAuthorizationOptions
- The configurableoptions
to pass when copying a model.context
- Additional context that is passed through the Http pipeline during the service call.Code sample
String modelId = "my-copied-model"; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("createdBy", "sample"); Response<CopyAuthorization> copyAuthorizationResponse = documentModelAdministrationClient.getCopyAuthorizationWithResponse(modelId, new CopyAuthorizationOptions() .setDescription("model-desc") .setTags(attrs), Context.NONE); System.out.printf("Copy Authorization operation returned with status: %s", copyAuthorizationResponse.getStatusCode()); CopyAuthorization copyAuthorization = 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", copyAuthorization.getTargetModelId(), copyAuthorization.getAccessToken(), copyAuthorization.getExpiresOn(), copyAuthorization.getTargetResourceId(), copyAuthorization.getTargetResourceRegion() );
- Returns:
- A
Response
containing theCopyAuthorization
-
beginCreateComposedModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginCreateComposedModel(List<String> modelIDs, String modelId)
Create a composed model from the provided list of existing models in the account.This operations fails if the list consists of an invalid, non-existing model Id or duplicate IDs.
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String modelId1 = "{model_Id_1}"; String modelId2 = "{model_Id_2}"; String modelId = "my-composed-model"; final DocumentModel documentModel = documentModelAdministrationClient.beginCreateComposedModel(Arrays.asList(modelId1, modelId2), modelId) .getFinalResult(); 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.getCreatedOn()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
modelIDs
- The list of models IDs to form the composed model.modelId
- A unique ID for your composed model. If not specified, a model ID will be created for you.- Returns:
- A
SyncPoller
that polls the create composed model operation until it has completed, has failed, or has been cancelled. The completed operation returns thecomposed model
. - Throws:
DocumentModelOperationException
- If create composed model operation fails and model withOperationStatus.FAILED
is created.NullPointerException
- If the list ofmodelIDs
is null or empty.
-
beginCreateComposedModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginCreateComposedModel(List<String> modelIDs, String modelId, CreateComposedModelOptions createComposedModelOptions, com.azure.core.util.Context context)
Create a composed model from the provided list of existing models in the account.This operations fails if the list consists of an invalid, non-existing model Id or duplicate IDs.
The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String modelId1 = "{model_Id_1}"; String modelId2 = "{model_Id_2}"; String modelId = "my-composed-model"; Map<String, String> attrs = new HashMap<String, String>(); attrs.put("createdBy", "sample"); final DocumentModel documentModel = documentModelAdministrationClient.beginCreateComposedModel(Arrays.asList(modelId1, modelId2), modelId, new CreateComposedModelOptions() .setDescription("my composed model name") .setTags(attrs), Context.NONE) .setPollInterval(Duration.ofSeconds(5)) .getFinalResult(); 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.getCreatedOn()); System.out.printf("Model assigned tags: %s%n", documentModel.getTags()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
modelIDs
- The list of models IDs to form the composed model.modelId
- A unique ID for your composed model. If not specified, a model ID will be created for you.createComposedModelOptions
- The configurableoptions
to pass when creating a composed model.context
- Additional context that is passed through the HTTP pipeline during the service call.- Returns:
- A
SyncPoller
that polls the create composed model operation until it has completed, has failed, or has been cancelled. The completed operation returns thecomposed model
. - Throws:
DocumentModelOperationException
- If create composed model operation fails and model withOperationStatus.FAILED
is created.NullPointerException
- If the list ofmodelIDs
is null or empty.
-
beginCopyModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginCopyModel(String modelId, CopyAuthorization target)
Copy a custom model stored in this resource (the source) to the user specified target Form Recognizer resource.This should be called with the source Form Recognizer resource (with the model that is intended to be copied). The target parameter should be supplied from the target resource's output from
getCopyAuthorization(String)
method.The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String copyModelId = "copy-model"; String targetModelId = "my-copied-model-id"; // Get authorization to copy the model to target resource CopyAuthorization copyAuthorization = documentModelAdministrationClient.getCopyAuthorization(copyModelId); // Start copy operation from the source client DocumentModel documentModel = documentModelAdministrationClient.beginCopyModel(copyModelId, copyAuthorization).getFinalResult(); System.out.printf("Copied model has model ID: %s, was created on: %s.%n,", documentModel.getModelId(), documentModel.getCreatedOn());
- Parameters:
modelId
- Model identifier of the model to copy to target resource.target
- the copy authorization to the target Form Recognizer resource. The copy authorization can be generated from the target resource's call togetCopyAuthorization(String)
- Returns:
- A
SyncPoller
that polls the copy model operation until it has completed, has failed, or has been cancelled.
-
beginCopyModel
public com.azure.core.util.polling.SyncPoller<DocumentOperationResult,DocumentModel> beginCopyModel(String modelId, CopyAuthorization target, com.azure.core.util.Context context)
Copy a custom model stored in this resource (the source) to the user specified target Form Recognizer resource.This should be called with the source Form Recognizer resource (with the model that is intended to be copied). The target parameter should be supplied from the target resource's output from
getCopyAuthorization(String)
method.The service does not support cancellation of the long running operation and returns with an error message indicating absence of cancellation support.
Code sample
String copyModelId = "copy-model"; String targetModelId = "my-copied-model-id"; // Get authorization to copy the model to target resource CopyAuthorization copyAuthorization = documentModelAdministrationClient.getCopyAuthorization(targetModelId); // Start copy operation from the source client DocumentModel documentModel = documentModelAdministrationClient.beginCopyModel(copyModelId, copyAuthorization, Context.NONE).getFinalResult(); System.out.printf("Copied model has model ID: %s, was created on: %s.%n,", documentModel.getModelId(), documentModel.getCreatedOn());
- Parameters:
modelId
- Model identifier of the model to copy to target resource.target
- the copy authorization to the target Form Recognizer resource. The copy authorization can be generated from the target resource's call togetCopyAuthorization(String)
.context
- Additional context that is passed through the HTTP pipeline during the service call.- Returns:
- A
SyncPoller
that polls the copy model operation until it has completed, has failed, or has been cancelled.
-
listModels
public com.azure.core.http.rest.PagedIterable<DocumentModelInfo> listModels()
List information for each model on the Form Recognizer account that were built successfully.Code sample
documentModelAdministrationClient.listModels() .forEach(documentModel -> System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n", documentModel.getModelId(), documentModel.getDescription(), documentModel.getCreatedOn()) );
- Returns:
PagedIterable
ofDocumentModelInfo
custom form model information.
-
listModels
public com.azure.core.http.rest.PagedIterable<DocumentModelInfo> listModels(com.azure.core.util.Context context)
List information for each model on the Form Recognizer account that were built successfully with a Http response and a specifiedContext
.Code sample
documentModelAdministrationClient.listModels(Context.NONE) .forEach(documentModel -> System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n", documentModel.getModelId(), documentModel.getDescription(), documentModel.getCreatedOn()) );
- Parameters:
context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
PagedIterable
ofDocumentModelInfo
custom form model information.
-
getModel
public DocumentModel getModel(String modelId)
Get detailed information for a specified model ID.Code sample
String modelId = "{model_id}"; DocumentModel documentModel = documentModelAdministrationClient.getModel(modelId); 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.getCreatedOn()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
modelId
- The unique model identifier.- Returns:
- The detailed information for the specified model.
- Throws:
IllegalArgumentException
- IfmodelId
is null or empty.
-
getModelWithResponse
public com.azure.core.http.rest.Response<DocumentModel> getModelWithResponse(String modelId, com.azure.core.util.Context context)
Get detailed information for a specified model ID.Code sample
String modelId = "{model_id}"; Response<DocumentModel> response = documentModelAdministrationClient.getModelWithResponse(modelId, Context.NONE); System.out.printf("Response Status Code: %d.", response.getStatusCode()); DocumentModel documentModel = response.getValue(); 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.getCreatedOn()); documentModel.getDocTypes().forEach((key, docTypeInfo) -> { docTypeInfo.getFieldSchema().forEach((field, documentFieldSchema) -> { System.out.printf("Field: %s", field); System.out.printf("Field type: %s", documentFieldSchema.getType()); System.out.printf("Field confidence: %.2f", docTypeInfo.getFieldConfidence().get(field)); }); });
- Parameters:
modelId
- The unique model identifier.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The detailed information for the specified model.
- Throws:
IllegalArgumentException
- IfmodelId
is null or empty.
-
getOperation
public ModelOperation getOperation(String operationId)
Get detailed operation information for the specified ID with Http response.This operations fails if the operation ID used is past 24 hours.
Code sample
String operationId = "{operation_Id}"; ModelOperation modelOperation = documentModelAdministrationClient.getOperation(operationId); System.out.printf("Operation ID: %s%n", modelOperation.getOperationId()); System.out.printf("Operation Kind: %s%n", modelOperation.getKind()); System.out.printf("Operation Status: %s%n", modelOperation.getStatus()); System.out.printf("Model ID created with this operation: %s%n", modelOperation.getModelId()); if (ModelOperationStatus.FAILED.equals(modelOperation.getStatus())) { System.out.printf("Operation fail error: %s%n", modelOperation.getError().getMessage()); }
- Parameters:
operationId
- Unique operation ID.- Returns:
- The detailed information for the specified operation.
- Throws:
IllegalArgumentException
- IfoperationId
is null or empty.
-
getOperationWithResponse
public com.azure.core.http.rest.Response<ModelOperation> getOperationWithResponse(String operationId, com.azure.core.util.Context context)
Get detailed operation information for the specified ID with Http response.This operations fails if the operation ID used is past 24 hours.
Code sample
String operationId = "{operation_Id}"; Response<ModelOperation> response = documentModelAdministrationClient.getOperationWithResponse(operationId, Context.NONE); System.out.printf("Response Status Code: %d.", response.getStatusCode()); ModelOperation modelOperation = response.getValue(); System.out.printf("Operation ID: %s%n", modelOperation.getOperationId()); System.out.printf("Operation Kind: %s%n", modelOperation.getKind()); System.out.printf("Operation Status: %s%n", modelOperation.getStatus()); System.out.printf("Model ID created with this operation: %s%n", modelOperation.getModelId()); if (ModelOperationStatus.FAILED.equals(modelOperation.getStatus())) { System.out.printf("Operation fail error: %s%n", modelOperation.getError().getMessage()); }
- Parameters:
operationId
- Unique operation ID.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The detailed information for the specified operation.
- Throws:
IllegalArgumentException
- IfoperationId
is null or empty.
-
listOperations
public com.azure.core.http.rest.PagedIterable<ModelOperationInfo> listOperations()
List information for each model operation on the Form Recognizer account in the past 24 hours.Code sample
PagedIterable<ModelOperationInfo> modelOperationInfo = documentModelAdministrationClient.listOperations(); modelOperationInfo.forEach(modelOperation -> { System.out.printf("Operation ID: %s%n", modelOperation.getOperationId()); System.out.printf("Operation Status: %s%n", modelOperation.getStatus()); System.out.printf("Operation Created on: %s%n", modelOperation.getCreatedOn()); System.out.printf("Operation Percent completed: %d%n", modelOperation.getPercentCompleted()); System.out.printf("Operation Kind: %s%n", modelOperation.getKind()); System.out.printf("Operation Last updated on: %s%n", modelOperation.getLastUpdatedOn()); System.out.printf("Operation resource location: %s%n", modelOperation.getResourceLocation()); });
- Returns:
PagedIterable
ofModelOperationInfo
custom form model information.
-
listOperations
public com.azure.core.http.rest.PagedIterable<ModelOperationInfo> listOperations(com.azure.core.util.Context context)
List information for each operation on the Form Recognizer account in the past 24 hours with an HTTP response and a specifiedContext
.Code sample
PagedIterable<ModelOperationInfo> modelOperationInfo = documentModelAdministrationClient.listOperations(Context.NONE); modelOperationInfo.forEach(modelOperation -> { System.out.printf("Operation ID: %s%n", modelOperation.getOperationId()); System.out.printf("Operation Status: %s%n", modelOperation.getStatus()); System.out.printf("Operation Created on: %s%n", modelOperation.getCreatedOn()); System.out.printf("Operation Percent completed: %d%n", modelOperation.getPercentCompleted()); System.out.printf("Operation Kind: %s%n", modelOperation.getKind()); System.out.printf("Operation Last updated on: %s%n", modelOperation.getLastUpdatedOn()); System.out.printf("Operation resource location: %s%n", modelOperation.getResourceLocation()); });
- Parameters:
context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
PagedIterable
ofModelOperationInfo
custom form model information.
-
-