• 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.v1p4beta1;
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.v1p4beta1.stub.ImageAnnotatorStub;
26 import com.google.cloud.vision.v1p4beta1.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 @BetaApi
125 @Generated("by gapic-generator-java")
126 public class ImageAnnotatorClient implements BackgroundResource {
127   private final ImageAnnotatorSettings settings;
128   private final ImageAnnotatorStub stub;
129   private final OperationsClient httpJsonOperationsClient;
130   private final com.google.longrunning.OperationsClient operationsClient;
131 
132   /** Constructs an instance of ImageAnnotatorClient with default settings. */
create()133   public static final ImageAnnotatorClient create() throws IOException {
134     return create(ImageAnnotatorSettings.newBuilder().build());
135   }
136 
137   /**
138    * Constructs an instance of ImageAnnotatorClient, using the given settings. The channels are
139    * created based on the settings passed in, or defaults for any settings that are not set.
140    */
create(ImageAnnotatorSettings settings)141   public static final ImageAnnotatorClient create(ImageAnnotatorSettings settings)
142       throws IOException {
143     return new ImageAnnotatorClient(settings);
144   }
145 
146   /**
147    * Constructs an instance of ImageAnnotatorClient, using the given stub for making calls. This is
148    * for advanced usage - prefer using create(ImageAnnotatorSettings).
149    */
create(ImageAnnotatorStub stub)150   public static final ImageAnnotatorClient create(ImageAnnotatorStub stub) {
151     return new ImageAnnotatorClient(stub);
152   }
153 
154   /**
155    * Constructs an instance of ImageAnnotatorClient, using the given settings. This is protected so
156    * that it is easy to make a subclass, but otherwise, the static factory methods should be
157    * preferred.
158    */
ImageAnnotatorClient(ImageAnnotatorSettings settings)159   protected ImageAnnotatorClient(ImageAnnotatorSettings settings) throws IOException {
160     this.settings = settings;
161     this.stub = ((ImageAnnotatorStubSettings) settings.getStubSettings()).createStub();
162     this.operationsClient =
163         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
164     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
165   }
166 
ImageAnnotatorClient(ImageAnnotatorStub stub)167   protected ImageAnnotatorClient(ImageAnnotatorStub stub) {
168     this.settings = null;
169     this.stub = stub;
170     this.operationsClient =
171         com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
172     this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
173   }
174 
getSettings()175   public final ImageAnnotatorSettings getSettings() {
176     return settings;
177   }
178 
getStub()179   public ImageAnnotatorStub getStub() {
180     return stub;
181   }
182 
183   /**
184    * Returns the OperationsClient that can be used to query the status of a long-running operation
185    * returned by another API method call.
186    */
getOperationsClient()187   public final com.google.longrunning.OperationsClient getOperationsClient() {
188     return operationsClient;
189   }
190 
191   /**
192    * Returns the OperationsClient that can be used to query the status of a long-running operation
193    * returned by another API method call.
194    */
195   @BetaApi
getHttpJsonOperationsClient()196   public final OperationsClient getHttpJsonOperationsClient() {
197     return httpJsonOperationsClient;
198   }
199 
200   // AUTO-GENERATED DOCUMENTATION AND METHOD.
201   /**
202    * Run image detection and annotation for a batch of images.
203    *
204    * <p>Sample code:
205    *
206    * <pre>{@code
207    * // This snippet has been automatically generated and should be regarded as a code template only.
208    * // It will require modifications to work:
209    * // - It may require correct/in-range values for request initialization.
210    * // - It may require specifying regional endpoints when creating the service client as shown in
211    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
212    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
213    *   List<AnnotateImageRequest> requests = new ArrayList<>();
214    *   BatchAnnotateImagesResponse response = imageAnnotatorClient.batchAnnotateImages(requests);
215    * }
216    * }</pre>
217    *
218    * @param requests Required. Individual image annotation requests for this batch.
219    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
220    */
batchAnnotateImages( List<AnnotateImageRequest> requests)221   public final BatchAnnotateImagesResponse batchAnnotateImages(
222       List<AnnotateImageRequest> requests) {
223     BatchAnnotateImagesRequest request =
224         BatchAnnotateImagesRequest.newBuilder().addAllRequests(requests).build();
225     return batchAnnotateImages(request);
226   }
227 
228   // AUTO-GENERATED DOCUMENTATION AND METHOD.
229   /**
230    * Run image detection and annotation for a batch of images.
231    *
232    * <p>Sample code:
233    *
234    * <pre>{@code
235    * // This snippet has been automatically generated and should be regarded as a code template only.
236    * // It will require modifications to work:
237    * // - It may require correct/in-range values for request initialization.
238    * // - It may require specifying regional endpoints when creating the service client as shown in
239    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
240    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
241    *   BatchAnnotateImagesRequest request =
242    *       BatchAnnotateImagesRequest.newBuilder()
243    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
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    *           .build();
273    *   ApiFuture<BatchAnnotateImagesResponse> future =
274    *       imageAnnotatorClient.batchAnnotateImagesCallable().futureCall(request);
275    *   // Do something.
276    *   BatchAnnotateImagesResponse response = future.get();
277    * }
278    * }</pre>
279    */
280   public final UnaryCallable<BatchAnnotateImagesRequest, BatchAnnotateImagesResponse>
batchAnnotateImagesCallable()281       batchAnnotateImagesCallable() {
282     return stub.batchAnnotateImagesCallable();
283   }
284 
285   // AUTO-GENERATED DOCUMENTATION AND METHOD.
286   /**
287    * Service that performs image detection and annotation for a batch of files. Now only
288    * "application/pdf", "image/tiff" and "image/gif" are supported.
289    *
290    * <p>This service will extract at most 5 (customers can specify which 5 in
291    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
292    * perform detection and annotation for each image extracted.
293    *
294    * <p>Sample code:
295    *
296    * <pre>{@code
297    * // This snippet has been automatically generated and should be regarded as a code template only.
298    * // It will require modifications to work:
299    * // - It may require correct/in-range values for request initialization.
300    * // - It may require specifying regional endpoints when creating the service client as shown in
301    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
302    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
303    *   List<AnnotateFileRequest> requests = new ArrayList<>();
304    *   BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(requests);
305    * }
306    * }</pre>
307    *
308    * @param requests Required. The list of file annotation requests. Right now we support only one
309    *     AnnotateFileRequest in BatchAnnotateFilesRequest.
310    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
311    */
batchAnnotateFiles(List<AnnotateFileRequest> requests)312   public final BatchAnnotateFilesResponse batchAnnotateFiles(List<AnnotateFileRequest> requests) {
313     BatchAnnotateFilesRequest request =
314         BatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
315     return batchAnnotateFiles(request);
316   }
317 
318   // AUTO-GENERATED DOCUMENTATION AND METHOD.
319   /**
320    * Service that performs image detection and annotation for a batch of files. Now only
321    * "application/pdf", "image/tiff" and "image/gif" are supported.
322    *
323    * <p>This service will extract at most 5 (customers can specify which 5 in
324    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
325    * perform detection and annotation for each image extracted.
326    *
327    * <p>Sample code:
328    *
329    * <pre>{@code
330    * // This snippet has been automatically generated and should be regarded as a code template only.
331    * // It will require modifications to work:
332    * // - It may require correct/in-range values for request initialization.
333    * // - It may require specifying regional endpoints when creating the service client as shown in
334    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
335    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
336    *   BatchAnnotateFilesRequest request =
337    *       BatchAnnotateFilesRequest.newBuilder()
338    *           .addAllRequests(new ArrayList<AnnotateFileRequest>())
339    *           .build();
340    *   BatchAnnotateFilesResponse response = imageAnnotatorClient.batchAnnotateFiles(request);
341    * }
342    * }</pre>
343    *
344    * @param request The request object containing all of the parameters for the API call.
345    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
346    */
batchAnnotateFiles(BatchAnnotateFilesRequest request)347   public final BatchAnnotateFilesResponse batchAnnotateFiles(BatchAnnotateFilesRequest request) {
348     return batchAnnotateFilesCallable().call(request);
349   }
350 
351   // AUTO-GENERATED DOCUMENTATION AND METHOD.
352   /**
353    * Service that performs image detection and annotation for a batch of files. Now only
354    * "application/pdf", "image/tiff" and "image/gif" are supported.
355    *
356    * <p>This service will extract at most 5 (customers can specify which 5 in
357    * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and
358    * perform detection and annotation for each image extracted.
359    *
360    * <p>Sample code:
361    *
362    * <pre>{@code
363    * // This snippet has been automatically generated and should be regarded as a code template only.
364    * // It will require modifications to work:
365    * // - It may require correct/in-range values for request initialization.
366    * // - It may require specifying regional endpoints when creating the service client as shown in
367    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
368    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
369    *   BatchAnnotateFilesRequest request =
370    *       BatchAnnotateFilesRequest.newBuilder()
371    *           .addAllRequests(new ArrayList<AnnotateFileRequest>())
372    *           .build();
373    *   ApiFuture<BatchAnnotateFilesResponse> future =
374    *       imageAnnotatorClient.batchAnnotateFilesCallable().futureCall(request);
375    *   // Do something.
376    *   BatchAnnotateFilesResponse response = future.get();
377    * }
378    * }</pre>
379    */
380   public final UnaryCallable<BatchAnnotateFilesRequest, BatchAnnotateFilesResponse>
batchAnnotateFilesCallable()381       batchAnnotateFilesCallable() {
382     return stub.batchAnnotateFilesCallable();
383   }
384 
385   // AUTO-GENERATED DOCUMENTATION AND METHOD.
386   /**
387    * Run asynchronous image detection and annotation for a list of images.
388    *
389    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
390    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
391    * `AsyncBatchAnnotateImagesResponse` (results).
392    *
393    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
394    * json file containing BatchAnnotateImagesResponse proto.
395    *
396    * <p>Sample code:
397    *
398    * <pre>{@code
399    * // This snippet has been automatically generated and should be regarded as a code template only.
400    * // It will require modifications to work:
401    * // - It may require correct/in-range values for request initialization.
402    * // - It may require specifying regional endpoints when creating the service client as shown in
403    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
404    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
405    *   List<AnnotateImageRequest> requests = new ArrayList<>();
406    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
407    *   AsyncBatchAnnotateImagesResponse response =
408    *       imageAnnotatorClient.asyncBatchAnnotateImagesAsync(requests, outputConfig).get();
409    * }
410    * }</pre>
411    *
412    * @param requests Required. Individual image annotation requests for this batch.
413    * @param outputConfig Required. The desired output location and metadata (e.g. format).
414    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
415    */
416   public final OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesAsync( List<AnnotateImageRequest> requests, OutputConfig outputConfig)417       asyncBatchAnnotateImagesAsync(
418           List<AnnotateImageRequest> requests, OutputConfig outputConfig) {
419     AsyncBatchAnnotateImagesRequest request =
420         AsyncBatchAnnotateImagesRequest.newBuilder()
421             .addAllRequests(requests)
422             .setOutputConfig(outputConfig)
423             .build();
424     return asyncBatchAnnotateImagesAsync(request);
425   }
426 
427   // AUTO-GENERATED DOCUMENTATION AND METHOD.
428   /**
429    * Run asynchronous image detection and annotation for a list of images.
430    *
431    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
432    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
433    * `AsyncBatchAnnotateImagesResponse` (results).
434    *
435    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
436    * json file containing BatchAnnotateImagesResponse proto.
437    *
438    * <p>Sample code:
439    *
440    * <pre>{@code
441    * // This snippet has been automatically generated and should be regarded as a code template only.
442    * // It will require modifications to work:
443    * // - It may require correct/in-range values for request initialization.
444    * // - It may require specifying regional endpoints when creating the service client as shown in
445    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
446    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
447    *   AsyncBatchAnnotateImagesRequest request =
448    *       AsyncBatchAnnotateImagesRequest.newBuilder()
449    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
450    *           .setOutputConfig(OutputConfig.newBuilder().build())
451    *           .build();
452    *   AsyncBatchAnnotateImagesResponse response =
453    *       imageAnnotatorClient.asyncBatchAnnotateImagesAsync(request).get();
454    * }
455    * }</pre>
456    *
457    * @param request The request object containing all of the parameters for the API call.
458    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
459    */
460   public final OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesAsync(AsyncBatchAnnotateImagesRequest request)461       asyncBatchAnnotateImagesAsync(AsyncBatchAnnotateImagesRequest request) {
462     return asyncBatchAnnotateImagesOperationCallable().futureCall(request);
463   }
464 
465   // AUTO-GENERATED DOCUMENTATION AND METHOD.
466   /**
467    * Run asynchronous image detection and annotation for a list of images.
468    *
469    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
470    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
471    * `AsyncBatchAnnotateImagesResponse` (results).
472    *
473    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
474    * json file containing BatchAnnotateImagesResponse proto.
475    *
476    * <p>Sample code:
477    *
478    * <pre>{@code
479    * // This snippet has been automatically generated and should be regarded as a code template only.
480    * // It will require modifications to work:
481    * // - It may require correct/in-range values for request initialization.
482    * // - It may require specifying regional endpoints when creating the service client as shown in
483    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
484    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
485    *   AsyncBatchAnnotateImagesRequest request =
486    *       AsyncBatchAnnotateImagesRequest.newBuilder()
487    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
488    *           .setOutputConfig(OutputConfig.newBuilder().build())
489    *           .build();
490    *   OperationFuture<AsyncBatchAnnotateImagesResponse, OperationMetadata> future =
491    *       imageAnnotatorClient.asyncBatchAnnotateImagesOperationCallable().futureCall(request);
492    *   // Do something.
493    *   AsyncBatchAnnotateImagesResponse response = future.get();
494    * }
495    * }</pre>
496    */
497   public final OperationCallable<
498           AsyncBatchAnnotateImagesRequest, AsyncBatchAnnotateImagesResponse, OperationMetadata>
asyncBatchAnnotateImagesOperationCallable()499       asyncBatchAnnotateImagesOperationCallable() {
500     return stub.asyncBatchAnnotateImagesOperationCallable();
501   }
502 
503   // AUTO-GENERATED DOCUMENTATION AND METHOD.
504   /**
505    * Run asynchronous image detection and annotation for a list of images.
506    *
507    * <p>Progress and results can be retrieved through the `google.longrunning.Operations` interface.
508    * `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains
509    * `AsyncBatchAnnotateImagesResponse` (results).
510    *
511    * <p>This service will write image annotation outputs to json files in customer GCS bucket, each
512    * json file containing BatchAnnotateImagesResponse proto.
513    *
514    * <p>Sample code:
515    *
516    * <pre>{@code
517    * // This snippet has been automatically generated and should be regarded as a code template only.
518    * // It will require modifications to work:
519    * // - It may require correct/in-range values for request initialization.
520    * // - It may require specifying regional endpoints when creating the service client as shown in
521    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
522    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
523    *   AsyncBatchAnnotateImagesRequest request =
524    *       AsyncBatchAnnotateImagesRequest.newBuilder()
525    *           .addAllRequests(new ArrayList<AnnotateImageRequest>())
526    *           .setOutputConfig(OutputConfig.newBuilder().build())
527    *           .build();
528    *   ApiFuture<Operation> future =
529    *       imageAnnotatorClient.asyncBatchAnnotateImagesCallable().futureCall(request);
530    *   // Do something.
531    *   Operation response = future.get();
532    * }
533    * }</pre>
534    */
535   public final UnaryCallable<AsyncBatchAnnotateImagesRequest, Operation>
asyncBatchAnnotateImagesCallable()536       asyncBatchAnnotateImagesCallable() {
537     return stub.asyncBatchAnnotateImagesCallable();
538   }
539 
540   // AUTO-GENERATED DOCUMENTATION AND METHOD.
541   /**
542    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
543    * which may contain multiple pages and multiple images per page. Progress and results can be
544    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
545    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
546    * (results).
547    *
548    * <p>Sample code:
549    *
550    * <pre>{@code
551    * // This snippet has been automatically generated and should be regarded as a code template only.
552    * // It will require modifications to work:
553    * // - It may require correct/in-range values for request initialization.
554    * // - It may require specifying regional endpoints when creating the service client as shown in
555    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
556    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
557    *   List<AsyncAnnotateFileRequest> requests = new ArrayList<>();
558    *   AsyncBatchAnnotateFilesResponse response =
559    *       imageAnnotatorClient.asyncBatchAnnotateFilesAsync(requests).get();
560    * }
561    * }</pre>
562    *
563    * @param requests Required. Individual async file annotation requests for this batch.
564    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
565    */
566   public final OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesAsync(List<AsyncAnnotateFileRequest> requests)567       asyncBatchAnnotateFilesAsync(List<AsyncAnnotateFileRequest> requests) {
568     AsyncBatchAnnotateFilesRequest request =
569         AsyncBatchAnnotateFilesRequest.newBuilder().addAllRequests(requests).build();
570     return asyncBatchAnnotateFilesAsync(request);
571   }
572 
573   // AUTO-GENERATED DOCUMENTATION AND METHOD.
574   /**
575    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
576    * which may contain multiple pages and multiple images per page. Progress and results can be
577    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
578    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
579    * (results).
580    *
581    * <p>Sample code:
582    *
583    * <pre>{@code
584    * // This snippet has been automatically generated and should be regarded as a code template only.
585    * // It will require modifications to work:
586    * // - It may require correct/in-range values for request initialization.
587    * // - It may require specifying regional endpoints when creating the service client as shown in
588    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
589    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
590    *   AsyncBatchAnnotateFilesRequest request =
591    *       AsyncBatchAnnotateFilesRequest.newBuilder()
592    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
593    *           .build();
594    *   AsyncBatchAnnotateFilesResponse response =
595    *       imageAnnotatorClient.asyncBatchAnnotateFilesAsync(request).get();
596    * }
597    * }</pre>
598    *
599    * @param request The request object containing all of the parameters for the API call.
600    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
601    */
602   public final OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesAsync(AsyncBatchAnnotateFilesRequest request)603       asyncBatchAnnotateFilesAsync(AsyncBatchAnnotateFilesRequest request) {
604     return asyncBatchAnnotateFilesOperationCallable().futureCall(request);
605   }
606 
607   // AUTO-GENERATED DOCUMENTATION AND METHOD.
608   /**
609    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
610    * which may contain multiple pages and multiple images per page. Progress and results can be
611    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
612    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
613    * (results).
614    *
615    * <p>Sample code:
616    *
617    * <pre>{@code
618    * // This snippet has been automatically generated and should be regarded as a code template only.
619    * // It will require modifications to work:
620    * // - It may require correct/in-range values for request initialization.
621    * // - It may require specifying regional endpoints when creating the service client as shown in
622    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
623    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
624    *   AsyncBatchAnnotateFilesRequest request =
625    *       AsyncBatchAnnotateFilesRequest.newBuilder()
626    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
627    *           .build();
628    *   OperationFuture<AsyncBatchAnnotateFilesResponse, OperationMetadata> future =
629    *       imageAnnotatorClient.asyncBatchAnnotateFilesOperationCallable().futureCall(request);
630    *   // Do something.
631    *   AsyncBatchAnnotateFilesResponse response = future.get();
632    * }
633    * }</pre>
634    */
635   public final OperationCallable<
636           AsyncBatchAnnotateFilesRequest, AsyncBatchAnnotateFilesResponse, OperationMetadata>
asyncBatchAnnotateFilesOperationCallable()637       asyncBatchAnnotateFilesOperationCallable() {
638     return stub.asyncBatchAnnotateFilesOperationCallable();
639   }
640 
641   // AUTO-GENERATED DOCUMENTATION AND METHOD.
642   /**
643    * Run asynchronous image detection and annotation for a list of generic files, such as PDF files,
644    * which may contain multiple pages and multiple images per page. Progress and results can be
645    * retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains
646    * `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse`
647    * (results).
648    *
649    * <p>Sample code:
650    *
651    * <pre>{@code
652    * // This snippet has been automatically generated and should be regarded as a code template only.
653    * // It will require modifications to work:
654    * // - It may require correct/in-range values for request initialization.
655    * // - It may require specifying regional endpoints when creating the service client as shown in
656    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
657    * try (ImageAnnotatorClient imageAnnotatorClient = ImageAnnotatorClient.create()) {
658    *   AsyncBatchAnnotateFilesRequest request =
659    *       AsyncBatchAnnotateFilesRequest.newBuilder()
660    *           .addAllRequests(new ArrayList<AsyncAnnotateFileRequest>())
661    *           .build();
662    *   ApiFuture<Operation> future =
663    *       imageAnnotatorClient.asyncBatchAnnotateFilesCallable().futureCall(request);
664    *   // Do something.
665    *   Operation response = future.get();
666    * }
667    * }</pre>
668    */
669   public final UnaryCallable<AsyncBatchAnnotateFilesRequest, Operation>
asyncBatchAnnotateFilesCallable()670       asyncBatchAnnotateFilesCallable() {
671     return stub.asyncBatchAnnotateFilesCallable();
672   }
673 
674   @Override
close()675   public final void close() {
676     stub.close();
677   }
678 
679   @Override
shutdown()680   public void shutdown() {
681     stub.shutdown();
682   }
683 
684   @Override
isShutdown()685   public boolean isShutdown() {
686     return stub.isShutdown();
687   }
688 
689   @Override
isTerminated()690   public boolean isTerminated() {
691     return stub.isTerminated();
692   }
693 
694   @Override
shutdownNow()695   public void shutdownNow() {
696     stub.shutdownNow();
697   }
698 
699   @Override
awaitTermination(long duration, TimeUnit unit)700   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
701     return stub.awaitTermination(duration, unit);
702   }
703 }
704