From 8c422152567b5b974d5824fe6cefaec64fcbce24 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 9 Feb 2021 10:20:03 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#413) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/b5715173-fa09-4f29-8c69-530ae787b970/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../v3/TranslationServiceClient.java | 510 ++++++++++++++++++ .../cloud/translate/v3/package-info.java | 10 + .../v3beta1/TranslationServiceClient.java | 485 +++++++++++++++++ .../cloud/translate/v3beta1/package-info.java | 17 + synth.metadata | 10 +- 5 files changed, 1027 insertions(+), 5 deletions(-) diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java index bafc06bd..f839da97 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java @@ -45,6 +45,16 @@ *

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 (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   String targetLanguageCode = "targetLanguageCode-106414698";
+ *   List contents = new ArrayList<>();
+ *   TranslateTextResponse response =
+ *       translationServiceClient.translateText(parent, targetLanguageCode, contents);
+ * }
+ * }
+ * *

Note: close() needs to be called on the TranslationServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -162,6 +172,18 @@ public final OperationsClient getOperationsClient() { /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String targetLanguageCode = "targetLanguageCode-106414698";
+   *   List contents = new ArrayList<>();
+   *   TranslateTextResponse response =
+   *       translationServiceClient.translateText(parent, targetLanguageCode, contents);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -191,6 +213,18 @@ public final TranslateTextResponse translateText( /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String targetLanguageCode = "targetLanguageCode-106414698";
+   *   List contents = new ArrayList<>();
+   *   TranslateTextResponse response =
+   *       translationServiceClient.translateText(parent, targetLanguageCode, contents);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -220,6 +254,22 @@ public final TranslateTextResponse translateText( /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   String sourceLanguageCode = "sourceLanguageCode1645917472";
+   *   String targetLanguageCode = "targetLanguageCode-106414698";
+   *   List contents = new ArrayList<>();
+   *   TranslateTextResponse response =
+   *       translationServiceClient.translateText(
+   *           parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -273,6 +323,22 @@ public final TranslateTextResponse translateText( /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   String sourceLanguageCode = "sourceLanguageCode1645917472";
+   *   String targetLanguageCode = "targetLanguageCode-106414698";
+   *   List contents = new ArrayList<>();
+   *   TranslateTextResponse response =
+   *       translationServiceClient.translateText(
+   *           parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -326,6 +392,25 @@ public final TranslateTextResponse translateText( /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   TranslateTextRequest request =
+   *       TranslateTextRequest.newBuilder()
+   *           .addAllContents(new ArrayList())
+   *           .setMimeType("mimeType-1392120434")
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .setTargetLanguageCode("targetLanguageCode-106414698")
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   TranslateTextResponse response = translationServiceClient.translateText(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 */ @@ -338,6 +423,26 @@ public final TranslateTextResponse translateText(TranslateTextRequest request) { * Translates input text and returns translated text. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   TranslateTextRequest request =
+   *       TranslateTextRequest.newBuilder()
+   *           .addAllContents(new ArrayList())
+   *           .setMimeType("mimeType-1392120434")
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .setTargetLanguageCode("targetLanguageCode-106414698")
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.translateTextCallable().futureCall(request);
+   *   // Do something.
+   *   TranslateTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable translateTextCallable() { return stub.translateTextCallable(); @@ -347,6 +452,19 @@ public final UnaryCallable translat /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   String content = "content951530617";
+   *   DetectLanguageResponse response =
+   *       translationServiceClient.detectLanguage(parent, model, mimeType, content);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}/locations/{location-id}` or * `projects/{project-number-or-id}`. @@ -381,6 +499,19 @@ public final DetectLanguageResponse detectLanguage( /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   String content = "content951530617";
+   *   DetectLanguageResponse response =
+   *       translationServiceClient.detectLanguage(parent, model, mimeType, content);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}/locations/{location-id}` or * `projects/{project-number-or-id}`. @@ -415,6 +546,21 @@ public final DetectLanguageResponse detectLanguage( /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DetectLanguageRequest request =
+   *       DetectLanguageRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setMimeType("mimeType-1392120434")
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   DetectLanguageResponse response = translationServiceClient.detectLanguage(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 */ @@ -427,6 +573,22 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request * Detects the language of text within a request. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DetectLanguageRequest request =
+   *       DetectLanguageRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setMimeType("mimeType-1392120434")
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.detectLanguageCallable().futureCall(request);
+   *   // Do something.
+   *   DetectLanguageResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable detectLanguageCallable() { @@ -437,6 +599,18 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String model = "model104069929";
+   *   String displayLanguageCode = "displayLanguageCode-1457478841";
+   *   SupportedLanguages response =
+   *       translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -474,6 +648,18 @@ public final SupportedLanguages getSupportedLanguages( /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String model = "model104069929";
+   *   String displayLanguageCode = "displayLanguageCode-1457478841";
+   *   SupportedLanguages response =
+   *       translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-number-or-id}` or * `projects/{project-number-or-id}/locations/{location-id}`. @@ -511,6 +697,20 @@ public final SupportedLanguages getSupportedLanguages( /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetSupportedLanguagesRequest request =
+   *       GetSupportedLanguagesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setDisplayLanguageCode("displayLanguageCode-1457478841")
+   *           .setModel("model104069929")
+   *           .build();
+   *   SupportedLanguages response = translationServiceClient.getSupportedLanguages(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 */ @@ -523,6 +723,21 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * Returns a list of supported languages for translation. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetSupportedLanguagesRequest request =
+   *       GetSupportedLanguagesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setDisplayLanguageCode("displayLanguageCode-1457478841")
+   *           .setModel("model104069929")
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.getSupportedLanguagesCallable().futureCall(request);
+   *   // Do something.
+   *   SupportedLanguages response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getSupportedLanguagesCallable() { @@ -538,6 +753,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque *

This call returns immediately and you can use google.longrunning.Operation.name to poll the * status of the call. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   BatchTranslateResponse response =
+   *       translationServiceClient.batchTranslateTextAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -556,6 +791,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.batchTranslateTextOperationCallable().futureCall(request);
+   *   // Do something.
+   *   BatchTranslateResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> @@ -573,6 +828,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.batchTranslateTextCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable batchTranslateTextCallable() { return stub.batchTranslateTextCallable(); @@ -583,6 +858,16 @@ public final UnaryCallable batchTranslateT * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Glossary glossary = Glossary.newBuilder().build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
+   * }
+   * }
+ * * @param parent Required. The project name. * @param glossary Required. The glossary to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -602,6 +887,16 @@ public final OperationFuture createGlossaryAsy * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Glossary glossary = Glossary.newBuilder().build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
+   * }
+   * }
+ * * @param parent Required. The project name. * @param glossary Required. The glossary to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -618,6 +913,19 @@ public final OperationFuture createGlossaryAsy * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -632,6 +940,20 @@ public final OperationFuture createGlossaryAsy * doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.createGlossaryOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Glossary response = future.get();
+   * }
+   * }
*/ public final OperationCallable createGlossaryOperationCallable() { @@ -644,6 +966,20 @@ public final OperationFuture createGlossaryAsy * doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.createGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createGlossaryCallable() { return stub.createGlossaryCallable(); @@ -653,6 +989,17 @@ public final UnaryCallable createGlossaryCalla /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -668,6 +1015,17 @@ public final ListGlossariesPagedResponse listGlossaries(LocationName parent) { /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -680,6 +1038,23 @@ public final ListGlossariesPagedResponse listGlossaries(String parent) { /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   ListGlossariesRequest request =
+   *       ListGlossariesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -692,6 +1067,24 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   ListGlossariesRequest request =
+   *       ListGlossariesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.listGlossariesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Glossary element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listGlossariesPagedCallable() { @@ -703,6 +1096,24 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   while (true) {
+   *     ListGlossariesResponse response =
+   *         translationServiceClient.listGlossariesCallable().call(request);
+   *     for (Glossary element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listGlossariesCallable() { @@ -713,6 +1124,15 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
+   *   Glossary response = translationServiceClient.getGlossary(name);
+   * }
+   * }
+ * * @param name Required. The name of the glossary to retrieve. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -726,6 +1146,15 @@ public final Glossary getGlossary(GlossaryName name) { /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
+   *   Glossary response = translationServiceClient.getGlossary(name);
+   * }
+   * }
+ * * @param name Required. The name of the glossary to retrieve. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -738,6 +1167,18 @@ public final Glossary getGlossary(String name) { /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetGlossaryRequest request =
+   *       GetGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   Glossary response = translationServiceClient.getGlossary(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 */ @@ -750,6 +1191,19 @@ public final Glossary getGlossary(GetGlossaryRequest request) { * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetGlossaryRequest request =
+   *       GetGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.getGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Glossary response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getGlossaryCallable() { return stub.getGlossaryCallable(); @@ -760,6 +1214,15 @@ public final UnaryCallable getGlossaryCallable() { * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
+   * }
+   * }
+ * * @param name Required. The name of the glossary to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -775,6 +1238,15 @@ public final OperationFuture del * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
+   * }
+   * }
+ * * @param name Required. The name of the glossary to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -789,6 +1261,18 @@ public final OperationFuture del * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -803,6 +1287,19 @@ public final OperationFuture del * NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.deleteGlossaryOperationCallable().futureCall(request);
+   *   // Do something.
+   *   DeleteGlossaryResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> @@ -816,6 +1313,19 @@ public final OperationFuture del * NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.deleteGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteGlossaryCallable() { return stub.deleteGlossaryCallable(); diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java index c1073a04..6f22696b 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java @@ -22,6 +22,16 @@ *

Service Description: Provides natural language translation operations. * *

Sample for TranslationServiceClient: + * + *

{@code
+ * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   String targetLanguageCode = "targetLanguageCode-106414698";
+ *   List contents = new ArrayList<>();
+ *   TranslateTextResponse response =
+ *       translationServiceClient.translateText(parent, targetLanguageCode, contents);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.translate.v3; diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java index 41d44afc..120d6322 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java @@ -45,6 +45,23 @@ *

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 (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+ *   TranslateTextRequest request =
+ *       TranslateTextRequest.newBuilder()
+ *           .addAllContents(new ArrayList())
+ *           .setMimeType("mimeType-1392120434")
+ *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+ *           .setTargetLanguageCode("targetLanguageCode-106414698")
+ *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+ *           .setModel("model104069929")
+ *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+ *           .putAllLabels(new HashMap())
+ *           .build();
+ *   TranslateTextResponse response = translationServiceClient.translateText(request);
+ * }
+ * }
+ * *

Note: close() needs to be called on the TranslationServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -163,6 +180,25 @@ public final OperationsClient getOperationsClient() { /** * Translates input text and returns translated text. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   TranslateTextRequest request =
+   *       TranslateTextRequest.newBuilder()
+   *           .addAllContents(new ArrayList())
+   *           .setMimeType("mimeType-1392120434")
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .setTargetLanguageCode("targetLanguageCode-106414698")
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   TranslateTextResponse response = translationServiceClient.translateText(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 */ @@ -175,6 +211,26 @@ public final TranslateTextResponse translateText(TranslateTextRequest request) { * Translates input text and returns translated text. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   TranslateTextRequest request =
+   *       TranslateTextRequest.newBuilder()
+   *           .addAllContents(new ArrayList())
+   *           .setMimeType("mimeType-1392120434")
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .setTargetLanguageCode("targetLanguageCode-106414698")
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.translateTextCallable().futureCall(request);
+   *   // Do something.
+   *   TranslateTextResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable translateTextCallable() { return stub.translateTextCallable(); @@ -184,6 +240,18 @@ public final UnaryCallable translat /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   DetectLanguageResponse response =
+   *       translationServiceClient.detectLanguage(parent, model, mimeType);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-id}/locations/{location-id}` or `projects/{project-id}`. *

For global calls, use `projects/{project-id}/locations/global` or @@ -215,6 +283,18 @@ public final DetectLanguageResponse detectLanguage( /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String model = "model104069929";
+   *   String mimeType = "mimeType-1392120434";
+   *   DetectLanguageResponse response =
+   *       translationServiceClient.detectLanguage(parent, model, mimeType);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-id}/locations/{location-id}` or `projects/{project-id}`. *

For global calls, use `projects/{project-id}/locations/global` or @@ -245,6 +325,21 @@ public final DetectLanguageResponse detectLanguage(String parent, String model, /** * Detects the language of text within a request. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DetectLanguageRequest request =
+   *       DetectLanguageRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setMimeType("mimeType-1392120434")
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   DetectLanguageResponse response = translationServiceClient.detectLanguage(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 */ @@ -257,6 +352,22 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request * Detects the language of text within a request. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DetectLanguageRequest request =
+   *       DetectLanguageRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setModel("model104069929")
+   *           .setMimeType("mimeType-1392120434")
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.detectLanguageCallable().futureCall(request);
+   *   // Do something.
+   *   DetectLanguageResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable detectLanguageCallable() { @@ -267,6 +378,18 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String displayLanguageCode = "displayLanguageCode-1457478841";
+   *   String model = "model104069929";
+   *   SupportedLanguages response =
+   *       translationServiceClient.getSupportedLanguages(parent, displayLanguageCode, model);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-id}` or `projects/{project-id}/locations/{location-id}`. *

For global calls, use `projects/{project-id}/locations/global` or @@ -303,6 +426,18 @@ public final SupportedLanguages getSupportedLanguages( /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String displayLanguageCode = "displayLanguageCode-1457478841";
+   *   String model = "model104069929";
+   *   SupportedLanguages response =
+   *       translationServiceClient.getSupportedLanguages(parent, displayLanguageCode, model);
+   * }
+   * }
+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *

Format: `projects/{project-id}` or `projects/{project-id}/locations/{location-id}`. *

For global calls, use `projects/{project-id}/locations/global` or @@ -339,6 +474,20 @@ public final SupportedLanguages getSupportedLanguages( /** * Returns a list of supported languages for translation. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetSupportedLanguagesRequest request =
+   *       GetSupportedLanguagesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setDisplayLanguageCode("displayLanguageCode-1457478841")
+   *           .setModel("model104069929")
+   *           .build();
+   *   SupportedLanguages response = translationServiceClient.getSupportedLanguages(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 */ @@ -351,6 +500,21 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * Returns a list of supported languages for translation. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetSupportedLanguagesRequest request =
+   *       GetSupportedLanguagesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setDisplayLanguageCode("displayLanguageCode-1457478841")
+   *           .setModel("model104069929")
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.getSupportedLanguagesCallable().futureCall(request);
+   *   // Do something.
+   *   SupportedLanguages response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getSupportedLanguagesCallable() { @@ -366,6 +530,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque *

This call returns immediately and you can use google.longrunning.Operation.name to poll the * status of the call. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   BatchTranslateResponse response =
+   *       translationServiceClient.batchTranslateTextAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -384,6 +568,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.batchTranslateTextOperationCallable().futureCall(request);
+   *   // Do something.
+   *   BatchTranslateResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> @@ -401,6 +605,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   BatchTranslateTextRequest request =
+   *       BatchTranslateTextRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+   *           .addAllTargetLanguageCodes(new ArrayList())
+   *           .putAllModels(new HashMap())
+   *           .addAllInputConfigs(new ArrayList())
+   *           .setOutputConfig(OutputConfig.newBuilder().build())
+   *           .putAllGlossaries(new HashMap())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.batchTranslateTextCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable batchTranslateTextCallable() { return stub.batchTranslateTextCallable(); @@ -411,6 +635,16 @@ public final UnaryCallable batchTranslateT * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Glossary glossary = Glossary.newBuilder().build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
+   * }
+   * }
+ * * @param parent Required. The project name. * @param glossary Required. The glossary to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -430,6 +664,16 @@ public final OperationFuture createGlossaryAsy * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Glossary glossary = Glossary.newBuilder().build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get();
+   * }
+   * }
+ * * @param parent Required. The project name. * @param glossary Required. The glossary to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -446,6 +690,19 @@ public final OperationFuture createGlossaryAsy * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project * doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   Glossary response = translationServiceClient.createGlossaryAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -460,6 +717,20 @@ public final OperationFuture createGlossaryAsy * doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.createGlossaryOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Glossary response = future.get();
+   * }
+   * }
*/ public final OperationCallable createGlossaryOperationCallable() { @@ -472,6 +743,20 @@ public final OperationFuture createGlossaryAsy * doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   CreateGlossaryRequest request =
+   *       CreateGlossaryRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setGlossary(Glossary.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.createGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createGlossaryCallable() { return stub.createGlossaryCallable(); @@ -481,6 +766,17 @@ public final UnaryCallable createGlossaryCalla /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -496,6 +792,17 @@ public final ListGlossariesPagedResponse listGlossaries(LocationName parent) { /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -508,6 +815,19 @@ public final ListGlossariesPagedResponse listGlossaries(String parent) { /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String filter = "filter-1274492040";
+   *   for (Glossary element :
+   *       translationServiceClient.listGlossaries(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @param filter Optional. Filter specifying constraints of a list operation. Filtering is not * supported yet, and the parameter currently has no effect. If missing, no filtering is @@ -527,6 +847,19 @@ public final ListGlossariesPagedResponse listGlossaries(LocationName parent, Str /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   String filter = "filter-1274492040";
+   *   for (Glossary element :
+   *       translationServiceClient.listGlossaries(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project from which to list all of the glossaries. * @param filter Optional. Filter specifying constraints of a list operation. Filtering is not * supported yet, and the parameter currently has no effect. If missing, no filtering is @@ -543,6 +876,23 @@ public final ListGlossariesPagedResponse listGlossaries(String parent, String fi /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   ListGlossariesRequest request =
+   *       ListGlossariesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -555,6 +905,24 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   ListGlossariesRequest request =
+   *       ListGlossariesRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.listGlossariesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Glossary element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listGlossariesPagedCallable() { @@ -566,6 +934,24 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   while (true) {
+   *     ListGlossariesResponse response =
+   *         translationServiceClient.listGlossariesCallable().call(request);
+   *     for (Glossary element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listGlossariesCallable() { @@ -576,6 +962,15 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
+   *   Glossary response = translationServiceClient.getGlossary(name);
+   * }
+   * }
+ * * @param name Required. The name of the glossary to retrieve. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -589,6 +984,15 @@ public final Glossary getGlossary(GlossaryName name) { /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
+   *   Glossary response = translationServiceClient.getGlossary(name);
+   * }
+   * }
+ * * @param name Required. The name of the glossary to retrieve. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -601,6 +1005,18 @@ public final Glossary getGlossary(String name) { /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetGlossaryRequest request =
+   *       GetGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   Glossary response = translationServiceClient.getGlossary(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 */ @@ -613,6 +1029,19 @@ public final Glossary getGlossary(GetGlossaryRequest request) { * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GetGlossaryRequest request =
+   *       GetGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.getGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Glossary response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getGlossaryCallable() { return stub.getGlossaryCallable(); @@ -623,6 +1052,15 @@ public final UnaryCallable getGlossaryCallable() { * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
+   * }
+   * }
+ * * @param name Required. The name of the glossary to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -638,6 +1076,15 @@ public final OperationFuture del * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString();
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get();
+   * }
+   * }
+ * * @param name Required. The name of the glossary to delete. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -652,6 +1099,18 @@ public final OperationFuture del * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns * NOT_FOUND, if the glossary doesn't exist. * + *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get();
+   * }
+   * }
+ * * @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 */ @@ -666,6 +1125,19 @@ public final OperationFuture del * NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   OperationFuture future =
+   *       translationServiceClient.deleteGlossaryOperationCallable().futureCall(request);
+   *   // Do something.
+   *   DeleteGlossaryResponse response = future.get();
+   * }
+   * }
*/ public final OperationCallable< DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> @@ -679,6 +1151,19 @@ public final OperationFuture del * NOT_FOUND, if the glossary doesn't exist. * *

Sample code: + * + *

{@code
+   * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+   *   DeleteGlossaryRequest request =
+   *       DeleteGlossaryRequest.newBuilder()
+   *           .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       translationServiceClient.deleteGlossaryCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteGlossaryCallable() { return stub.deleteGlossaryCallable(); diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/package-info.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/package-info.java index 3aa4e1b4..5084f173 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/package-info.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/package-info.java @@ -22,6 +22,23 @@ *

Service Description: Provides natural language translation operations. * *

Sample for TranslationServiceClient: + * + *

{@code
+ * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
+ *   TranslateTextRequest request =
+ *       TranslateTextRequest.newBuilder()
+ *           .addAllContents(new ArrayList())
+ *           .setMimeType("mimeType-1392120434")
+ *           .setSourceLanguageCode("sourceLanguageCode1645917472")
+ *           .setTargetLanguageCode("targetLanguageCode-106414698")
+ *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+ *           .setModel("model104069929")
+ *           .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
+ *           .putAllLabels(new HashMap())
+ *           .build();
+ *   TranslateTextResponse response = translationServiceClient.translateText(request);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.translate.v3beta1; diff --git a/synth.metadata b/synth.metadata index d0359e0d..ee5e31ae 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,23 +4,23 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-translate.git", - "sha": "9a99bb54d14fa933fe1ed9414d01cae0f35f097e" + "sha": "8a40a6ec80b3a23d10f9fbac620e7e3454c934af" } }, { "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" } }, {