@BetaApi @Generated(value="by gapic-generator-java") public class DocumentServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetName dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
GetDocumentResponse response = documentServiceClient.getDocument(dataset);
}
Note: close() needs to be called on the DocumentServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
UpdateDataset |
Updates metadata associated with a dataset. Note that this method requires the `documentai.googleapis.com/datasets.update` 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. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ImportDocuments |
Import documents into a dataset. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetDocument |
Returns relevant fields present in the requested document. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListDocuments |
Returns a list of documents present in the dataset. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
BatchDeleteDocuments |
Deletes a set of documents. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetDatasetSchema |
Gets the `DatasetSchema` of a `Dataset`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateDatasetSchema |
Updates a `DatasetSchema`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DocumentServiceSettings to create(). For example:
To customize credentials:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DocumentServiceSettings documentServiceSettings =
DocumentServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DocumentServiceClient documentServiceClient =
DocumentServiceClient.create(documentServiceSettings);
To customize the endpoint:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DocumentServiceSettings documentServiceSettings =
DocumentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
DocumentServiceClient documentServiceClient =
DocumentServiceClient.create(documentServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DocumentServiceSettings documentServiceSettings =
DocumentServiceSettings.newHttpJsonBuilder().build();
DocumentServiceClient documentServiceClient =
DocumentServiceClient.create(documentServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
DocumentServiceClient.ListDocumentsFixedSizeCollection |
static class |
DocumentServiceClient.ListDocumentsPage |
static class |
DocumentServiceClient.ListDocumentsPagedResponse |
static class |
DocumentServiceClient.ListLocationsFixedSizeCollection |
static class |
DocumentServiceClient.ListLocationsPage |
static class |
DocumentServiceClient.ListLocationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
DocumentServiceClient(DocumentServiceSettings settings)
Constructs an instance of DocumentServiceClient, using the given settings.
|
protected |
DocumentServiceClient(DocumentServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.api.gax.longrunning.OperationFuture<BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> |
batchDeleteDocumentsAsync(BatchDeleteDocumentsRequest request)
Deletes a set of documents.
|
com.google.api.gax.longrunning.OperationFuture<BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> |
batchDeleteDocumentsAsync(String dataset)
Deletes a set of documents.
|
com.google.api.gax.rpc.UnaryCallable<BatchDeleteDocumentsRequest,com.google.longrunning.Operation> |
batchDeleteDocumentsCallable()
Deletes a set of documents.
|
com.google.api.gax.rpc.OperationCallable<BatchDeleteDocumentsRequest,BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> |
batchDeleteDocumentsOperationCallable()
Deletes a set of documents.
|
void |
close() |
static DocumentServiceClient |
create()
Constructs an instance of DocumentServiceClient with default settings.
|
static DocumentServiceClient |
create(DocumentServiceSettings settings)
Constructs an instance of DocumentServiceClient, using the given settings.
|
static DocumentServiceClient |
create(DocumentServiceStub stub)
Constructs an instance of DocumentServiceClient, using the given stub for making calls.
|
DatasetSchema |
getDatasetSchema(DatasetSchemaName name)
Gets the `DatasetSchema` of a `Dataset`.
|
DatasetSchema |
getDatasetSchema(GetDatasetSchemaRequest request)
Gets the `DatasetSchema` of a `Dataset`.
|
DatasetSchema |
getDatasetSchema(String name)
Gets the `DatasetSchema` of a `Dataset`.
|
com.google.api.gax.rpc.UnaryCallable<GetDatasetSchemaRequest,DatasetSchema> |
getDatasetSchemaCallable()
Gets the `DatasetSchema` of a `Dataset`.
|
GetDocumentResponse |
getDocument(DatasetName dataset)
Returns relevant fields present in the requested document.
|
GetDocumentResponse |
getDocument(GetDocumentRequest request)
Returns relevant fields present in the requested document.
|
GetDocumentResponse |
getDocument(String dataset)
Returns relevant fields present in the requested document.
|
com.google.api.gax.rpc.UnaryCallable<GetDocumentRequest,GetDocumentResponse> |
getDocumentCallable()
Returns relevant fields present in the requested document.
|
com.google.api.gax.httpjson.longrunning.OperationsClient |
getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
DocumentServiceSettings |
getSettings() |
DocumentServiceStub |
getStub() |
com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> |
importDocumentsAsync(DatasetName dataset)
Import documents into a dataset.
|
com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> |
importDocumentsAsync(ImportDocumentsRequest request)
Import documents into a dataset.
|
com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> |
importDocumentsAsync(String dataset)
Import documents into a dataset.
|
com.google.api.gax.rpc.UnaryCallable<ImportDocumentsRequest,com.google.longrunning.Operation> |
importDocumentsCallable()
Import documents into a dataset.
|
com.google.api.gax.rpc.OperationCallable<ImportDocumentsRequest,ImportDocumentsResponse,ImportDocumentsMetadata> |
importDocumentsOperationCallable()
Import documents into a dataset.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
DocumentServiceClient.ListDocumentsPagedResponse |
listDocuments(DatasetName dataset)
Returns a list of documents present in the dataset.
|
DocumentServiceClient.ListDocumentsPagedResponse |
listDocuments(ListDocumentsRequest request)
Returns a list of documents present in the dataset.
|
DocumentServiceClient.ListDocumentsPagedResponse |
listDocuments(String dataset)
Returns a list of documents present in the dataset.
|
com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,ListDocumentsResponse> |
listDocumentsCallable()
Returns a list of documents present in the dataset.
|
com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,DocumentServiceClient.ListDocumentsPagedResponse> |
listDocumentsPagedCallable()
Returns a list of documents present in the dataset.
|
DocumentServiceClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,DocumentServiceClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<Dataset,UpdateDatasetOperationMetadata> |
updateDatasetAsync(Dataset dataset,
com.google.protobuf.FieldMask updateMask)
Updates metadata associated with a dataset.
|
com.google.api.gax.longrunning.OperationFuture<Dataset,UpdateDatasetOperationMetadata> |
updateDatasetAsync(UpdateDatasetRequest request)
Updates metadata associated with a dataset.
|
com.google.api.gax.rpc.UnaryCallable<UpdateDatasetRequest,com.google.longrunning.Operation> |
updateDatasetCallable()
Updates metadata associated with a dataset.
|
com.google.api.gax.rpc.OperationCallable<UpdateDatasetRequest,Dataset,UpdateDatasetOperationMetadata> |
updateDatasetOperationCallable()
Updates metadata associated with a dataset.
|
DatasetSchema |
updateDatasetSchema(DatasetSchema datasetSchema,
com.google.protobuf.FieldMask updateMask)
Updates a `DatasetSchema`.
|
DatasetSchema |
updateDatasetSchema(UpdateDatasetSchemaRequest request)
Updates a `DatasetSchema`.
|
com.google.api.gax.rpc.UnaryCallable<UpdateDatasetSchemaRequest,DatasetSchema> |
updateDatasetSchemaCallable()
Updates a `DatasetSchema`.
|
protected DocumentServiceClient(DocumentServiceSettings settings) throws IOException
IOExceptionprotected DocumentServiceClient(DocumentServiceStub stub)
public static final DocumentServiceClient create() throws IOException
IOExceptionpublic static final DocumentServiceClient create(DocumentServiceSettings settings) throws IOException
IOExceptionpublic static final DocumentServiceClient create(DocumentServiceStub stub)
public final DocumentServiceSettings getSettings()
public DocumentServiceStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<Dataset,UpdateDatasetOperationMetadata> updateDatasetAsync(Dataset dataset, com.google.protobuf.FieldMask updateMask)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
Dataset dataset = Dataset.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Dataset response = documentServiceClient.updateDatasetAsync(dataset, updateMask).get();
}
dataset - Required. The `name` field of the `Dataset` is used to identify the resource to
be updated.updateMask - The update mask applies to the resource.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Dataset,UpdateDatasetOperationMetadata> updateDatasetAsync(UpdateDatasetRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
UpdateDatasetRequest request =
UpdateDatasetRequest.newBuilder()
.setDataset(Dataset.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Dataset response = documentServiceClient.updateDatasetAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<UpdateDatasetRequest,Dataset,UpdateDatasetOperationMetadata> updateDatasetOperationCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
UpdateDatasetRequest request =
UpdateDatasetRequest.newBuilder()
.setDataset(Dataset.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
OperationFuture<Dataset, UpdateDatasetOperationMetadata> future =
documentServiceClient.updateDatasetOperationCallable().futureCall(request);
// Do something.
Dataset response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UpdateDatasetRequest,com.google.longrunning.Operation> updateDatasetCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
UpdateDatasetRequest request =
UpdateDatasetRequest.newBuilder()
.setDataset(Dataset.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Operation> future =
documentServiceClient.updateDatasetCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsAsync(DatasetName dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetName dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(dataset).get();
}
dataset - Required. The dataset resource name. Format:
projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsAsync(String dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
String dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(dataset).get();
}
dataset - Required. The dataset resource name. Format:
projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsAsync(ImportDocumentsRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ImportDocumentsRequest request =
ImportDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.addAllBatchDocumentsImportConfigs(
new ArrayList<ImportDocumentsRequest.BatchDocumentsImportConfig>())
.build();
ImportDocumentsResponse response = documentServiceClient.importDocumentsAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<ImportDocumentsRequest,ImportDocumentsResponse,ImportDocumentsMetadata> importDocumentsOperationCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ImportDocumentsRequest request =
ImportDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.addAllBatchDocumentsImportConfigs(
new ArrayList<ImportDocumentsRequest.BatchDocumentsImportConfig>())
.build();
OperationFuture<ImportDocumentsResponse, ImportDocumentsMetadata> future =
documentServiceClient.importDocumentsOperationCallable().futureCall(request);
// Do something.
ImportDocumentsResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ImportDocumentsRequest,com.google.longrunning.Operation> importDocumentsCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ImportDocumentsRequest request =
ImportDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.addAllBatchDocumentsImportConfigs(
new ArrayList<ImportDocumentsRequest.BatchDocumentsImportConfig>())
.build();
ApiFuture<Operation> future =
documentServiceClient.importDocumentsCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final GetDocumentResponse getDocument(DatasetName dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetName dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
GetDocumentResponse response = documentServiceClient.getDocument(dataset);
}
dataset - Required. The resource name of the dataset that the document belongs to .
Format: projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final GetDocumentResponse getDocument(String dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
String dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
GetDocumentResponse response = documentServiceClient.getDocument(dataset);
}
dataset - Required. The resource name of the dataset that the document belongs to .
Format: projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final GetDocumentResponse getDocument(GetDocumentRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetDocumentRequest request =
GetDocumentRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setDocumentId(DocumentId.newBuilder().build())
.setReadMask(FieldMask.newBuilder().build())
.setPageRange(DocumentPageRange.newBuilder().build())
.build();
GetDocumentResponse response = documentServiceClient.getDocument(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetDocumentRequest,GetDocumentResponse> getDocumentCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetDocumentRequest request =
GetDocumentRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setDocumentId(DocumentId.newBuilder().build())
.setReadMask(FieldMask.newBuilder().build())
.setPageRange(DocumentPageRange.newBuilder().build())
.build();
ApiFuture<GetDocumentResponse> future =
documentServiceClient.getDocumentCallable().futureCall(request);
// Do something.
GetDocumentResponse response = future.get();
}
public final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(DatasetName dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetName dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
for (DocumentMetadata element : documentServiceClient.listDocuments(dataset).iterateAll()) {
// doThingsWith(element);
}
}
dataset - Required. The resource name of the dataset to be listed. Format:
projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(String dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
String dataset = DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
for (DocumentMetadata element : documentServiceClient.listDocuments(dataset).iterateAll()) {
// doThingsWith(element);
}
}
dataset - Required. The resource name of the dataset to be listed. Format:
projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final DocumentServiceClient.ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListDocumentsRequest request =
ListDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setReturnTotalSize(true)
.setSkip(3532159)
.build();
for (DocumentMetadata element : documentServiceClient.listDocuments(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,DocumentServiceClient.ListDocumentsPagedResponse> listDocumentsPagedCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListDocumentsRequest request =
ListDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setReturnTotalSize(true)
.setSkip(3532159)
.build();
ApiFuture<DocumentMetadata> future =
documentServiceClient.listDocumentsPagedCallable().futureCall(request);
// Do something.
for (DocumentMetadata element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListDocumentsRequest,ListDocumentsResponse> listDocumentsCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListDocumentsRequest request =
ListDocumentsRequest.newBuilder()
.setDataset(DatasetName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setReturnTotalSize(true)
.setSkip(3532159)
.build();
while (true) {
ListDocumentsResponse response =
documentServiceClient.listDocumentsCallable().call(request);
for (DocumentMetadata element : response.getDocumentMetadataList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.api.gax.longrunning.OperationFuture<BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> batchDeleteDocumentsAsync(String dataset)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
String dataset = "dataset1443214456";
BatchDeleteDocumentsResponse response =
documentServiceClient.batchDeleteDocumentsAsync(dataset).get();
}
dataset - Required. The dataset resource name. Format:
projects/{project}/locations/{location}/processors/{processor}/datasetcom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> batchDeleteDocumentsAsync(BatchDeleteDocumentsRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
BatchDeleteDocumentsRequest request =
BatchDeleteDocumentsRequest.newBuilder()
.setDataset("dataset1443214456")
.setDatasetDocuments(BatchDatasetDocuments.newBuilder().build())
.build();
BatchDeleteDocumentsResponse response =
documentServiceClient.batchDeleteDocumentsAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<BatchDeleteDocumentsRequest,BatchDeleteDocumentsResponse,BatchDeleteDocumentsMetadata> batchDeleteDocumentsOperationCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
BatchDeleteDocumentsRequest request =
BatchDeleteDocumentsRequest.newBuilder()
.setDataset("dataset1443214456")
.setDatasetDocuments(BatchDatasetDocuments.newBuilder().build())
.build();
OperationFuture<BatchDeleteDocumentsResponse, BatchDeleteDocumentsMetadata> future =
documentServiceClient.batchDeleteDocumentsOperationCallable().futureCall(request);
// Do something.
BatchDeleteDocumentsResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<BatchDeleteDocumentsRequest,com.google.longrunning.Operation> batchDeleteDocumentsCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
BatchDeleteDocumentsRequest request =
BatchDeleteDocumentsRequest.newBuilder()
.setDataset("dataset1443214456")
.setDatasetDocuments(BatchDatasetDocuments.newBuilder().build())
.build();
ApiFuture<Operation> future =
documentServiceClient.batchDeleteDocumentsCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final DatasetSchema getDatasetSchema(DatasetSchemaName name)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetSchemaName name = DatasetSchemaName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]");
DatasetSchema response = documentServiceClient.getDatasetSchema(name);
}
name - Required. The dataset schema resource name. Format:
projects/{project}/locations/{location}/processors/{processor}/dataset/datasetSchemacom.google.api.gax.rpc.ApiException - if the remote call failspublic final DatasetSchema getDatasetSchema(String name)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
String name = DatasetSchemaName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString();
DatasetSchema response = documentServiceClient.getDatasetSchema(name);
}
name - Required. The dataset schema resource name. Format:
projects/{project}/locations/{location}/processors/{processor}/dataset/datasetSchemacom.google.api.gax.rpc.ApiException - if the remote call failspublic final DatasetSchema getDatasetSchema(GetDatasetSchemaRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetDatasetSchemaRequest request =
GetDatasetSchemaRequest.newBuilder()
.setName(DatasetSchemaName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setVisibleFieldsOnly(true)
.build();
DatasetSchema response = documentServiceClient.getDatasetSchema(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetDatasetSchemaRequest,DatasetSchema> getDatasetSchemaCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetDatasetSchemaRequest request =
GetDatasetSchemaRequest.newBuilder()
.setName(DatasetSchemaName.of("[PROJECT]", "[LOCATION]", "[PROCESSOR]").toString())
.setVisibleFieldsOnly(true)
.build();
ApiFuture<DatasetSchema> future =
documentServiceClient.getDatasetSchemaCallable().futureCall(request);
// Do something.
DatasetSchema response = future.get();
}
public final DatasetSchema updateDatasetSchema(DatasetSchema datasetSchema, com.google.protobuf.FieldMask updateMask)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
DatasetSchema datasetSchema = DatasetSchema.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
DatasetSchema response = documentServiceClient.updateDatasetSchema(datasetSchema, updateMask);
}
datasetSchema - Required. The name field of the `DatasetSchema` is used to identify the
resource to be updated.updateMask - The update mask applies to the resource.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DatasetSchema updateDatasetSchema(UpdateDatasetSchemaRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
UpdateDatasetSchemaRequest request =
UpdateDatasetSchemaRequest.newBuilder()
.setDatasetSchema(DatasetSchema.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
DatasetSchema response = documentServiceClient.updateDatasetSchema(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateDatasetSchemaRequest,DatasetSchema> updateDatasetSchemaCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
UpdateDatasetSchemaRequest request =
UpdateDatasetSchemaRequest.newBuilder()
.setDatasetSchema(DatasetSchema.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<DatasetSchema> future =
documentServiceClient.updateDatasetSchemaCallable().futureCall(request);
// Do something.
DatasetSchema response = future.get();
}
public final DocumentServiceClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : documentServiceClient.listLocations(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,DocumentServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future =
documentServiceClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response =
documentServiceClient.listLocationsCallable().call(request);
for (Location element : response.getLocationsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest request)
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = documentServiceClient.getLocation(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
Sample code:
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DocumentServiceClient documentServiceClient = DocumentServiceClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = documentServiceClient.getLocationCallable().futureCall(request);
// Do something.
Location response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2024 Google LLC. All rights reserved.