- 0.50.0 (latest)
- 0.49.0
- 0.48.0
- 0.47.0
- 0.45.0
- 0.44.0
- 0.43.0
- 0.42.0
- 0.41.0
- 0.40.0
- 0.39.0
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.20.0
- 0.19.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
public class DocumentServiceClient implements BackgroundResource
Service Description: This service lets you manage document.
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()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Document document = Document.newBuilder().build();
CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
}
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().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns 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.newBuilder()
.setTransportChannelProvider(
DocumentServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
DocumentServiceClient documentServiceClient =
DocumentServiceClient.create(documentServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final DocumentServiceClient create()
Constructs an instance of DocumentServiceClient with default settings.
Type | Description |
DocumentServiceClient |
Type | Description |
IOException |
create(DocumentServiceSettings settings)
public static final DocumentServiceClient create(DocumentServiceSettings settings)
Constructs an instance of DocumentServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | DocumentServiceSettings |
Type | Description |
DocumentServiceClient |
Type | Description |
IOException |
create(DocumentServiceStub stub)
public static final DocumentServiceClient create(DocumentServiceStub stub)
Constructs an instance of DocumentServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(DocumentServiceSettings).
Name | Description |
stub | DocumentServiceStub |
Type | Description |
DocumentServiceClient |
Constructors
DocumentServiceClient(DocumentServiceSettings settings)
protected DocumentServiceClient(DocumentServiceSettings settings)
Constructs an instance of DocumentServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | DocumentServiceSettings |
DocumentServiceClient(DocumentServiceStub stub)
protected DocumentServiceClient(DocumentServiceStub stub)
Name | Description |
stub | DocumentServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createDocument(CreateDocumentRequest request)
public final CreateDocumentResponse createDocument(CreateDocumentRequest request)
Creates a document.
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()) {
CreateDocumentRequest request =
CreateDocumentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setDocument(Document.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setPolicy(Policy.newBuilder().build())
.setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
.setCreateMask(FieldMask.newBuilder().build())
.build();
CreateDocumentResponse response = documentServiceClient.createDocument(request);
}
Name | Description |
request | CreateDocumentRequest The request object containing all of the parameters for the API call. |
Type | Description |
CreateDocumentResponse |
createDocument(LocationName parent, Document document)
public final CreateDocumentResponse createDocument(LocationName parent, Document document)
Creates a document.
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()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Document document = Document.newBuilder().build();
CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
}
Name | Description |
parent | LocationName Required. The parent name. Format: projects/{project_number}/locations/{location}. |
document | Document Required. The document to create. |
Type | Description |
CreateDocumentResponse |
createDocument(String parent, Document document)
public final CreateDocumentResponse createDocument(String parent, Document document)
Creates a document.
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 parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Document document = Document.newBuilder().build();
CreateDocumentResponse response = documentServiceClient.createDocument(parent, document);
}
Name | Description |
parent | String Required. The parent name. Format: projects/{project_number}/locations/{location}. |
document | Document Required. The document to create. |
Type | Description |
CreateDocumentResponse |
createDocumentCallable()
public final UnaryCallable<CreateDocumentRequest,CreateDocumentResponse> createDocumentCallable()
Creates a document.
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()) {
CreateDocumentRequest request =
CreateDocumentRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setDocument(Document.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setPolicy(Policy.newBuilder().build())
.setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
.setCreateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<CreateDocumentResponse> future =
documentServiceClient.createDocumentCallable().futureCall(request);
// Do something.
CreateDocumentResponse response = future.get();
}
Type | Description |
UnaryCallable<CreateDocumentRequest,CreateDocumentResponse> |
deleteDocument(DeleteDocumentRequest request)
public final void deleteDocument(DeleteDocumentRequest request)
Deletes a document. Returns NOT_FOUND if the document does not exist.
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()) {
DeleteDocumentRequest request =
DeleteDocumentRequest.newBuilder()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.build();
documentServiceClient.deleteDocument(request);
}
Name | Description |
request | DeleteDocumentRequest The request object containing all of the parameters for the API call. |
deleteDocument(DocumentName name)
public final void deleteDocument(DocumentName name)
Deletes a document. Returns NOT_FOUND if the document does not exist.
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()) {
DocumentName name =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
documentServiceClient.deleteDocument(name);
}
Name | Description |
name | DocumentName Required. The name of the document to delete. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
deleteDocument(String name)
public final void deleteDocument(String name)
Deletes a document. Returns NOT_FOUND if the document does not exist.
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 =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString();
documentServiceClient.deleteDocument(name);
}
Name | Description |
name | String Required. The name of the document to delete. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
deleteDocumentCallable()
public final UnaryCallable<DeleteDocumentRequest,Empty> deleteDocumentCallable()
Deletes a document. Returns NOT_FOUND if the document does not exist.
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()) {
DeleteDocumentRequest request =
DeleteDocumentRequest.newBuilder()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.build();
ApiFuture<Empty> future = documentServiceClient.deleteDocumentCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteDocumentRequest,Empty> |
fetchAcl(FetchAclRequest request)
public final FetchAclResponse fetchAcl(FetchAclRequest request)
Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.
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()) {
FetchAclRequest request =
FetchAclRequest.newBuilder()
.setResource("resource-341064690")
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setProjectOwner(true)
.build();
FetchAclResponse response = documentServiceClient.fetchAcl(request);
}
Name | Description |
request | FetchAclRequest The request object containing all of the parameters for the API call. |
Type | Description |
FetchAclResponse |
fetchAcl(String resource)
public final FetchAclResponse fetchAcl(String resource)
Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.
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 resource = "resource-341064690";
FetchAclResponse response = documentServiceClient.fetchAcl(resource);
}
Name | Description |
resource | String Required. REQUIRED: The resource for which the policy is being requested. Format for document: projects/{project_number}/locations/{location}/documents/{document_id}. Format for project: projects/{project_number}. |
Type | Description |
FetchAclResponse |
fetchAclCallable()
public final UnaryCallable<FetchAclRequest,FetchAclResponse> fetchAclCallable()
Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.
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()) {
FetchAclRequest request =
FetchAclRequest.newBuilder()
.setResource("resource-341064690")
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setProjectOwner(true)
.build();
ApiFuture<FetchAclResponse> future =
documentServiceClient.fetchAclCallable().futureCall(request);
// Do something.
FetchAclResponse response = future.get();
}
Type | Description |
UnaryCallable<FetchAclRequest,FetchAclResponse> |
getDocument(DocumentName name)
public final Document getDocument(DocumentName name)
Gets a document. Returns NOT_FOUND if the document does not exist.
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()) {
DocumentName name =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
Document response = documentServiceClient.getDocument(name);
}
Name | Description |
name | DocumentName Required. The name of the document to retrieve. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
Type | Description |
Document |
getDocument(GetDocumentRequest request)
public final Document getDocument(GetDocumentRequest request)
Gets a document. Returns NOT_FOUND if the document does not exist.
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()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.build();
Document response = documentServiceClient.getDocument(request);
}
Name | Description |
request | GetDocumentRequest The request object containing all of the parameters for the API call. |
Type | Description |
Document |
getDocument(String name)
public final Document getDocument(String name)
Gets a document. Returns NOT_FOUND if the document does not exist.
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 =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString();
Document response = documentServiceClient.getDocument(name);
}
Name | Description |
name | String Required. The name of the document to retrieve. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
Type | Description |
Document |
getDocumentCallable()
public final UnaryCallable<GetDocumentRequest,Document> getDocumentCallable()
Gets a document. Returns NOT_FOUND if the document does not exist.
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()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.build();
ApiFuture<Document> future = documentServiceClient.getDocumentCallable().futureCall(request);
// Do something.
Document response = future.get();
}
Type | Description |
UnaryCallable<GetDocumentRequest,Document> |
getSettings()
public final DocumentServiceSettings getSettings()
Type | Description |
DocumentServiceSettings |
getStub()
public DocumentServiceStub getStub()
Type | Description |
DocumentServiceStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
searchDocuments(LocationName parent)
public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments(LocationName parent)
Searches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
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()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (SearchDocumentsResponse.MatchingDocument element :
documentServiceClient.searchDocuments(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The parent, which owns this collection of documents. Format: projects/{project_number}/locations/{location}. |
Type | Description |
DocumentServiceClient.SearchDocumentsPagedResponse |
searchDocuments(SearchDocumentsRequest request)
public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments(SearchDocumentsRequest request)
Searches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
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()) {
SearchDocumentsRequest request =
SearchDocumentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setDocumentQuery(DocumentQuery.newBuilder().build())
.setOffset(-1019779949)
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.addAllHistogramQueries(new ArrayList<HistogramQuery>())
.setRequireTotalSize(true)
.setQaSizeLimit(142059404)
.build();
for (SearchDocumentsResponse.MatchingDocument element :
documentServiceClient.searchDocuments(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | SearchDocumentsRequest The request object containing all of the parameters for the API call. |
Type | Description |
DocumentServiceClient.SearchDocumentsPagedResponse |
searchDocuments(String parent)
public final DocumentServiceClient.SearchDocumentsPagedResponse searchDocuments(String parent)
Searches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
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 parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (SearchDocumentsResponse.MatchingDocument element :
documentServiceClient.searchDocuments(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The parent, which owns this collection of documents. Format: projects/{project_number}/locations/{location}. |
Type | Description |
DocumentServiceClient.SearchDocumentsPagedResponse |
searchDocumentsCallable()
public final UnaryCallable<SearchDocumentsRequest,SearchDocumentsResponse> searchDocumentsCallable()
Searches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
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()) {
SearchDocumentsRequest request =
SearchDocumentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setDocumentQuery(DocumentQuery.newBuilder().build())
.setOffset(-1019779949)
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.addAllHistogramQueries(new ArrayList<HistogramQuery>())
.setRequireTotalSize(true)
.setQaSizeLimit(142059404)
.build();
while (true) {
SearchDocumentsResponse response =
documentServiceClient.searchDocumentsCallable().call(request);
for (SearchDocumentsResponse.MatchingDocument element :
response.getMatchingDocumentsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<SearchDocumentsRequest,SearchDocumentsResponse> |
searchDocumentsPagedCallable()
public final UnaryCallable<SearchDocumentsRequest,DocumentServiceClient.SearchDocumentsPagedResponse> searchDocumentsPagedCallable()
Searches for documents using provided SearchDocumentsRequest. This call only returns documents that the caller has permission to search against.
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()) {
SearchDocumentsRequest request =
SearchDocumentsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setDocumentQuery(DocumentQuery.newBuilder().build())
.setOffset(-1019779949)
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOrderBy("orderBy-1207110587")
.addAllHistogramQueries(new ArrayList<HistogramQuery>())
.setRequireTotalSize(true)
.setQaSizeLimit(142059404)
.build();
ApiFuture<SearchDocumentsResponse.MatchingDocument> future =
documentServiceClient.searchDocumentsPagedCallable().futureCall(request);
// Do something.
for (SearchDocumentsResponse.MatchingDocument element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<SearchDocumentsRequest,SearchDocumentsPagedResponse> |
setAcl(SetAclRequest request)
public final SetAclResponse setAcl(SetAclRequest request)
Sets the access control policy for a resource. Replaces any existing policy.
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()) {
SetAclRequest request =
SetAclRequest.newBuilder()
.setResource("resource-341064690")
.setPolicy(Policy.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setProjectOwner(true)
.build();
SetAclResponse response = documentServiceClient.setAcl(request);
}
Name | Description |
request | SetAclRequest The request object containing all of the parameters for the API call. |
Type | Description |
SetAclResponse |
setAcl(String resource, Policy policy)
public final SetAclResponse setAcl(String resource, Policy policy)
Sets the access control policy for a resource. Replaces any existing policy.
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 resource = "resource-341064690";
Policy policy = Policy.newBuilder().build();
SetAclResponse response = documentServiceClient.setAcl(resource, policy);
}
Name | Description |
resource | String Required. REQUIRED: The resource for which the policy is being requested. Format for document: projects/{project_number}/locations/{location}/documents/{document_id}. Format for project: projects/{project_number}. |
policy | com.google.iam.v1.Policy Required. REQUIRED: The complete policy to be applied to the |
Type | Description |
SetAclResponse |
setAclCallable()
public final UnaryCallable<SetAclRequest,SetAclResponse> setAclCallable()
Sets the access control policy for a resource. Replaces any existing policy.
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()) {
SetAclRequest request =
SetAclRequest.newBuilder()
.setResource("resource-341064690")
.setPolicy(Policy.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setProjectOwner(true)
.build();
ApiFuture<SetAclResponse> future = documentServiceClient.setAclCallable().futureCall(request);
// Do something.
SetAclResponse response = future.get();
}
Type | Description |
UnaryCallable<SetAclRequest,SetAclResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateDocument(DocumentName name, Document document)
public final UpdateDocumentResponse updateDocument(DocumentName name, Document document)
Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing 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()) {
DocumentName name =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]");
Document document = Document.newBuilder().build();
UpdateDocumentResponse response = documentServiceClient.updateDocument(name, document);
}
Name | Description |
name | DocumentName Required. The name of the document to update. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
document | Document Required. The document to update. |
Type | Description |
UpdateDocumentResponse |
updateDocument(UpdateDocumentRequest request)
public final UpdateDocumentResponse updateDocument(UpdateDocumentRequest request)
Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing 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()) {
UpdateDocumentRequest request =
UpdateDocumentRequest.newBuilder()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setDocument(Document.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
.setUpdateOptions(UpdateOptions.newBuilder().build())
.build();
UpdateDocumentResponse response = documentServiceClient.updateDocument(request);
}
Name | Description |
request | UpdateDocumentRequest The request object containing all of the parameters for the API call. |
Type | Description |
UpdateDocumentResponse |
updateDocument(String name, Document document)
public final UpdateDocumentResponse updateDocument(String name, Document document)
Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing 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 =
DocumentName.ofProjectLocationDocumentName("[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString();
Document document = Document.newBuilder().build();
UpdateDocumentResponse response = documentServiceClient.updateDocument(name, document);
}
Name | Description |
name | String Required. The name of the document to update. Format: projects/{project_number}/locations/{location}/documents/{document_id} or projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. |
document | Document Required. The document to update. |
Type | Description |
UpdateDocumentResponse |
updateDocumentCallable()
public final UnaryCallable<UpdateDocumentRequest,UpdateDocumentResponse> updateDocumentCallable()
Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing 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()) {
UpdateDocumentRequest request =
UpdateDocumentRequest.newBuilder()
.setName(
DocumentName.ofProjectLocationDocumentName(
"[PROJECT]", "[LOCATION]", "[DOCUMENT]")
.toString())
.setDocument(Document.newBuilder().build())
.setRequestMetadata(RequestMetadata.newBuilder().build())
.setCloudAiDocumentOption(CloudAIDocumentOption.newBuilder().build())
.setUpdateOptions(UpdateOptions.newBuilder().build())
.build();
ApiFuture<UpdateDocumentResponse> future =
documentServiceClient.updateDocumentCallable().futureCall(request);
// Do something.
UpdateDocumentResponse response = future.get();
}
Type | Description |
UnaryCallable<UpdateDocumentRequest,UpdateDocumentResponse> |