From 85e966a9a65aedde5b93173993cd06c94cf629aa Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 8 Feb 2021 16:44:06 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#368) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/89565b2d-2643-4c84-a434-564a46601538/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../language/v1/LanguageServiceClient.java | 255 ++++++++++++++++++ .../cloud/language/v1/package-info.java | 7 + .../v1beta2/LanguageServiceClient.java | 255 ++++++++++++++++++ .../cloud/language/v1beta2/package-info.java | 7 + synth.metadata | 10 +- 5 files changed, 529 insertions(+), 5 deletions(-) diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java index 14205fab..b45fe8a6 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java @@ -33,6 +33,13 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ *   Document document = Document.newBuilder().build();
+ *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+ * }
+ * }
+ * *

Note: close() needs to be called on the LanguageServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -139,6 +146,15 @@ public LanguageServiceStub getStub() { /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+   * }
+   * }
+ * * @param document Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -152,6 +168,17 @@ public final AnalyzeSentimentResponse analyzeSentiment(Document document) { /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeSentimentResponse response =
+   *       languageServiceClient.analyzeSentiment(document, encodingType);
+   * }
+   * }
+ * * @param document Input document. * @param encodingType The encoding type used by the API to calculate sentence offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -170,6 +197,16 @@ public final AnalyzeSentimentResponse analyzeSentiment( /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSentimentRequest request =
+   *       AnalyzeSentimentRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -182,6 +219,17 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r * Analyzes the sentiment of the provided text. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSentimentRequest request =
+   *       AnalyzeSentimentRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeSentimentCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeSentimentResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeSentimentCallable() { @@ -193,6 +241,15 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
+   * }
+   * }
+ * * @param document Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -207,6 +264,17 @@ public final AnalyzeEntitiesResponse analyzeEntities(Document document) { * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeEntitiesResponse response =
+   *       languageServiceClient.analyzeEntities(document, encodingType);
+   * }
+   * }
+ * * @param document Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -226,6 +294,16 @@ public final AnalyzeEntitiesResponse analyzeEntities( * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitiesRequest request =
+   *       AnalyzeEntitiesRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -239,6 +317,17 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ * types, salience, mentions for each entity, and other properties. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitiesRequest request =
+   *       AnalyzeEntitiesRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeEntitiesCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeEntitiesResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeEntitiesCallable() { @@ -251,6 +340,16 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and * analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(document);
+   * }
+   * }
+ * * @param document Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -266,6 +365,17 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document docu * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and * analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(document, encodingType);
+   * }
+   * }
+ * * @param document Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -286,6 +396,19 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and * analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitySentimentRequest request =
+   *       AnalyzeEntitySentimentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .build();
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -301,6 +424,19 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * analyzes sentiment associated with each entity and its mentions. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitySentimentRequest request =
+   *       AnalyzeEntitySentimentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeEntitySentimentCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeEntitySentimentResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeEntitySentimentCallable() { @@ -312,6 +448,15 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part of speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
+   * }
+   * }
+ * * @param document Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -325,6 +470,16 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) { * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part of speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document, encodingType);
+   * }
+   * }
+ * * @param document Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -343,6 +498,16 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part of speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSyntaxRequest request =
+   *       AnalyzeSyntaxRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -356,6 +521,17 @@ public final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest request) { * part of speech tags, dependency trees, and other properties. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSyntaxRequest request =
+   *       AnalyzeSyntaxRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeSyntaxCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeSyntaxResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeSyntaxCallable() { return stub.analyzeSyntaxCallable(); @@ -365,6 +541,15 @@ public final UnaryCallable analyzeS /** * Classifies a document into categories. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   ClassifyTextResponse response = languageServiceClient.classifyText(document);
+   * }
+   * }
+ * * @param document Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -377,6 +562,16 @@ public final ClassifyTextResponse classifyText(Document document) { /** * Classifies a document into categories. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   ClassifyTextRequest request =
+   *       ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ClassifyTextResponse response = languageServiceClient.classifyText(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -389,6 +584,17 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) { * Classifies a document into categories. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   ClassifyTextRequest request =
+   *       ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.classifyTextCallable().futureCall(request);
+   *   // Do something.
+   *   ClassifyTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable classifyTextCallable() { return stub.classifyTextCallable(); @@ -399,6 +605,16 @@ public final UnaryCallable classifyTe * A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and * analyzeSyntax provide in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+   *   AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
+   * }
+   * }
+ * * @param document Input document. * @param features The enabled features. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -415,6 +631,18 @@ public final AnnotateTextResponse annotateText( * A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and * analyzeSyntax provide in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnnotateTextResponse response =
+   *       languageServiceClient.annotateText(document, features, encodingType);
+   * }
+   * }
+ * * @param document Input document. * @param features The enabled features. * @param encodingType The encoding type used by the API to calculate offsets. @@ -436,6 +664,19 @@ public final AnnotateTextResponse annotateText( * A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and * analyzeSyntax provide in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnnotateTextRequest request =
+   *       AnnotateTextRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
+   *           .build();
+   *   AnnotateTextResponse response = languageServiceClient.annotateText(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -449,6 +690,20 @@ public final AnnotateTextResponse annotateText(AnnotateTextRequest request) { * analyzeSyntax provide in one call. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnnotateTextRequest request =
+   *       AnnotateTextRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       languageServiceClient.annotateTextCallable().futureCall(request);
+   *   // Do something.
+   *   AnnotateTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable annotateTextCallable() { return stub.annotateTextCallable(); diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/package-info.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/package-info.java index 7907cd76..12a3ad8b 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/package-info.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/package-info.java @@ -23,6 +23,13 @@ * recognition. * *

Sample for LanguageServiceClient: + * + *

{@code
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ *   Document document = Document.newBuilder().build();
+ *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.language.v1; diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java index 53108798..396b0598 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java @@ -33,6 +33,13 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ *   Document document = Document.newBuilder().build();
+ *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+ * }
+ * }
+ * *

Note: close() needs to be called on the LanguageServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -140,6 +147,15 @@ public LanguageServiceStub getStub() { /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+   * }
+   * }
+ * * @param document Required. Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -153,6 +169,17 @@ public final AnalyzeSentimentResponse analyzeSentiment(Document document) { /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeSentimentResponse response =
+   *       languageServiceClient.analyzeSentiment(document, encodingType);
+   * }
+   * }
+ * * @param document Required. Input document. * @param encodingType The encoding type used by the API to calculate sentence offsets for the * sentence sentiment. @@ -172,6 +199,16 @@ public final AnalyzeSentimentResponse analyzeSentiment( /** * Analyzes the sentiment of the provided text. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSentimentRequest request =
+   *       AnalyzeSentimentRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -184,6 +221,17 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r * Analyzes the sentiment of the provided text. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSentimentRequest request =
+   *       AnalyzeSentimentRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeSentimentCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeSentimentResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeSentimentCallable() { @@ -195,6 +243,15 @@ public final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest r * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(document);
+   * }
+   * }
+ * * @param document Required. Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -209,6 +266,17 @@ public final AnalyzeEntitiesResponse analyzeEntities(Document document) { * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeEntitiesResponse response =
+   *       languageServiceClient.analyzeEntities(document, encodingType);
+   * }
+   * }
+ * * @param document Required. Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -228,6 +296,16 @@ public final AnalyzeEntitiesResponse analyzeEntities( * Finds named entities (currently proper names and common nouns) in the text along with entity * types, salience, mentions for each entity, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitiesRequest request =
+   *       AnalyzeEntitiesRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeEntitiesResponse response = languageServiceClient.analyzeEntities(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -241,6 +319,17 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ * types, salience, mentions for each entity, and other properties. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitiesRequest request =
+   *       AnalyzeEntitiesRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeEntitiesCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeEntitiesResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeEntitiesCallable() { @@ -253,6 +342,16 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text * and analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(document);
+   * }
+   * }
+ * * @param document Required. Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -268,6 +367,17 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment(Document docu * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text * and analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(document, encodingType);
+   * }
+   * }
+ * * @param document Required. Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -288,6 +398,19 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text * and analyzes sentiment associated with each entity and its mentions. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitySentimentRequest request =
+   *       AnalyzeEntitySentimentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .build();
+   *   AnalyzeEntitySentimentResponse response =
+   *       languageServiceClient.analyzeEntitySentiment(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -303,6 +426,19 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * and analyzes sentiment associated with each entity and its mentions. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeEntitySentimentRequest request =
+   *       AnalyzeEntitySentimentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeEntitySentimentCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeEntitySentimentResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeEntitySentimentCallable() { @@ -314,6 +450,15 @@ public final AnalyzeEntitySentimentResponse analyzeEntitySentiment( * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part-of-speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document);
+   * }
+   * }
+ * * @param document Required. Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -327,6 +472,16 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document) { * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part-of-speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(document, encodingType);
+   * }
+   * }
+ * * @param document Required. Input document. * @param encodingType The encoding type used by the API to calculate offsets. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -345,6 +500,16 @@ public final AnalyzeSyntaxResponse analyzeSyntax(Document document, EncodingType * Analyzes the syntax of the text and provides sentence boundaries and tokenization along with * part-of-speech tags, dependency trees, and other properties. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSyntaxRequest request =
+   *       AnalyzeSyntaxRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   AnalyzeSyntaxResponse response = languageServiceClient.analyzeSyntax(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -358,6 +523,17 @@ public final AnalyzeSyntaxResponse analyzeSyntax(AnalyzeSyntaxRequest request) { * part-of-speech tags, dependency trees, and other properties. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnalyzeSyntaxRequest request =
+   *       AnalyzeSyntaxRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.analyzeSyntaxCallable().futureCall(request);
+   *   // Do something.
+   *   AnalyzeSyntaxResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable analyzeSyntaxCallable() { return stub.analyzeSyntaxCallable(); @@ -367,6 +543,15 @@ public final UnaryCallable analyzeS /** * Classifies a document into categories. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   ClassifyTextResponse response = languageServiceClient.classifyText(document);
+   * }
+   * }
+ * * @param document Required. Input document. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -379,6 +564,16 @@ public final ClassifyTextResponse classifyText(Document document) { /** * Classifies a document into categories. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   ClassifyTextRequest request =
+   *       ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ClassifyTextResponse response = languageServiceClient.classifyText(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -391,6 +586,17 @@ public final ClassifyTextResponse classifyText(ClassifyTextRequest request) { * Classifies a document into categories. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   ClassifyTextRequest request =
+   *       ClassifyTextRequest.newBuilder().setDocument(Document.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       languageServiceClient.classifyTextCallable().futureCall(request);
+   *   // Do something.
+   *   ClassifyTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable classifyTextCallable() { return stub.classifyTextCallable(); @@ -401,6 +607,16 @@ public final UnaryCallable classifyTe * A convenience method that provides all syntax, sentiment, entity, and classification features * in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+   *   AnnotateTextResponse response = languageServiceClient.annotateText(document, features);
+   * }
+   * }
+ * * @param document Required. Input document. * @param features Required. The enabled features. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -417,6 +633,18 @@ public final AnnotateTextResponse annotateText( * A convenience method that provides all syntax, sentiment, entity, and classification features * in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
+   *   EncodingType encodingType = EncodingType.forNumber(0);
+   *   AnnotateTextResponse response =
+   *       languageServiceClient.annotateText(document, features, encodingType);
+   * }
+   * }
+ * * @param document Required. Input document. * @param features Required. The enabled features. * @param encodingType The encoding type used by the API to calculate offsets. @@ -438,6 +666,19 @@ public final AnnotateTextResponse annotateText( * A convenience method that provides all syntax, sentiment, entity, and classification features * in one call. * + *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnnotateTextRequest request =
+   *       AnnotateTextRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
+   *           .build();
+   *   AnnotateTextResponse response = languageServiceClient.annotateText(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -451,6 +692,20 @@ public final AnnotateTextResponse annotateText(AnnotateTextRequest request) { * in one call. * *

Sample code: + * + *

{@code
+   * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+   *   AnnotateTextRequest request =
+   *       AnnotateTextRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setFeatures(AnnotateTextRequest.Features.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       languageServiceClient.annotateTextCallable().futureCall(request);
+   *   // Do something.
+   *   AnnotateTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable annotateTextCallable() { return stub.annotateTextCallable(); diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java index f3bfe477..a69c2b98 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/package-info.java @@ -23,6 +23,13 @@ * recognition. * *

Sample for LanguageServiceClient: + * + *

{@code
+ * try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
+ *   Document document = Document.newBuilder().build();
+ *   AnalyzeSentimentResponse response = languageServiceClient.analyzeSentiment(document);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.language.v1beta2; diff --git a/synth.metadata b/synth.metadata index 71ef9859..1d36e9a2 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,23 +4,23 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-language.git", - "sha": "f7aab9f86fa484d7606394bc8782b8bca391492f" + "sha": "3a2521ed980fb50e5707e9c6927d720bd71245c6" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {