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