• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.vision.v1;
18 
19 import com.google.api.core.BetaApi;
20 import com.google.api.gax.core.BackgroundResource;
21 import com.google.api.gax.httpjson.longrunning.OperationsClient;
22 import com.google.api.gax.longrunning.OperationFuture;
23 import com.google.api.gax.rpc.OperationCallable;
24 import com.google.api.gax.rpc.UnaryCallable;
25 import com.google.cloud.vision.v1.stub.ImageAnnotatorStub;
26 import com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings;
27 import com.google.longrunning.Operation;
28 import java.io.IOException;
29 import java.util.List;
30 import java.util.concurrent.TimeUnit;
31 import javax.annotation.Generated;
32 
33 // AUTO-GENERATED DOCUMENTATION AND CLASS.
34 /**
35  * Service Description: Service that performs Google Cloud Vision API detection tasks over client
36  * images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service
37  * returns detected entities from the images.
38  *
39  * <p>This class provides the ability to make remote calls to the backing service through method
40  * calls that map to API methods. Sample code to get started:
41  *
42  * <pre>{@code
43  * // This snippet has been automatically generated and should be regarded as a code template only.
44  * // It will require modifications to work:
45  * // - It may require correct/in-range values for request initialization.
46  * // - It may require specifying regional endpoints when creating the service client as shown in
47  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
48  * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
49  *   List<AnnotateImageRequest> requests = new ArrayList<>();
50  *   BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests);
51  * }
52  * }</pre>
53  *
54  * <p>Note: close() needs to be called on the ImageAnnotatorClient object to clean up resources such
55  * as threads. In the example above, try-with-resources is used, which automatically calls close().
56  *
57  * <p>The surface of this class includes several types of Java methods for each of the API's
58  * methods:
59  *
60  * <ol>
61  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
62  *       converted into function parameters. It may be the case that not all fields are available as
63  *       parameters, and not every API method will have a flattened method entry point.
64  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
65  *       which must be constructed before the call. Not every API method will have a request object
66  *       method.
67  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
68  *       callable object, which can be used to initiate calls to the service.
69  * </ol>
70  *
71  * <p>See the individual methods for example code.
72  *
73  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
74  * these names, this class includes a format method for each type of name, and additionally a parse
75  * method to extract the individual identifiers contained within names that are returned.
76  *
77  * <p>This class can be customized by passing in a custom instance of ImageAnnotatorSettings to
78  * create(). For example:
79  *
80  * <p>To customize credentials:
81  *
82  * <pre>{@code
83  * // This snippet has been automatically generated and should be regarded as a code template only.
84  * // It will require modifications to work:
85  * // - It may require correct/in-range values for request initialization.
86  * // - It may require specifying regional endpoints when creating the service client as shown in
87  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
88  * ImageAnnotatorSettings imageAnnotatorSettings =
89  *     ImageAnnotatorSettings.newBuilder()
90  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
91  *         .build();
92  * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
93  * }</pre>
94  *
95  * <p>To customize the endpoint:
96  *
97  * <pre>{@code
98  * // This snippet has been automatically generated and should be regarded as a code template only.
99  * // It will require modifications to work:
100  * // - It may require correct/in-range values for request initialization.
101  * // - It may require specifying regional endpoints when creating the service client as shown in
102  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
103  * ImageAnnotatorSettings imageAnnotatorSettings =
104  *     ImageAnnotatorSettings.newBuilder().setEndpoint(myEndpoint).build();
105  * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
106  * }</pre>
107  *
108  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
109  * the wire:
110  *
111  * <pre>{@code
112  * // This snippet has been automatically generated and should be regarded as a code template only.
113  * // It will require modifications to work:
114  * // - It may require correct/in-range values for request initialization.
115  * // - It may require specifying regional endpoints when creating the service client as shown in
116  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
117  * ImageAnnotatorSettings imageAnnotatorSettings =
118  *     ImageAnnotatorSettings.newHttpJsonBuilder().build();
119  * ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create(imageAnnotatorSettings);
120  * }</pre>
121  *
122  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
123  */
124 @Generated("by gapic-generator-java")
125 public class ImageAnnotatorClient implements BackgroundResource {
126   private final ImageAnnotatorSettings settings;
127   private final ImageAnnotatorStub stub;
128   private final OperationsClient httpJsonOperationsClient;
129   private final com.google.longrunning.OperationsClient operationsClient;
130 
131   /** Constructs an instance of ImageAnnotatorClient with default settings. */
create()132   public static final ImageAnnotatorClient create() throws IOException {
133     return create(ImageAnnotatorSettings.newBuilder().build());
134   }
135 
136   /**
137    * Constructs an instance of ImageAnnotatorClient, using the given settings. The channels are
138    * created based on the settings passed in, or defaults for any settings that are not set.
139    */
create(ImageAnnotatorSettings settings)140   public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings)
141       throws IOException {
142     return new ImageAnnotatorClient(settings);
143   }
144 
145   /**
146    * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is
147    * for advanced usage - prefer using create(ImageAnnotatorSettings).
148    */
create(ImageAnnotatorStub stub)149   public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) {
150     return new ImageAnnotatorClient(stub);
151   }
152 
153   /**
154    * Constructs an instance of ImageAnnotatorClient, using the given settings. This is protected so
155    * that it is easy to make a subclass, but otherwise, the static factory methods should be
156    * preferred.
157    */
ImageAnnotatorClient(ImageAnnotatorSettings settings)158   protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException {
159     this.settings = settings;
160     this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub();
161     this.operationsClient =
162         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
163     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
164   }
165 
ImageAnnotatorClient(ImageAnnotatorStub stub)166   protected ImageAnnotatorClient(ImageAnnotatorStub stub) {
167     this.settings = null;
168     this.stub = stub;
169     this.operationsClient =
170         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
171     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
172   }
173 
getSettings()174   public final ImageAnnotatorSettings getSettings() {
175     return settings;
176   }
177 
getStub()178   public ImageAnnotatorStub getStub() {
179     return stub;
180   }
181 
182   /**
183    * Returns the OperationsClient that can be used to query the status of a long-running operation
184    * returned by another API method call.
185    */
getOperationsClient()186   public final com.google.longrunning.OperationsClient getOperationsClient() {
187     return operationsClient;
188   }
189 
190   /**
191    * Returns the OperationsClient that can be used to query the status of a long-running operation
192    * returned by another API method call.
193    */
194   @BetaApi
getHttpJsonOperationsClient()195   public final OperationsClient getHttpJsonOperationsClient() {
196     return httpJsonOperationsClient;
197   }
198 
199   // AUTO-GENERATED DOCUMENTATION AND METHOD.
200   /**
201    * Run image detection and annotation for a batch of images.
202    *
203    * <p>Sample code:
204    *
205    * <pre>{@code
206    * // This snippet has been automatically generated and should be regarded as a code template only.
207    * // It will require modifications to work:
208    * // - It may require correct/in-range values for request initialization.
209    * // - It may require specifying regional endpoints when creating the service client as shown in
210    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
211    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
212    *   List<AnnotateImageRequest> requests = new ArrayList<>();
213    *   BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests);
214    * }
215    * }</pre>
216    *
217    * @param requests Required. Individual image annotation requests for this batch.
218    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
219    */
batchAnnotateImages( List<AnnotateImageRequest> requests)220   public final BatchAnnotateImagesResponse batchAnnotateImages(
221       List<AnnotateImageRequest> requests) {
222     BatchAnnotateImagesRequest request =
223         BatchAnnotateImagesRequest.newBuilder().addAllRequests(requests).build();
224     return batchAnnotateImages(request);
225   }
226 
227   // AUTO-GENERATED DOCUMENTATION AND METHOD.
228   /**
229    * Run image detection and annotation for a batch of images.
230    *
231    * <p>Sample code:
232    *
233    * <pre>{@code
234    * // This snippet has been automatically generated and should be regarded as a code template only.
235    * // It will require modifications to work:
236    * // - It may require correct/in-range values for request initialization.
237    * // - It may require specifying regional endpoints when creating the service client as shown in
238    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
239    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
240    *   BatchAnnotateImagesRequest request =
241    *       BatchAnnotateImagesRequest.newBuilder()
242    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
243    *           .setParent("parent-995424086")
244    *           .build();
245    *   BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(request);
246    * }
247    * }</pre>
248    *
249    * @param request The request object containing all of the parameters for the API call.
250    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
251    */
batchAnnotateImages(BatchAnnotateImagesRequest request)252   public final BatchAnnotateImagesResponse batchAnnotateImages(BatchAnnotateImagesRequest request) {
253     return batchAnnotateImagesCallable().call(request);
254   }
255 
256   // AUTO-GENERATED DOCUMENTATION AND METHOD.
257   /**
258    * Run image detection and annotation for a batch of images.
259    *
260    * <p>Sample code:
261    *
262    * <pre>{@code
263    * // This snippet has been automatically generated and should be regarded as a code template only.
264    * // It will require modifications to work:
265    * // - It may require correct/in-range values for request initialization.
266    * // - It may require specifying regional endpoints when creating the service client as shown in
267    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
268    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
269    *   BatchAnnotateImagesRequest request =
270    *       BatchAnnotateImagesRequest.newBuilder()
271    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
272    *           .setParent("parent-995424086")
273    *           .build();
274    *   ApiFuture<BatchAnnotateImagesResponse> future =
275    *       imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request);
276    *   // Do something.
277    *   BatchAnnotateImagesResponse response = future.get();
278    * }
279    * }</pre>
280    */
281   public final UnaryCallable<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
batchAnnotateImagesCallable()282       batchAnnotateImagesCallable() {
283     return stub.batchAnnotateImagesCallable();
284   }
285 
286   // AUTO-GENERATED DOCUMENTATION AND METHOD.
287   /**
288    * Service that performs image detection and annotation for a batch of files. Now only
289    * "application/pdf", "image/tiff" and "image/gif" are supported.
290    *
291    * <p>This service will extract at most 5 (customers can specify which 5 in
292    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
293    * perform detection and annotation for each image extracted.
294    *
295    * <p>Sample code:
296    *
297    * <pre>{@code
298    * // This snippet has been automatically generated and should be regarded as a code template only.
299    * // It will require modifications to work:
300    * // - It may require correct/in-range values for request initialization.
301    * // - It may require specifying regional endpoints when creating the service client as shown in
302    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
303    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
304    *   List<AnnotateFileRequest> requests = new ArrayList<>();
305    *   BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(requests);
306    * }
307    * }</pre>
308    *
309    * @param requests Required. The list of file annotation requests. Right now we support only one
310    *     AnnotateFileRequest in BatchAnnotateFilesRequest.
311    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
312    */
batchAnnotateFiles(List<AnnotateFileRequest> requests)313   public final BatchAnnotateFilesResponse batchAnnotateFiles(List<AnnotateFileRequest> requests) {
314     BatchAnnotateFilesRequest request =
315         BatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
316     return batchAnnotateFiles(request);
317   }
318 
319   // AUTO-GENERATED DOCUMENTATION AND METHOD.
320   /**
321    * Service that performs image detection and annotation for a batch of files. Now only
322    * "application/pdf", "image/tiff" and "image/gif" are supported.
323    *
324    * <p>This service will extract at most 5 (customers can specify which 5 in
325    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
326    * perform detection and annotation for each image extracted.
327    *
328    * <p>Sample code:
329    *
330    * <pre>{@code
331    * // This snippet has been automatically generated and should be regarded as a code template only.
332    * // It will require modifications to work:
333    * // - It may require correct/in-range values for request initialization.
334    * // - It may require specifying regional endpoints when creating the service client as shown in
335    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
336    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
337    *   BatchAnnotateFilesRequest request =
338    *       BatchAnnotateFilesRequest.newBuilder()
339    *           .addAllRequests(new ArrayList<AnnotateFileRequest>())
340    *           .setParent("parent-995424086")
341    *           .build();
342    *   BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(request);
343    * }
344    * }</pre>
345    *
346    * @param request The request object containing all of the parameters for the API call.
347    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
348    */
batchAnnotateFiles(BatchAnnotateFilesRequest request)349   public final BatchAnnotateFilesResponse batchAnnotateFiles(BatchAnnotateFilesRequest request) {
350     return batchAnnotateFilesCallable().call(request);
351   }
352 
353   // AUTO-GENERATED DOCUMENTATION AND METHOD.
354   /**
355    * Service that performs image detection and annotation for a batch of files. Now only
356    * "application/pdf", "image/tiff" and "image/gif" are supported.
357    *
358    * <p>This service will extract at most 5 (customers can specify which 5 in
359    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
360    * perform detection and annotation for each image extracted.
361    *
362    * <p>Sample code:
363    *
364    * <pre>{@code
365    * // This snippet has been automatically generated and should be regarded as a code template only.
366    * // It will require modifications to work:
367    * // - It may require correct/in-range values for request initialization.
368    * // - It may require specifying regional endpoints when creating the service client as shown in
369    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
370    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
371    *   BatchAnnotateFilesRequest request =
372    *       BatchAnnotateFilesRequest.newBuilder()
373    *           .addAllRequests(new ArrayList<AnnotateFileRequest>())
374    *           .setParent("parent-995424086")
375    *           .build();
376    *   ApiFuture<BatchAnnotateFilesResponse> future =
377    *       imageAnnotatorClient.batchAnnotateFilesCallable().futureCall(request);
378    *   // Do something.
379    *   BatchAnnotateFilesResponse response = future.get();
380    * }
381    * }</pre>
382    */
383   public final UnaryCallable<BatchAnnotateFilesRequest, BatchAnnotateFilesResponse>
batchAnnotateFilesCallable()384       batchAnnotateFilesCallable() {
385     return stub.batchAnnotateFilesCallable();
386   }
387 
388   // AUTO-GENERATED DOCUMENTATION AND METHOD.
389   /**
390    * Run asynchronous image detection and annotation for a list of images.
391    *
392    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
393    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
394    * `AsyncBatchAnnotateImagesResponse` (results).
395    *
396    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
397    * json file containing BatchAnnotateImagesResponse proto.
398    *
399    * <p>Sample code:
400    *
401    * <pre>{@code
402    * // This snippet has been automatically generated and should be regarded as a code template only.
403    * // It will require modifications to work:
404    * // - It may require correct/in-range values for request initialization.
405    * // - It may require specifying regional endpoints when creating the service client as shown in
406    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
407    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
408    *   List<AnnotateImageRequest> requests = new ArrayList<>();
409    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
410    *   AsyncBatchAnnotateImagesResponse response =
411    *       imageAnnotatorClient.asyncBatchAnnotateImagesAsync(requests, outputConfig).get();
412    * }
413    * }</pre>
414    *
415    * @param requests Required. Individual image annotation requests for this batch.
416    * @param outputConfig Required. The desired output location and metadata (e.g. format).
417    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
418    */
419   public final OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesAsync( List<AnnotateImageRequest> requests, OutputConfig outputConfig)420       asyncBatchAnnotateImagesAsync(
421           List<AnnotateImageRequest> requests, OutputConfig outputConfig) {
422     AsyncBatchAnnotateImagesRequest request =
423         AsyncBatchAnnotateImagesRequest.newBuilder()
424             .addAllRequests(requests)
425             .setOutputConfig(outputConfig)
426             .build();
427     return asyncBatchAnnotateImagesAsync(request);
428   }
429 
430   // AUTO-GENERATED DOCUMENTATION AND METHOD.
431   /**
432    * Run asynchronous image detection and annotation for a list of images.
433    *
434    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
435    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
436    * `AsyncBatchAnnotateImagesResponse` (results).
437    *
438    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
439    * json file containing BatchAnnotateImagesResponse proto.
440    *
441    * <p>Sample code:
442    *
443    * <pre>{@code
444    * // This snippet has been automatically generated and should be regarded as a code template only.
445    * // It will require modifications to work:
446    * // - It may require correct/in-range values for request initialization.
447    * // - It may require specifying regional endpoints when creating the service client as shown in
448    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
449    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
450    *   AsyncBatchAnnotateImagesRequest request =
451    *       AsyncBatchAnnotateImagesRequest.newBuilder()
452    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
453    *           .setOutputConfig(OutputConfig.newBuilder().build())
454    *           .setParent("parent-995424086")
455    *           .build();
456    *   AsyncBatchAnnotateImagesResponse response =
457    *       imageAnnotatorClient.asyncBatchAnnotateImagesAsync(request).get();
458    * }
459    * }</pre>
460    *
461    * @param request The request object containing all of the parameters for the API call.
462    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
463    */
464   public final OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesAsync(AsyncBatchAnnotateImagesRequest request)465       asyncBatchAnnotateImagesAsync(AsyncBatchAnnotateImagesRequest request) {
466     return asyncBatchAnnotateImagesOperationCallable().futureCall(request);
467   }
468 
469   // AUTO-GENERATED DOCUMENTATION AND METHOD.
470   /**
471    * Run asynchronous image detection and annotation for a list of images.
472    *
473    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
474    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
475    * `AsyncBatchAnnotateImagesResponse` (results).
476    *
477    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
478    * json file containing BatchAnnotateImagesResponse proto.
479    *
480    * <p>Sample code:
481    *
482    * <pre>{@code
483    * // This snippet has been automatically generated and should be regarded as a code template only.
484    * // It will require modifications to work:
485    * // - It may require correct/in-range values for request initialization.
486    * // - It may require specifying regional endpoints when creating the service client as shown in
487    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
488    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
489    *   AsyncBatchAnnotateImagesRequest request =
490    *       AsyncBatchAnnotateImagesRequest.newBuilder()
491    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
492    *           .setOutputConfig(OutputConfig.newBuilder().build())
493    *           .setParent("parent-995424086")
494    *           .build();
495    *   OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata> future =
496    *       imageAnnotatorClient.asyncBatchAnnotateImagesOperationCallable().futureCall(request);
497    *   // Do something.
498    *   AsyncBatchAnnotateImagesResponse response = future.get();
499    * }
500    * }</pre>
501    */
502   public final OperationCallable<
503           AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesOperationCallable()504       asyncBatchAnnotateImagesOperationCallable() {
505     return stub.asyncBatchAnnotateImagesOperationCallable();
506   }
507 
508   // AUTO-GENERATED DOCUMENTATION AND METHOD.
509   /**
510    * Run asynchronous image detection and annotation for a list of images.
511    *
512    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
513    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
514    * `AsyncBatchAnnotateImagesResponse` (results).
515    *
516    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
517    * json file containing BatchAnnotateImagesResponse proto.
518    *
519    * <p>Sample code:
520    *
521    * <pre>{@code
522    * // This snippet has been automatically generated and should be regarded as a code template only.
523    * // It will require modifications to work:
524    * // - It may require correct/in-range values for request initialization.
525    * // - It may require specifying regional endpoints when creating the service client as shown in
526    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
527    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
528    *   AsyncBatchAnnotateImagesRequest request =
529    *       AsyncBatchAnnotateImagesRequest.newBuilder()
530    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
531    *           .setOutputConfig(OutputConfig.newBuilder().build())
532    *           .setParent("parent-995424086")
533    *           .build();
534    *   ApiFuture<Operation> future =
535    *       imageAnnotatorClient.asyncBatchAnnotateImagesCallable().futureCall(request);
536    *   // Do something.
537    *   Operation response = future.get();
538    * }
539    * }</pre>
540    */
541   public final UnaryCallable<AsyncBatchAnnotateImagesRequest, Operation>
asyncBatchAnnotateImagesCallable()542       asyncBatchAnnotateImagesCallable() {
543     return stub.asyncBatchAnnotateImagesCallable();
544   }
545 
546   // AUTO-GENERATED DOCUMENTATION AND METHOD.
547   /**
548    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
549    * which may contain multiple pages and multiple images per page. Progress and results can be
550    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
551    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
552    * (results).
553    *
554    * <p>Sample code:
555    *
556    * <pre>{@code
557    * // This snippet has been automatically generated and should be regarded as a code template only.
558    * // It will require modifications to work:
559    * // - It may require correct/in-range values for request initialization.
560    * // - It may require specifying regional endpoints when creating the service client as shown in
561    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
562    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
563    *   List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
564    *   AsyncBatchAnnotateFilesResponse response =
565    *       imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get();
566    * }
567    * }</pre>
568    *
569    * @param requests Required. Individual async file annotation requests for this batch.
570    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
571    */
572   public final OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesAsync(List<AsyncAnnotateFileRequest> requests)573       asyncBatchAnnotateFilesAsync(List<AsyncAnnotateFileRequest> requests) {
574     AsyncBatchAnnotateFilesRequest request =
575         AsyncBatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
576     return asyncBatchAnnotateFilesAsync(request);
577   }
578 
579   // AUTO-GENERATED DOCUMENTATION AND METHOD.
580   /**
581    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
582    * which may contain multiple pages and multiple images per page. Progress and results can be
583    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
584    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
585    * (results).
586    *
587    * <p>Sample code:
588    *
589    * <pre>{@code
590    * // This snippet has been automatically generated and should be regarded as a code template only.
591    * // It will require modifications to work:
592    * // - It may require correct/in-range values for request initialization.
593    * // - It may require specifying regional endpoints when creating the service client as shown in
594    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
595    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
596    *   AsyncBatchAnnotateFilesRequest request =
597    *       AsyncBatchAnnotateFilesRequest.newBuilder()
598    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
599    *           .setParent("parent-995424086")
600    *           .build();
601    *   AsyncBatchAnnotateFilesResponse response =
602    *       imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get();
603    * }
604    * }</pre>
605    *
606    * @param request The request object containing all of the parameters for the API call.
607    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
608    */
609   public final OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesAsync(AsyncBatchAnnotateFilesRequest request)610       asyncBatchAnnotateFilesAsync(AsyncBatchAnnotateFilesRequest request) {
611     return asyncBatchAnnotateFilesOperationCallable().futureCall(request);
612   }
613 
614   // AUTO-GENERATED DOCUMENTATION AND METHOD.
615   /**
616    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
617    * which may contain multiple pages and multiple images per page. Progress and results can be
618    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
619    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
620    * (results).
621    *
622    * <p>Sample code:
623    *
624    * <pre>{@code
625    * // This snippet has been automatically generated and should be regarded as a code template only.
626    * // It will require modifications to work:
627    * // - It may require correct/in-range values for request initialization.
628    * // - It may require specifying regional endpoints when creating the service client as shown in
629    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
630    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
631    *   AsyncBatchAnnotateFilesRequest request =
632    *       AsyncBatchAnnotateFilesRequest.newBuilder()
633    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
634    *           .setParent("parent-995424086")
635    *           .build();
636    *   OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata> future =
637    *       imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request);
638    *   // Do something.
639    *   AsyncBatchAnnotateFilesResponse response = future.get();
640    * }
641    * }</pre>
642    */
643   public final OperationCallable<
644           AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesOperationCallable()645       asyncBatchAnnotateFilesOperationCallable() {
646     return stub.asyncBatchAnnotateFilesOperationCallable();
647   }
648 
649   // AUTO-GENERATED DOCUMENTATION AND METHOD.
650   /**
651    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
652    * which may contain multiple pages and multiple images per page. Progress and results can be
653    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
654    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
655    * (results).
656    *
657    * <p>Sample code:
658    *
659    * <pre>{@code
660    * // This snippet has been automatically generated and should be regarded as a code template only.
661    * // It will require modifications to work:
662    * // - It may require correct/in-range values for request initialization.
663    * // - It may require specifying regional endpoints when creating the service client as shown in
664    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
665    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
666    *   AsyncBatchAnnotateFilesRequest request =
667    *       AsyncBatchAnnotateFilesRequest.newBuilder()
668    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
669    *           .setParent("parent-995424086")
670    *           .build();
671    *   ApiFuture<Operation> future =
672    *       imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request);
673    *   // Do something.
674    *   Operation response = future.get();
675    * }
676    * }</pre>
677    */
678   public final UnaryCallable<AsyncBatchAnnotateFilesRequest, Operation>
asyncBatchAnnotateFilesCallable()679       asyncBatchAnnotateFilesCallable() {
680     return stub.asyncBatchAnnotateFilesCallable();
681   }
682 
683   @Override
close()684   public final void close() {
685     stub.close();
686   }
687 
688   @Override
shutdown()689   public void shutdown() {
690     stub.shutdown();
691   }
692 
693   @Override
isShutdown()694   public boolean isShutdown() {
695     return stub.isShutdown();
696   }
697 
698   @Override
isTerminated()699   public boolean isTerminated() {
700     return stub.isTerminated();
701   }
702 
703   @Override
shutdownNow()704   public void shutdownNow() {
705     stub.shutdownNow();
706   }
707 
708   @Override
awaitTermination(long duration, TimeUnit unit)709   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
710     return stub.awaitTermination(duration, unit);
711   }
712 }
713