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
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;
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.
universeDomain
get universeDomain(): string;
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.