• 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.language.v1beta2;
18 
19 import com.google.api.core.BetaApi;
20 import com.google.api.gax.core.BackgroundResource;
21 import com.google.api.gax.rpc.UnaryCallable;
22 import com.google.cloud.language.v1beta2.stub.LanguageServiceStub;
23 import com.google.cloud.language.v1beta2.stub.LanguageServiceStubSettings;
24 import java.io.IOException;
25 import java.util.concurrent.TimeUnit;
26 import javax.annotation.Generated;
27 
28 // AUTO-GENERATED DOCUMENTATION AND CLASS.
29 /**
30  * Service Description: Provides text analysis operations such as sentiment analysis and entity
31  * recognition.
32  *
33  * <p>This class provides the ability to make remote calls to the backing service through method
34  * calls that map to API methods. Sample code to get started:
35  *
36  * <pre>{@code
37  * // This snippet has been automatically generated and should be regarded as a code template only.
38  * // It will require modifications to work:
39  * // - It may require correct/in-range values for request initialization.
40  * // - It may require specifying regional endpoints when creating the service client as shown in
41  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
42  * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
43  *   Document document = Document.newBuilder().build();
44  *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
45  * }
46  * }</pre>
47  *
48  * <p>Note: close() needs to be called on the LanguageServiceClient object to clean up resources
49  * such as threads. In the example above, try-with-resources is used, which automatically calls
50  * close().
51  *
52  * <p>The surface of this class includes several types of Java methods for each of the API's
53  * methods:
54  *
55  * <ol>
56  *   <li>A "flattened" method. With this type of method, the fields of the request type have been
57  *       converted into function parameters. It may be the case that not all fields are available as
58  *       parameters, and not every API method will have a flattened method entry point.
59  *   <li>A "request object" method. This type of method only takes one parameter, a request object,
60  *       which must be constructed before the call. Not every API method will have a request object
61  *       method.
62  *   <li>A "callable" method. This type of method takes no parameters and returns an immutable API
63  *       callable object, which can be used to initiate calls to the service.
64  * </ol>
65  *
66  * <p>See the individual methods for example code.
67  *
68  * <p>Many parameters require resource names to be formatted in a particular way. To assist with
69  * these names, this class includes a format method for each type of name, and additionally a parse
70  * method to extract the individual identifiers contained within names that are returned.
71  *
72  * <p>This class can be customized by passing in a custom instance of LanguageServiceSettings to
73  * create(). For example:
74  *
75  * <p>To customize credentials:
76  *
77  * <pre>{@code
78  * // This snippet has been automatically generated and should be regarded as a code template only.
79  * // It will require modifications to work:
80  * // - It may require correct/in-range values for request initialization.
81  * // - It may require specifying regional endpoints when creating the service client as shown in
82  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
83  * LanguageServiceSettings languageServiceSettings =
84  *     LanguageServiceSettings.newBuilder()
85  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
86  *         .build();
87  * LanguageServiceClient languageServiceClient =
88  *     LanguageServiceClient.create(languageServiceSettings);
89  * }</pre>
90  *
91  * <p>To customize the endpoint:
92  *
93  * <pre>{@code
94  * // This snippet has been automatically generated and should be regarded as a code template only.
95  * // It will require modifications to work:
96  * // - It may require correct/in-range values for request initialization.
97  * // - It may require specifying regional endpoints when creating the service client as shown in
98  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
99  * LanguageServiceSettings languageServiceSettings =
100  *     LanguageServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
101  * LanguageServiceClient languageServiceClient =
102  *     LanguageServiceClient.create(languageServiceSettings);
103  * }</pre>
104  *
105  * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
106  * the wire:
107  *
108  * <pre>{@code
109  * // This snippet has been automatically generated and should be regarded as a code template only.
110  * // It will require modifications to work:
111  * // - It may require correct/in-range values for request initialization.
112  * // - It may require specifying regional endpoints when creating the service client as shown in
113  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
114  * LanguageServiceSettings languageServiceSettings =
115  *     LanguageServiceSettings.newHttpJsonBuilder().build();
116  * LanguageServiceClient languageServiceClient =
117  *     LanguageServiceClient.create(languageServiceSettings);
118  * }</pre>
119  *
120  * <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
121  */
122 @BetaApi
123 @Generated("by gapic-generator-java")
124 public class LanguageServiceClient implements BackgroundResource {
125   private final LanguageServiceSettings settings;
126   private final LanguageServiceStub stub;
127 
128   /** Constructs an instance of LanguageServiceClient with default settings. */
create()129   public static final LanguageServiceClient create() throws IOException {
130     return create(LanguageServiceSettings.newBuilder().build());
131   }
132 
133   /**
134    * Constructs an instance of LanguageServiceClient, using the given settings. The channels are
135    * created based on the settings passed in, or defaults for any settings that are not set.
136    */
create(LanguageServiceSettings settings)137   public static final LanguageServiceClient create(LanguageServiceSettings settings)
138       throws IOException {
139     return new LanguageServiceClient(settings);
140   }
141 
142   /**
143    * Constructs an instance of LanguageServiceClient, using the given stub for making calls. This is
144    * for advanced usage - prefer using create(LanguageServiceSettings).
145    */
create(LanguageServiceStub stub)146   public static final LanguageServiceClient create(LanguageServiceStub stub) {
147     return new LanguageServiceClient(stub);
148   }
149 
150   /**
151    * Constructs an instance of LanguageServiceClient, using the given settings. This is protected so
152    * that it is easy to make a subclass, but otherwise, the static factory methods should be
153    * preferred.
154    */
LanguageServiceClient(LanguageServiceSettings settings)155   protected LanguageServiceClient(LanguageServiceSettings settings) throws IOException {
156     this.settings = settings;
157     this.stub = ((LanguageServiceStubSettings) settings.getStubSettings()).createStub();
158   }
159 
LanguageServiceClient(LanguageServiceStub stub)160   protected LanguageServiceClient(LanguageServiceStub stub) {
161     this.settings = null;
162     this.stub = stub;
163   }
164 
getSettings()165   public final LanguageServiceSettings getSettings() {
166     return settings;
167   }
168 
getStub()169   public LanguageServiceStub getStub() {
170     return stub;
171   }
172 
173   // AUTO-GENERATED DOCUMENTATION AND METHOD.
174   /**
175    * Analyzes the sentiment of the provided text.
176    *
177    * <p>Sample code:
178    *
179    * <pre>{@code
180    * // This snippet has been automatically generated and should be regarded as a code template only.
181    * // It will require modifications to work:
182    * // - It may require correct/in-range values for request initialization.
183    * // - It may require specifying regional endpoints when creating the service client as shown in
184    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
185    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
186    *   Document document = Document.newBuilder().build();
187    *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
188    * }
189    * }</pre>
190    *
191    * @param document Required. Input document.
192    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
193    */
analyzeSentiment(Document document)194   public final AnalyzeSentimentResponse analyzeSentiment(Document document) {
195     AnalyzeSentimentRequest request =
196         AnalyzeSentimentRequest.newBuilder().setDocument(document).build();
197     return analyzeSentiment(request);
198   }
199 
200   // AUTO-GENERATED DOCUMENTATION AND METHOD.
201   /**
202    * Analyzes the sentiment of the provided text.
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 (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
213    *   Document document = Document.newBuilder().build();
214    *   EncodingType encodingType = EncodingType.forNumber(0);
215    *   AnalyzeSentimentResponse response =
216    *       languageServiceClient.analyzeSentiment(document, encodingType);
217    * }
218    * }</pre>
219    *
220    * @param document Required. Input document.
221    * @param encodingType The encoding type used by the API to calculate sentence offsets for the
222    *     sentence sentiment.
223    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
224    */
analyzeSentiment( Document document, EncodingType encodingType)225   public final AnalyzeSentimentResponse analyzeSentiment(
226       Document document, EncodingType encodingType) {
227     AnalyzeSentimentRequest request =
228         AnalyzeSentimentRequest.newBuilder()
229             .setDocument(document)
230             .setEncodingType(encodingType)
231             .build();
232     return analyzeSentiment(request);
233   }
234 
235   // AUTO-GENERATED DOCUMENTATION AND METHOD.
236   /**
237    * Analyzes the sentiment of the provided text.
238    *
239    * <p>Sample code:
240    *
241    * <pre>{@code
242    * // This snippet has been automatically generated and should be regarded as a code template only.
243    * // It will require modifications to work:
244    * // - It may require correct/in-range values for request initialization.
245    * // - It may require specifying regional endpoints when creating the service client as shown in
246    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
247    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
248    *   AnalyzeSentimentRequest request =
249    *       AnalyzeSentimentRequest.newBuilder()
250    *           .setDocument(Document.newBuilder().build())
251    *           .setEncodingType(EncodingType.forNumber(0))
252    *           .build();
253    *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(request);
254    * }
255    * }</pre>
256    *
257    * @param request The request object containing all of the parameters for the API call.
258    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
259    */
analyzeSentiment(AnalyzeSentimentRequest request)260   public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest request) {
261     return analyzeSentimentCallable().call(request);
262   }
263 
264   // AUTO-GENERATED DOCUMENTATION AND METHOD.
265   /**
266    * Analyzes the sentiment of the provided text.
267    *
268    * <p>Sample code:
269    *
270    * <pre>{@code
271    * // This snippet has been automatically generated and should be regarded as a code template only.
272    * // It will require modifications to work:
273    * // - It may require correct/in-range values for request initialization.
274    * // - It may require specifying regional endpoints when creating the service client as shown in
275    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
276    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
277    *   AnalyzeSentimentRequest request =
278    *       AnalyzeSentimentRequest.newBuilder()
279    *           .setDocument(Document.newBuilder().build())
280    *           .setEncodingType(EncodingType.forNumber(0))
281    *           .build();
282    *   ApiFuture<AnalyzeSentimentResponse> future =
283    *       languageServiceClient.analyzeSentimentCallable().futureCall(request);
284    *   // Do something.
285    *   AnalyzeSentimentResponse response = future.get();
286    * }
287    * }</pre>
288    */
289   public final UnaryCallable<AnalyzeSentimentRequest, AnalyzeSentimentResponse>
analyzeSentimentCallable()290       analyzeSentimentCallable() {
291     return stub.analyzeSentimentCallable();
292   }
293 
294   // AUTO-GENERATED DOCUMENTATION AND METHOD.
295   /**
296    * Finds named entities (currently proper names and common nouns) in the text along with entity
297    * types, salience, mentions for each entity, and other properties.
298    *
299    * <p>Sample code:
300    *
301    * <pre>{@code
302    * // This snippet has been automatically generated and should be regarded as a code template only.
303    * // It will require modifications to work:
304    * // - It may require correct/in-range values for request initialization.
305    * // - It may require specifying regional endpoints when creating the service client as shown in
306    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
307    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
308    *   Document document = Document.newBuilder().build();
309    *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
310    * }
311    * }</pre>
312    *
313    * @param document Required. Input document.
314    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
315    */
analyzeEntities(Document document)316   public final AnalyzeEntitiesResponse analyzeEntities(Document document) {
317     AnalyzeEntitiesRequest request =
318         AnalyzeEntitiesRequest.newBuilder().setDocument(document).build();
319     return analyzeEntities(request);
320   }
321 
322   // AUTO-GENERATED DOCUMENTATION AND METHOD.
323   /**
324    * Finds named entities (currently proper names and common nouns) in the text along with entity
325    * types, salience, mentions for each entity, and other properties.
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 (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
336    *   Document document = Document.newBuilder().build();
337    *   EncodingType encodingType = EncodingType.forNumber(0);
338    *   AnalyzeEntitiesResponse response =
339    *       languageServiceClient.analyzeEntities(document, encodingType);
340    * }
341    * }</pre>
342    *
343    * @param document Required. Input document.
344    * @param encodingType The encoding type used by the API to calculate offsets.
345    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
346    */
analyzeEntities( Document document, EncodingType encodingType)347   public final AnalyzeEntitiesResponse analyzeEntities(
348       Document document, EncodingType encodingType) {
349     AnalyzeEntitiesRequest request =
350         AnalyzeEntitiesRequest.newBuilder()
351             .setDocument(document)
352             .setEncodingType(encodingType)
353             .build();
354     return analyzeEntities(request);
355   }
356 
357   // AUTO-GENERATED DOCUMENTATION AND METHOD.
358   /**
359    * Finds named entities (currently proper names and common nouns) in the text along with entity
360    * types, salience, mentions for each entity, and other properties.
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 (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
371    *   AnalyzeEntitiesRequest request =
372    *       AnalyzeEntitiesRequest.newBuilder()
373    *           .setDocument(Document.newBuilder().build())
374    *           .setEncodingType(EncodingType.forNumber(0))
375    *           .build();
376    *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(request);
377    * }
378    * }</pre>
379    *
380    * @param request The request object containing all of the parameters for the API call.
381    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
382    */
analyzeEntities(AnalyzeEntitiesRequest request)383   public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest request) {
384     return analyzeEntitiesCallable().call(request);
385   }
386 
387   // AUTO-GENERATED DOCUMENTATION AND METHOD.
388   /**
389    * Finds named entities (currently proper names and common nouns) in the text along with entity
390    * types, salience, mentions for each entity, and other properties.
391    *
392    * <p>Sample code:
393    *
394    * <pre>{@code
395    * // This snippet has been automatically generated and should be regarded as a code template only.
396    * // It will require modifications to work:
397    * // - It may require correct/in-range values for request initialization.
398    * // - It may require specifying regional endpoints when creating the service client as shown in
399    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
400    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
401    *   AnalyzeEntitiesRequest request =
402    *       AnalyzeEntitiesRequest.newBuilder()
403    *           .setDocument(Document.newBuilder().build())
404    *           .setEncodingType(EncodingType.forNumber(0))
405    *           .build();
406    *   ApiFuture<AnalyzeEntitiesResponse> future =
407    *       languageServiceClient.analyzeEntitiesCallable().futureCall(request);
408    *   // Do something.
409    *   AnalyzeEntitiesResponse response = future.get();
410    * }
411    * }</pre>
412    */
413   public final UnaryCallable<AnalyzeEntitiesRequest, AnalyzeEntitiesResponse>
analyzeEntitiesCallable()414       analyzeEntitiesCallable() {
415     return stub.analyzeEntitiesCallable();
416   }
417 
418   // AUTO-GENERATED DOCUMENTATION AND METHOD.
419   /**
420    * Finds entities, similar to
421    * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
422    * and analyzes sentiment associated with each entity and its mentions.
423    *
424    * <p>Sample code:
425    *
426    * <pre>{@code
427    * // This snippet has been automatically generated and should be regarded as a code template only.
428    * // It will require modifications to work:
429    * // - It may require correct/in-range values for request initialization.
430    * // - It may require specifying regional endpoints when creating the service client as shown in
431    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
432    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
433    *   Document document = Document.newBuilder().build();
434    *   AnalyzeEntitySentimentResponse response =
435    *       languageServiceClient.analyzeEntitySentiment(document);
436    * }
437    * }</pre>
438    *
439    * @param document Required. Input document.
440    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
441    */
analyzeEntitySentiment(Document document)442   public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document document) {
443     AnalyzeEntitySentimentRequest request =
444         AnalyzeEntitySentimentRequest.newBuilder().setDocument(document).build();
445     return analyzeEntitySentiment(request);
446   }
447 
448   // AUTO-GENERATED DOCUMENTATION AND METHOD.
449   /**
450    * Finds entities, similar to
451    * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
452    * and analyzes sentiment associated with each entity and its mentions.
453    *
454    * <p>Sample code:
455    *
456    * <pre>{@code
457    * // This snippet has been automatically generated and should be regarded as a code template only.
458    * // It will require modifications to work:
459    * // - It may require correct/in-range values for request initialization.
460    * // - It may require specifying regional endpoints when creating the service client as shown in
461    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
462    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
463    *   Document document = Document.newBuilder().build();
464    *   EncodingType encodingType = EncodingType.forNumber(0);
465    *   AnalyzeEntitySentimentResponse response =
466    *       languageServiceClient.analyzeEntitySentiment(document, encodingType);
467    * }
468    * }</pre>
469    *
470    * @param document Required. Input document.
471    * @param encodingType The encoding type used by the API to calculate offsets.
472    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
473    */
analyzeEntitySentiment( Document document, EncodingType encodingType)474   public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
475       Document document, EncodingType encodingType) {
476     AnalyzeEntitySentimentRequest request =
477         AnalyzeEntitySentimentRequest.newBuilder()
478             .setDocument(document)
479             .setEncodingType(encodingType)
480             .build();
481     return analyzeEntitySentiment(request);
482   }
483 
484   // AUTO-GENERATED DOCUMENTATION AND METHOD.
485   /**
486    * Finds entities, similar to
487    * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
488    * and analyzes sentiment associated with each entity and its mentions.
489    *
490    * <p>Sample code:
491    *
492    * <pre>{@code
493    * // This snippet has been automatically generated and should be regarded as a code template only.
494    * // It will require modifications to work:
495    * // - It may require correct/in-range values for request initialization.
496    * // - It may require specifying regional endpoints when creating the service client as shown in
497    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
498    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
499    *   AnalyzeEntitySentimentRequest request =
500    *       AnalyzeEntitySentimentRequest.newBuilder()
501    *           .setDocument(Document.newBuilder().build())
502    *           .setEncodingType(EncodingType.forNumber(0))
503    *           .build();
504    *   AnalyzeEntitySentimentResponse response =
505    *       languageServiceClient.analyzeEntitySentiment(request);
506    * }
507    * }</pre>
508    *
509    * @param request The request object containing all of the parameters for the API call.
510    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
511    */
analyzeEntitySentiment( AnalyzeEntitySentimentRequest request)512   public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(
513       AnalyzeEntitySentimentRequest request) {
514     return analyzeEntitySentimentCallable().call(request);
515   }
516 
517   // AUTO-GENERATED DOCUMENTATION AND METHOD.
518   /**
519    * Finds entities, similar to
520    * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text
521    * and analyzes sentiment associated with each entity and its mentions.
522    *
523    * <p>Sample code:
524    *
525    * <pre>{@code
526    * // This snippet has been automatically generated and should be regarded as a code template only.
527    * // It will require modifications to work:
528    * // - It may require correct/in-range values for request initialization.
529    * // - It may require specifying regional endpoints when creating the service client as shown in
530    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
531    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
532    *   AnalyzeEntitySentimentRequest request =
533    *       AnalyzeEntitySentimentRequest.newBuilder()
534    *           .setDocument(Document.newBuilder().build())
535    *           .setEncodingType(EncodingType.forNumber(0))
536    *           .build();
537    *   ApiFuture<AnalyzeEntitySentimentResponse> future =
538    *       languageServiceClient.analyzeEntitySentimentCallable().futureCall(request);
539    *   // Do something.
540    *   AnalyzeEntitySentimentResponse response = future.get();
541    * }
542    * }</pre>
543    */
544   public final UnaryCallable<AnalyzeEntitySentimentRequest, AnalyzeEntitySentimentResponse>
analyzeEntitySentimentCallable()545       analyzeEntitySentimentCallable() {
546     return stub.analyzeEntitySentimentCallable();
547   }
548 
549   // AUTO-GENERATED DOCUMENTATION AND METHOD.
550   /**
551    * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
552    * part of speech tags, dependency trees, and other properties.
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 (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
563    *   Document document = Document.newBuilder().build();
564    *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
565    * }
566    * }</pre>
567    *
568    * @param document Required. Input document.
569    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
570    */
analyzeSyntax(Document document)571   public final AnalyzeSyntaxResponse analyzeSyntax(Document document) {
572     AnalyzeSyntaxRequest request = AnalyzeSyntaxRequest.newBuilder().setDocument(document).build();
573     return analyzeSyntax(request);
574   }
575 
576   // AUTO-GENERATED DOCUMENTATION AND METHOD.
577   /**
578    * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
579    * part of speech tags, dependency trees, and other properties.
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 (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
590    *   Document document = Document.newBuilder().build();
591    *   EncodingType encodingType = EncodingType.forNumber(0);
592    *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document, encodingType);
593    * }
594    * }</pre>
595    *
596    * @param document Required. Input document.
597    * @param encodingType The encoding type used by the API to calculate offsets.
598    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
599    */
analyzeSyntax(Document document, EncodingType encodingType)600   public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType encodingType) {
601     AnalyzeSyntaxRequest request =
602         AnalyzeSyntaxRequest.newBuilder()
603             .setDocument(document)
604             .setEncodingType(encodingType)
605             .build();
606     return analyzeSyntax(request);
607   }
608 
609   // AUTO-GENERATED DOCUMENTATION AND METHOD.
610   /**
611    * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
612    * part of speech tags, dependency trees, and other properties.
613    *
614    * <p>Sample code:
615    *
616    * <pre>{@code
617    * // This snippet has been automatically generated and should be regarded as a code template only.
618    * // It will require modifications to work:
619    * // - It may require correct/in-range values for request initialization.
620    * // - It may require specifying regional endpoints when creating the service client as shown in
621    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
622    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
623    *   AnalyzeSyntaxRequest request =
624    *       AnalyzeSyntaxRequest.newBuilder()
625    *           .setDocument(Document.newBuilder().build())
626    *           .setEncodingType(EncodingType.forNumber(0))
627    *           .build();
628    *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(request);
629    * }
630    * }</pre>
631    *
632    * @param request The request object containing all of the parameters for the API call.
633    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
634    */
analyzeSyntax(AnalyzeSyntaxRequest request)635   public final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest request) {
636     return analyzeSyntaxCallable().call(request);
637   }
638 
639   // AUTO-GENERATED DOCUMENTATION AND METHOD.
640   /**
641    * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with
642    * part of speech tags, dependency trees, and other properties.
643    *
644    * <p>Sample code:
645    *
646    * <pre>{@code
647    * // This snippet has been automatically generated and should be regarded as a code template only.
648    * // It will require modifications to work:
649    * // - It may require correct/in-range values for request initialization.
650    * // - It may require specifying regional endpoints when creating the service client as shown in
651    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
652    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
653    *   AnalyzeSyntaxRequest request =
654    *       AnalyzeSyntaxRequest.newBuilder()
655    *           .setDocument(Document.newBuilder().build())
656    *           .setEncodingType(EncodingType.forNumber(0))
657    *           .build();
658    *   ApiFuture<AnalyzeSyntaxResponse> future =
659    *       languageServiceClient.analyzeSyntaxCallable().futureCall(request);
660    *   // Do something.
661    *   AnalyzeSyntaxResponse response = future.get();
662    * }
663    * }</pre>
664    */
analyzeSyntaxCallable()665   public final UnaryCallable<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse> analyzeSyntaxCallable() {
666     return stub.analyzeSyntaxCallable();
667   }
668 
669   // AUTO-GENERATED DOCUMENTATION AND METHOD.
670   /**
671    * Classifies a document into categories.
672    *
673    * <p>Sample code:
674    *
675    * <pre>{@code
676    * // This snippet has been automatically generated and should be regarded as a code template only.
677    * // It will require modifications to work:
678    * // - It may require correct/in-range values for request initialization.
679    * // - It may require specifying regional endpoints when creating the service client as shown in
680    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
681    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
682    *   Document document = Document.newBuilder().build();
683    *   ClassifyTextResponse response = languageServiceClient.classifyText(document);
684    * }
685    * }</pre>
686    *
687    * @param document Required. Input document.
688    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
689    */
classifyText(Document document)690   public final ClassifyTextResponse classifyText(Document document) {
691     ClassifyTextRequest request = ClassifyTextRequest.newBuilder().setDocument(document).build();
692     return classifyText(request);
693   }
694 
695   // AUTO-GENERATED DOCUMENTATION AND METHOD.
696   /**
697    * Classifies a document into categories.
698    *
699    * <p>Sample code:
700    *
701    * <pre>{@code
702    * // This snippet has been automatically generated and should be regarded as a code template only.
703    * // It will require modifications to work:
704    * // - It may require correct/in-range values for request initialization.
705    * // - It may require specifying regional endpoints when creating the service client as shown in
706    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
707    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
708    *   ClassifyTextRequest request =
709    *       ClassifyTextRequest.newBuilder()
710    *           .setDocument(Document.newBuilder().build())
711    *           .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
712    *           .build();
713    *   ClassifyTextResponse response = languageServiceClient.classifyText(request);
714    * }
715    * }</pre>
716    *
717    * @param request The request object containing all of the parameters for the API call.
718    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
719    */
classifyText(ClassifyTextRequest request)720   public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
721     return classifyTextCallable().call(request);
722   }
723 
724   // AUTO-GENERATED DOCUMENTATION AND METHOD.
725   /**
726    * Classifies a document into categories.
727    *
728    * <p>Sample code:
729    *
730    * <pre>{@code
731    * // This snippet has been automatically generated and should be regarded as a code template only.
732    * // It will require modifications to work:
733    * // - It may require correct/in-range values for request initialization.
734    * // - It may require specifying regional endpoints when creating the service client as shown in
735    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
736    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
737    *   ClassifyTextRequest request =
738    *       ClassifyTextRequest.newBuilder()
739    *           .setDocument(Document.newBuilder().build())
740    *           .setClassificationModelOptions(ClassificationModelOptions.newBuilder().build())
741    *           .build();
742    *   ApiFuture<ClassifyTextResponse> future =
743    *       languageServiceClient.classifyTextCallable().futureCall(request);
744    *   // Do something.
745    *   ClassifyTextResponse response = future.get();
746    * }
747    * }</pre>
748    */
classifyTextCallable()749   public final UnaryCallable<ClassifyTextRequest, ClassifyTextResponse> classifyTextCallable() {
750     return stub.classifyTextCallable();
751   }
752 
753   // AUTO-GENERATED DOCUMENTATION AND METHOD.
754   /**
755    * A convenience method that provides all syntax, sentiment, entity, and classification features
756    * in one call.
757    *
758    * <p>Sample code:
759    *
760    * <pre>{@code
761    * // This snippet has been automatically generated and should be regarded as a code template only.
762    * // It will require modifications to work:
763    * // - It may require correct/in-range values for request initialization.
764    * // - It may require specifying regional endpoints when creating the service client as shown in
765    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
766    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
767    *   Document document = Document.newBuilder().build();
768    *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
769    *   AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
770    * }
771    * }</pre>
772    *
773    * @param document Required. Input document.
774    * @param features Required. The enabled features.
775    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
776    */
annotateText( Document document, AnnotateTextRequest.Features features)777   public final AnnotateTextResponse annotateText(
778       Document document, AnnotateTextRequest.Features features) {
779     AnnotateTextRequest request =
780         AnnotateTextRequest.newBuilder().setDocument(document).setFeatures(features).build();
781     return annotateText(request);
782   }
783 
784   // AUTO-GENERATED DOCUMENTATION AND METHOD.
785   /**
786    * A convenience method that provides all syntax, sentiment, entity, and classification features
787    * in one call.
788    *
789    * <p>Sample code:
790    *
791    * <pre>{@code
792    * // This snippet has been automatically generated and should be regarded as a code template only.
793    * // It will require modifications to work:
794    * // - It may require correct/in-range values for request initialization.
795    * // - It may require specifying regional endpoints when creating the service client as shown in
796    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
797    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
798    *   Document document = Document.newBuilder().build();
799    *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
800    *   EncodingType encodingType = EncodingType.forNumber(0);
801    *   AnnotateTextResponse response =
802    *       languageServiceClient.annotateText(document, features, encodingType);
803    * }
804    * }</pre>
805    *
806    * @param document Required. Input document.
807    * @param features Required. The enabled features.
808    * @param encodingType The encoding type used by the API to calculate offsets.
809    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
810    */
annotateText( Document document, AnnotateTextRequest.Features features, EncodingType encodingType)811   public final AnnotateTextResponse annotateText(
812       Document document, AnnotateTextRequest.Features features, EncodingType encodingType) {
813     AnnotateTextRequest request =
814         AnnotateTextRequest.newBuilder()
815             .setDocument(document)
816             .setFeatures(features)
817             .setEncodingType(encodingType)
818             .build();
819     return annotateText(request);
820   }
821 
822   // AUTO-GENERATED DOCUMENTATION AND METHOD.
823   /**
824    * A convenience method that provides all syntax, sentiment, entity, and classification features
825    * in one call.
826    *
827    * <p>Sample code:
828    *
829    * <pre>{@code
830    * // This snippet has been automatically generated and should be regarded as a code template only.
831    * // It will require modifications to work:
832    * // - It may require correct/in-range values for request initialization.
833    * // - It may require specifying regional endpoints when creating the service client as shown in
834    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
835    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
836    *   AnnotateTextRequest request =
837    *       AnnotateTextRequest.newBuilder()
838    *           .setDocument(Document.newBuilder().build())
839    *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
840    *           .setEncodingType(EncodingType.forNumber(0))
841    *           .build();
842    *   AnnotateTextResponse response = languageServiceClient.annotateText(request);
843    * }
844    * }</pre>
845    *
846    * @param request The request object containing all of the parameters for the API call.
847    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
848    */
annotateText(AnnotateTextRequest request)849   public final AnnotateTextResponse annotateText(AnnotateTextRequest request) {
850     return annotateTextCallable().call(request);
851   }
852 
853   // AUTO-GENERATED DOCUMENTATION AND METHOD.
854   /**
855    * A convenience method that provides all syntax, sentiment, entity, and classification features
856    * in one call.
857    *
858    * <p>Sample code:
859    *
860    * <pre>{@code
861    * // This snippet has been automatically generated and should be regarded as a code template only.
862    * // It will require modifications to work:
863    * // - It may require correct/in-range values for request initialization.
864    * // - It may require specifying regional endpoints when creating the service client as shown in
865    * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
866    * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
867    *   AnnotateTextRequest request =
868    *       AnnotateTextRequest.newBuilder()
869    *           .setDocument(Document.newBuilder().build())
870    *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
871    *           .setEncodingType(EncodingType.forNumber(0))
872    *           .build();
873    *   ApiFuture<AnnotateTextResponse> future =
874    *       languageServiceClient.annotateTextCallable().futureCall(request);
875    *   // Do something.
876    *   AnnotateTextResponse response = future.get();
877    * }
878    * }</pre>
879    */
annotateTextCallable()880   public final UnaryCallable<AnnotateTextRequest, AnnotateTextResponse> annotateTextCallable() {
881     return stub.annotateTextCallable();
882   }
883 
884   @Override
close()885   public final void close() {
886     stub.close();
887   }
888 
889   @Override
shutdown()890   public void shutdown() {
891     stub.shutdown();
892   }
893 
894   @Override
isShutdown()895   public boolean isShutdown() {
896     return stub.isShutdown();
897   }
898 
899   @Override
isTerminated()900   public boolean isTerminated() {
901     return stub.isTerminated();
902   }
903 
904   @Override
shutdownNow()905   public void shutdownNow() {
906     stub.shutdownNow();
907   }
908 
909   @Override
awaitTermination(long duration, TimeUnit unit)910   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
911     return stub.awaitTermination(duration, unit);
912   }
913 }
914