Service to call Document AI to process documents according to the processor's definition. Processors are built using state-of-the-art Google AI such as natural language, computer vision, and translation to extract structured information from unstructured or semi-structured documents. v1
Package
@google-cloud/documentaiConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of DocumentProcessorServiceClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
documentProcessorServiceStub
documentProcessorServiceStub?: Promise<{
[name: string]: Function;
}>;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
locationsClient
locationsClient: LocationsClient;
operationsClient
operationsClient: gax.OperationsClient;
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchProcessDocuments(request, options)
batchProcessDocuments(request?: protos.google.cloud.documentai.v1.IBatchProcessRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
Parameters | |
---|---|
Name | Description |
request |
IBatchProcessRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of
* Processor google.cloud.documentai.v1.Processor or
* ProcessorVersion google.cloud.documentai.v1.ProcessorVersion.
* Format: `projects/{project}/locations/{location}/processors/{processor}`,
* or
* `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
*/
// const name = 'abc123'
/**
* The input documents for the
* BatchProcessDocuments google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments
* method.
*/
// const inputDocuments = {}
/**
* The output configuration for the
* BatchProcessDocuments google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments
* method.
*/
// const documentOutputConfig = {}
/**
* Whether human review should be skipped for this request. Default to
* `false`.
*/
// const skipHumanReview = true
/**
* Inference-time options for the process API
*/
// const processOptions = {}
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
* (Unicode codepoints) and can only contain lowercase letters, numeric
* characters, underscores, and dashes. International characters are allowed.
* Label values are optional. Label keys must start with a letter.
*/
// const labels = [1,2,3,4]
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callBatchProcessDocuments() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.batchProcessDocuments(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchProcessDocuments();
batchProcessDocuments(request, options, callback)
batchProcessDocuments(request: protos.google.cloud.documentai.v1.IBatchProcessRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchProcessRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
batchProcessDocuments(request, callback)
batchProcessDocuments(request: protos.google.cloud.documentai.v1.IBatchProcessRequest, callback: Callback<LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchProcessRequest
|
callback |
Callback<LROperation<protos.google.cloud.documentai.v1.IBatchProcessResponse, protos.google.cloud.documentai.v1.IBatchProcessMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
cancelOperation(request, options, callback)
cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
CancelOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
checkBatchProcessDocumentsProgress(name)
checkBatchProcessDocumentsProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.BatchProcessResponse, protos.google.cloud.documentai.v1.BatchProcessMetadata>>;
Check the status of the long running operation returned by batchProcessDocuments()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.BatchProcessResponse, protos.google.cloud.documentai.v1.BatchProcessMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of
* Processor google.cloud.documentai.v1.Processor or
* ProcessorVersion google.cloud.documentai.v1.ProcessorVersion.
* Format: `projects/{project}/locations/{location}/processors/{processor}`,
* or
* `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
*/
// const name = 'abc123'
/**
* The input documents for the
* BatchProcessDocuments google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments
* method.
*/
// const inputDocuments = {}
/**
* The output configuration for the
* BatchProcessDocuments google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments
* method.
*/
// const documentOutputConfig = {}
/**
* Whether human review should be skipped for this request. Default to
* `false`.
*/
// const skipHumanReview = true
/**
* Inference-time options for the process API
*/
// const processOptions = {}
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
* (Unicode codepoints) and can only contain lowercase letters, numeric
* characters, underscores, and dashes. International characters are allowed.
* Label values are optional. Label keys must start with a letter.
*/
// const labels = [1,2,3,4]
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callBatchProcessDocuments() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.batchProcessDocuments(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchProcessDocuments();
checkDeleteProcessorProgress(name)
checkDeleteProcessorProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.documentai.v1.DeleteProcessorMetadata>>;
Check the status of the long running operation returned by deleteProcessor()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.documentai.v1.DeleteProcessorMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor resource name to be deleted.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callDeleteProcessor() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.deleteProcessor(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteProcessor();
checkDeleteProcessorVersionProgress(name)
checkDeleteProcessorVersionProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.documentai.v1.DeleteProcessorVersionMetadata>>;
Check the status of the long running operation returned by deleteProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.protobuf.Empty, protos.google.cloud.documentai.v1.DeleteProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor version resource name to be deleted.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callDeleteProcessorVersion() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.deleteProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteProcessorVersion();
checkDeployProcessorVersionProgress(name)
checkDeployProcessorVersionProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.DeployProcessorVersionResponse, protos.google.cloud.documentai.v1.DeployProcessorVersionMetadata>>;
Check the status of the long running operation returned by deployProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.DeployProcessorVersionResponse, protos.google.cloud.documentai.v1.DeployProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor version resource name to be deployed.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callDeployProcessorVersion() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.deployProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callDeployProcessorVersion();
checkDisableProcessorProgress(name)
checkDisableProcessorProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.DisableProcessorResponse, protos.google.cloud.documentai.v1.DisableProcessorMetadata>>;
Check the status of the long running operation returned by disableProcessor()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.DisableProcessorResponse, protos.google.cloud.documentai.v1.DisableProcessorMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor resource name to be disabled.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callDisableProcessor() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.disableProcessor(request);
const [response] = await operation.promise();
console.log(response);
}
callDisableProcessor();
checkEnableProcessorProgress(name)
checkEnableProcessorProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.EnableProcessorResponse, protos.google.cloud.documentai.v1.EnableProcessorMetadata>>;
Check the status of the long running operation returned by enableProcessor()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.EnableProcessorResponse, protos.google.cloud.documentai.v1.EnableProcessorMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor resource name to be enabled.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callEnableProcessor() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.enableProcessor(request);
const [response] = await operation.promise();
console.log(response);
}
callEnableProcessor();
checkEvaluateProcessorVersionProgress(name)
checkEvaluateProcessorVersionProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.EvaluateProcessorVersionResponse, protos.google.cloud.documentai.v1.EvaluateProcessorVersionMetadata>>;
Check the status of the long running operation returned by evaluateProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.EvaluateProcessorVersionResponse, protos.google.cloud.documentai.v1.EvaluateProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the
* ProcessorVersion google.cloud.documentai.v1.ProcessorVersion to
* evaluate.
* `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
*/
// const processorVersion = 'abc123'
/**
* Optional. The documents used in the evaluation. If unspecified, use the
* processor's dataset as evaluation input.
*/
// const evaluationDocuments = {}
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callEvaluateProcessorVersion() {
// Construct request
const request = {
processorVersion,
};
// Run request
const [operation] = await documentaiClient.evaluateProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callEvaluateProcessorVersion();
checkReviewDocumentProgress(name)
checkReviewDocumentProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.ReviewDocumentResponse, protos.google.cloud.documentai.v1.ReviewDocumentOperationMetadata>>;
Check the status of the long running operation returned by reviewDocument()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.ReviewDocumentResponse, protos.google.cloud.documentai.v1.ReviewDocumentOperationMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* An inline document proto.
*/
// const inlineDocument = {}
/**
* Required. The resource name of the
* HumanReviewConfig google.cloud.documentai.v1.HumanReviewConfig that the
* document will be reviewed with.
*/
// const humanReviewConfig = 'abc123'
/**
* Whether the validation should be performed on the ad-hoc review request.
*/
// const enableSchemaValidation = true
/**
* The priority of the human review task.
*/
// const priority = {}
/**
* The document schema of the human review task.
*/
// const documentSchema = {}
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callReviewDocument() {
// Construct request
const request = {
humanReviewConfig,
};
// Run request
const [operation] = await documentaiClient.reviewDocument(request);
const [response] = await operation.promise();
console.log(response);
}
callReviewDocument();
checkSetDefaultProcessorVersionProgress(name)
checkSetDefaultProcessorVersionProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.SetDefaultProcessorVersionResponse, protos.google.cloud.documentai.v1.SetDefaultProcessorVersionMetadata>>;
Check the status of the long running operation returned by setDefaultProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.SetDefaultProcessorVersionResponse, protos.google.cloud.documentai.v1.SetDefaultProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the
* Processor google.cloud.documentai.v1.Processor to change default
* version.
*/
// const processor = 'abc123'
/**
* Required. The resource name of child
* ProcessorVersion google.cloud.documentai.v1.ProcessorVersion to use as
* default. Format:
* `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}`
*/
// const defaultProcessorVersion = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callSetDefaultProcessorVersion() {
// Construct request
const request = {
processor,
defaultProcessorVersion,
};
// Run request
const [operation] = await documentaiClient.setDefaultProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callSetDefaultProcessorVersion();
checkTrainProcessorVersionProgress(name)
checkTrainProcessorVersionProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.TrainProcessorVersionResponse, protos.google.cloud.documentai.v1.TrainProcessorVersionMetadata>>;
Check the status of the long running operation returned by trainProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.TrainProcessorVersionResponse, protos.google.cloud.documentai.v1.TrainProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Options to control Custom Document Extraction (CDE) Processor.
*/
// const customDocumentExtractionOptions = {}
/**
* Options to control foundation model tuning of a processor.
*/
// const foundationModelTuningOptions = {}
/**
* Required. The parent (project, location and processor) to create the new
* version for. Format:
* `projects/{project}/locations/{location}/processors/{processor}`.
*/
// const parent = 'abc123'
/**
* Required. The processor version to be created.
*/
// const processorVersion = {}
/**
* Optional. The schema the processor version will be trained with.
*/
// const documentSchema = {}
/**
* Optional. The input data used to train the
* ProcessorVersion google.cloud.documentai.v1.ProcessorVersion.
*/
// const inputData = {}
/**
* Optional. The processor version to use as a base for training. This
* processor version must be a child of `parent`. Format:
* `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`.
*/
// const baseProcessorVersion = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callTrainProcessorVersion() {
// Construct request
const request = {
parent,
processorVersion,
};
// Run request
const [operation] = await documentaiClient.trainProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callTrainProcessorVersion();
checkUndeployProcessorVersionProgress(name)
checkUndeployProcessorVersionProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1.UndeployProcessorVersionResponse, protos.google.cloud.documentai.v1.UndeployProcessorVersionMetadata>>;
Check the status of the long running operation returned by undeployProcessorVersion()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1.UndeployProcessorVersionResponse, protos.google.cloud.documentai.v1.UndeployProcessorVersionMetadata>> |
{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The processor version resource name to be undeployed.
*/
// const name = 'abc123'
// Imports the Documentai library
const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1;
// Instantiates a client
const documentaiClient = new DocumentProcessorServiceClient();
async function callUndeployProcessorVersion() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await documentaiClient.undeployProcessorVersion(request);
const [response] = await operation.promise();
console.log(response);
}
callUndeployProcessorVersion();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> |
{Promise} A promise that resolves when the client is closed. |
createProcessor(request, options)
createProcessor(request?: protos.google.cloud.documentai.v1.ICreateProcessorRequest, options?: CallOptions): Promise<[
protos.google.cloud.documentai.v1.IProcessor,
protos.google.cloud.documentai.v1.ICreateProcessorRequest | undefined,
{} | undefined
]>;
Creates a processor from the provided. The processor will be at ENABLED
state by default after its creation. Note that this method requires the documentai.processors.create
permission on the project, which is highly privileged. A user or service account with this permission can create new processors that can interact with any gcs bucket in your project.
Parameters | |
---|---|
Name | Description |
request |
ICreateProcessorRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.documentai.v1.IProcessor,
protos.google.cloud.documentai.v1.ICreateProcessorRequest | undefined,
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent (project and location) under which to create the
* processor. Format: `projects/{project}/locations/{location}`
*/
// const parent = 'abc