Service to call Cloud DocumentAI to manage document collection (dataset). v1beta3
Package
@google-cloud/documentaiConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of DocumentServiceClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
documentServiceStub
documentServiceStub?: 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.
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchDeleteDocuments(request, options)
batchDeleteDocuments(request?: protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Deletes a set of documents.
Parameters | |
---|---|
Name | Description |
request |
IBatchDeleteDocumentsRequest
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.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>,
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 dataset resource name.
* Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
*/
// const dataset = 'abc123'
/**
* Required. Dataset documents input. If given `filter`, all documents
* satisfying the filter will be deleted. If given documentIds, a maximum of
* 50 documents can be deleted in a batch. The request will be rejected if
* more than 50 document_ids are provided.
*/
// const datasetDocuments = {}
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callBatchDeleteDocuments() {
// Construct request
const request = {
dataset,
datasetDocuments,
};
// Run request
const [operation] = await documentaiClient.batchDeleteDocuments(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchDeleteDocuments();
batchDeleteDocuments(request, options, callback)
batchDeleteDocuments(request: protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchDeleteDocumentsRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
batchDeleteDocuments(request, callback)
batchDeleteDocuments(request: protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsRequest, callback: Callback<LROperation<protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IBatchDeleteDocumentsRequest
|
callback |
Callback<LROperation<protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.IBatchDeleteDocumentsMetadata>, 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: ''});
checkBatchDeleteDocumentsProgress(name)
checkBatchDeleteDocumentsProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1beta3.BatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.BatchDeleteDocumentsMetadata>>;
Check the status of the long running operation returned by batchDeleteDocuments()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1beta3.BatchDeleteDocumentsResponse, protos.google.cloud.documentai.v1beta3.BatchDeleteDocumentsMetadata>> | {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 dataset resource name.
* Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
*/
// const dataset = 'abc123'
/**
* Required. Dataset documents input. If given `filter`, all documents
* satisfying the filter will be deleted. If given documentIds, a maximum of
* 50 documents can be deleted in a batch. The request will be rejected if
* more than 50 document_ids are provided.
*/
// const datasetDocuments = {}
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callBatchDeleteDocuments() {
// Construct request
const request = {
dataset,
datasetDocuments,
};
// Run request
const [operation] = await documentaiClient.batchDeleteDocuments(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchDeleteDocuments();
checkImportDocumentsProgress(name)
checkImportDocumentsProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1beta3.ImportDocumentsResponse, protos.google.cloud.documentai.v1beta3.ImportDocumentsMetadata>>;
Check the status of the long running operation returned by importDocuments()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1beta3.ImportDocumentsResponse, protos.google.cloud.documentai.v1beta3.ImportDocumentsMetadata>> | {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 dataset resource name.
* Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
*/
// const dataset = 'abc123'
/**
* Required. The Cloud Storage uri containing raw documents that must be
* imported.
*/
// const batchDocumentsImportConfigs = [1,2,3,4]
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callImportDocuments() {
// Construct request
const request = {
dataset,
batchDocumentsImportConfigs,
};
// Run request
const [operation] = await documentaiClient.importDocuments(request);
const [response] = await operation.promise();
console.log(response);
}
callImportDocuments();
checkUpdateDatasetProgress(name)
checkUpdateDatasetProgress(name: string): Promise<LROperation<protos.google.cloud.documentai.v1beta3.Dataset, protos.google.cloud.documentai.v1beta3.UpdateDatasetOperationMetadata>>;
Check the status of the long running operation returned by updateDataset()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.cloud.documentai.v1beta3.Dataset, protos.google.cloud.documentai.v1beta3.UpdateDatasetOperationMetadata>> | {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 `name` field of the `Dataset` is used to identify the
* resource to be updated.
*/
// const dataset = {}
/**
* The update mask applies to the resource.
*/
// const updateMask = {}
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callUpdateDataset() {
// Construct request
const request = {
dataset,
};
// Run request
const [operation] = await documentaiClient.updateDataset(request);
const [response] = await operation.promise();
console.log(response);
}
callUpdateDataset();
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. |
datasetPath(project, location, processor)
datasetPath(project: string, location: string, processor: string): string;
Return a fully-qualified dataset resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
processor |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
datasetSchemaPath(project, location, processor)
datasetSchemaPath(project: string, location: string, processor: string): string;
Return a fully-qualified datasetSchema resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
processor |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
deleteOperation(request, options, callback)
deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;
Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
DeleteOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
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.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
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.deleteOperation({name: ''});
evaluationPath(project, location, processor, processorVersion, evaluation)
evaluationPath(project: string, location: string, processor: string, processorVersion: string, evaluation: string): string;
Return a fully-qualified evaluation resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
processor |
string
|
processorVersion |
string
|
evaluation |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
getDatasetSchema(request, options)
getDatasetSchema(request?: protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest, options?: CallOptions): Promise<[
protos.google.cloud.documentai.v1beta3.IDatasetSchema,
(protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | undefined),
{} | undefined
]>;
Gets the DatasetSchema
of a Dataset
.
Parameters | |
---|---|
Name | Description |
request |
IGetDatasetSchemaRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.documentai.v1beta3.IDatasetSchema,
(protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | undefined),
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing DatasetSchema. 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 dataset schema resource name.
* Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset/datasetSchema
*/
// const name = 'abc123'
/**
* If set, only returns the visible fields of the schema.
*/
// const visibleFieldsOnly = true
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callGetDatasetSchema() {
// Construct request
const request = {
name,
};
// Run request
const response = await documentaiClient.getDatasetSchema(request);
console.log(response);
}
callGetDatasetSchema();
getDatasetSchema(request, options, callback)
getDatasetSchema(request: protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest, options: CallOptions, callback: Callback<protos.google.cloud.documentai.v1beta3.IDatasetSchema, protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetDatasetSchemaRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.documentai.v1beta3.IDatasetSchema, protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getDatasetSchema(request, callback)
getDatasetSchema(request: protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest, callback: Callback<protos.google.cloud.documentai.v1beta3.IDatasetSchema, protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetDatasetSchemaRequest
|
callback |
Callback<protos.google.cloud.documentai.v1beta3.IDatasetSchema, protos.google.cloud.documentai.v1beta3.IGetDatasetSchemaRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getDocument(request, options)
getDocument(request?: protos.google.cloud.documentai.v1beta3.IGetDocumentRequest, options?: CallOptions): Promise<[
protos.google.cloud.documentai.v1beta3.IGetDocumentResponse,
protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | undefined,
{} | undefined
]>;
Returns relevant fields present in the requested document.
Parameters | |
---|---|
Name | Description |
request |
IGetDocumentRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.documentai.v1beta3.IGetDocumentResponse,
protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing GetDocumentResponse. 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 dataset that the document belongs to .
* Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
*/
// const dataset = 'abc123'
/**
* Required. Document identifier.
*/
// const documentId = {}
/**
* If set, only fields listed here will be returned. Otherwise, all fields
* will be returned by default.
*/
// const readMask = {}
/**
* List of pages for which the fields specified in the `read_mask` must
* be served.
*/
// const pageRange = {}
// Imports the Documentai library
const {DocumentServiceClient} = require('@google-cloud/documentai').v1beta3;
// Instantiates a client
const documentaiClient = new DocumentServiceClient();
async function callGetDocument() {
// Construct request
const request = {
dataset,
documentId,
};
// Run request
const response = await documentaiClient.getDocument(request);
console.log(response);
}
callGetDocument();
getDocument(request, options, callback)
getDocument(request: protos.google.cloud.documentai.v1beta3.IGetDocumentRequest, options: CallOptions, callback: Callback<protos.google.cloud.documentai.v1beta3.IGetDocumentResponse, protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetDocumentRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.documentai.v1beta3.IGetDocumentResponse, protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getDocument(request, callback)
getDocument(request: protos.google.cloud.documentai.v1beta3.IGetDocumentRequest, callback: Callback<protos.google.cloud.documentai.v1beta3.IGetDocumentResponse, protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetDocumentRequest
|
callback |
Callback<protos.google.cloud.documentai.v1beta3.IGetDocumentResponse, protos.google.cloud.documentai.v1beta3.IGetDocumentRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getLocation(request, options, callback)
getLocation(request: LocationProtos.google.cloud.location.IGetLocationRequest, options?: gax.CallOptions | Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>, callback?: Callback<LocationProtos.google.cloud.location.ILocation, LocationProtos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): Promise<LocationProtos.google.cloud.location.ILocation>;
Gets information about a location.
Parameters | |
---|---|
Name | Description |
request |
LocationProtos.google.cloud.location.IGetLocationRequest
The request object that will be sent. |
options |
CallOptions | Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>
Call options. See CallOptions for more details. |
callback |
Callback<google.cloud.location.ILocation, google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
Promise<google.cloud.location.ILocation> | {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. |
const [response] = await client.getLocation(request);
getOperation(request, options, callback)
getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
GetOperationRequest
The request object that will be sent. |
options |
CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
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.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<[protos.google.longrunning.Operation]> |
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
importDocuments(request, options)
importDocuments(request?: protos.google.cloud.documentai.v1beta3.IImportDocumentsRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.documentai.v1beta3.IImportDocumentsResponse, protos.google.cloud.documentai.v1beta3.IImportDocumentsMetadata>,
protos.google.longrunning.IOperation