Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [documentai] make page_range field public #9879

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -603,6 +603,180 @@ public final UnaryCallable<GetDocumentRequest, GetDocumentResponse> getDocumentC
return stub.getDocumentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of documents present in the dataset.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</pre>
*
* @param dataset Required. The resource name of the dataset to be listed. Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDocumentsPagedResponse listDocuments(DatasetName dataset) {
ListDocumentsRequest request =
ListDocumentsRequest.newBuilder()
.setDataset(dataset == null ? null : dataset.toString())
.build();
return listDocuments(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of documents present in the dataset.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</pre>
*
* @param dataset Required. The resource name of the dataset to be listed. Format:
* projects/{project}/locations/{location}/processors/{processor}/dataset
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDocumentsPagedResponse listDocuments(String dataset) {
ListDocumentsRequest request = ListDocumentsRequest.newBuilder().setDataset(dataset).build();
return listDocuments(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of documents present in the dataset.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request) {
return listDocumentsPagedCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of documents present in the dataset.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</pre>
*/
public final UnaryCallable<ListDocumentsRequest, ListDocumentsPagedResponse>
listDocumentsPagedCallable() {
return stub.listDocumentsPagedCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of documents present in the dataset.
*
* <p>Sample code:
*
* <pre>{@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;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<ListDocumentsRequest, ListDocumentsResponse> listDocumentsCallable() {
return stub.listDocumentsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a set of documents.
@@ -1117,6 +1291,82 @@ public boolean awaitTermination(long duration, TimeUnit unit) throws Interrupted
return stub.awaitTermination(duration, unit);
}

public static class ListDocumentsPagedResponse
extends AbstractPagedListResponse<
ListDocumentsRequest,
ListDocumentsResponse,
DocumentMetadata,
ListDocumentsPage,
ListDocumentsFixedSizeCollection> {

public static ApiFuture<ListDocumentsPagedResponse> createAsync(
PageContext<ListDocumentsRequest, ListDocumentsResponse, DocumentMetadata> context,
ApiFuture<ListDocumentsResponse> futureResponse) {
ApiFuture<ListDocumentsPage> futurePage =
ListDocumentsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListDocumentsPagedResponse(input),
MoreExecutors.directExecutor());
}

private ListDocumentsPagedResponse(ListDocumentsPage page) {
super(page, ListDocumentsFixedSizeCollection.createEmptyCollection());
}
}

public static class ListDocumentsPage
extends AbstractPage<
ListDocumentsRequest, ListDocumentsResponse, DocumentMetadata, ListDocumentsPage> {

private ListDocumentsPage(
PageContext<ListDocumentsRequest, ListDocumentsResponse, DocumentMetadata> context,
ListDocumentsResponse response) {
super(context, response);
}

private static ListDocumentsPage createEmptyPage() {
return new ListDocumentsPage(null, null);
}

@Override
protected ListDocumentsPage createPage(
PageContext<ListDocumentsRequest, ListDocumentsResponse, DocumentMetadata> context,
ListDocumentsResponse response) {
return new ListDocumentsPage(context, response);
}

@Override
public ApiFuture<ListDocumentsPage> createPageAsync(
PageContext<ListDocumentsRequest, ListDocumentsResponse, DocumentMetadata> context,
ApiFuture<ListDocumentsResponse> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}

public static class ListDocumentsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListDocumentsRequest,
ListDocumentsResponse,
DocumentMetadata,
ListDocumentsPage,
ListDocumentsFixedSizeCollection> {

private ListDocumentsFixedSizeCollection(List<ListDocumentsPage> pages, int collectionSize) {
super(pages, collectionSize);
}

private static ListDocumentsFixedSizeCollection createEmptyCollection() {
return new ListDocumentsFixedSizeCollection(null, 0);
}

@Override
protected ListDocumentsFixedSizeCollection createCollection(
List<ListDocumentsPage> pages, int collectionSize) {
return new ListDocumentsFixedSizeCollection(pages, collectionSize);
}
}

public static class ListLocationsPagedResponse
extends AbstractPagedListResponse<
ListLocationsRequest,
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@

package com.google.cloud.documentai.v1beta3;

import static com.google.cloud.documentai.v1beta3.DocumentServiceClient.ListDocumentsPagedResponse;
import static com.google.cloud.documentai.v1beta3.DocumentServiceClient.ListLocationsPagedResponse;

import com.google.api.core.ApiFunction;
@@ -110,6 +111,12 @@ public UnaryCallSettings<GetDocumentRequest, GetDocumentResponse> getDocumentSet
return ((DocumentServiceStubSettings) getStubSettings()).getDocumentSettings();
}

/** Returns the object with the settings used for calls to listDocuments. */
public PagedCallSettings<ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse>
listDocumentsSettings() {
return ((DocumentServiceStubSettings) getStubSettings()).listDocumentsSettings();
}

/** Returns the object with the settings used for calls to batchDeleteDocuments. */
public UnaryCallSettings<BatchDeleteDocumentsRequest, Operation> batchDeleteDocumentsSettings() {
return ((DocumentServiceStubSettings) getStubSettings()).batchDeleteDocumentsSettings();
@@ -290,6 +297,13 @@ public UnaryCallSettings.Builder<ImportDocumentsRequest, Operation> importDocume
return getStubSettingsBuilder().getDocumentSettings();
}

/** Returns the builder for the settings used for calls to listDocuments. */
public PagedCallSettings.Builder<
ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse>
listDocumentsSettings() {
return getStubSettingsBuilder().listDocumentsSettings();
}

/** Returns the builder for the settings used for calls to batchDeleteDocuments. */
public UnaryCallSettings.Builder<BatchDeleteDocumentsRequest, Operation>
batchDeleteDocumentsSettings() {
Original file line number Diff line number Diff line change
@@ -109,6 +109,9 @@
"ImportDocuments": {
"methods": ["importDocumentsAsync", "importDocumentsAsync", "importDocumentsAsync", "importDocumentsOperationCallable", "importDocumentsCallable"]
},
"ListDocuments": {
"methods": ["listDocuments", "listDocuments", "listDocuments", "listDocumentsPagedCallable", "listDocumentsCallable"]
},
"ListLocations": {
"methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"]
},
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@

package com.google.cloud.documentai.v1beta3.stub;

import static com.google.cloud.documentai.v1beta3.DocumentServiceClient.ListDocumentsPagedResponse;
import static com.google.cloud.documentai.v1beta3.DocumentServiceClient.ListLocationsPagedResponse;

import com.google.api.core.BetaApi;
@@ -33,6 +34,8 @@
import com.google.cloud.documentai.v1beta3.ImportDocumentsMetadata;
import com.google.cloud.documentai.v1beta3.ImportDocumentsRequest;
import com.google.cloud.documentai.v1beta3.ImportDocumentsResponse;
import com.google.cloud.documentai.v1beta3.ListDocumentsRequest;
import com.google.cloud.documentai.v1beta3.ListDocumentsResponse;
import com.google.cloud.documentai.v1beta3.UpdateDatasetOperationMetadata;
import com.google.cloud.documentai.v1beta3.UpdateDatasetRequest;
import com.google.cloud.documentai.v1beta3.UpdateDatasetSchemaRequest;
@@ -84,6 +87,15 @@ public UnaryCallable<GetDocumentRequest, GetDocumentResponse> getDocumentCallabl
throw new UnsupportedOperationException("Not implemented: getDocumentCallable()");
}

public UnaryCallable<ListDocumentsRequest, ListDocumentsPagedResponse>
listDocumentsPagedCallable() {
throw new UnsupportedOperationException("Not implemented: listDocumentsPagedCallable()");
}

public UnaryCallable<ListDocumentsRequest, ListDocumentsResponse> listDocumentsCallable() {
throw new UnsupportedOperationException("Not implemented: listDocumentsCallable()");
}

public OperationCallable<
BatchDeleteDocumentsRequest, BatchDeleteDocumentsResponse, BatchDeleteDocumentsMetadata>
batchDeleteDocumentsOperationCallable() {
Loading