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+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *contents = new ArrayList<>(); + * TranslateTextResponse response = + * translationServiceClient.translateText(parent, targetLanguageCode, contents); + * } + * }
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+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *contents = new ArrayList<>(); + * TranslateTextResponse response = + * translationServiceClient.translateText(parent, targetLanguageCode, contents); + * } + * }
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+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *contents = new ArrayList<>(); + * TranslateTextResponse response = + * translationServiceClient.translateText( + * parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + * } + * }
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+ * * @param parent Required. Project or location to make a call. Must refer to a caller's project. *contents = new ArrayList<>(); + * TranslateTextResponse response = + * translationServiceClient.translateText( + * parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + * } + * }
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+ * * @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. * *()) + * .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); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * TranslateTextRequest request = + * TranslateTextRequest.newBuilder() + * .addAllContents(new ArrayList*/ public final UnaryCallable()) + * .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(); + * } + * }
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+ * * @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. * *()) + * .build(); + * DetectLanguageResponse response = translationServiceClient.detectLanguage(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*/ public final UnaryCallable()) + * .build(); + * ApiFuture future = + * translationServiceClient.detectLanguageCallable().futureCall(request); + * // Do something. + * DetectLanguageResponse response = future.get(); + * } + * }
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*/ public final UnaryCallablefuture = + * translationServiceClient.getSupportedLanguagesCallable().futureCall(request); + * // Do something. + * SupportedLanguages response = future.get(); + * } + * }
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+ * * @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. * *()) + * .putAllModels(new HashMap ()) + * .addAllInputConfigs(new ArrayList ()) + * .setOutputConfig(OutputConfig.newBuilder().build()) + * .putAllGlossaries(new HashMap ()) + * .putAllLabels(new HashMap ()) + * .build(); + * BatchTranslateResponse response = + * translationServiceClient.batchTranslateTextAsync(request).get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * BatchTranslateTextRequest request = + * BatchTranslateTextRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setSourceLanguageCode("sourceLanguageCode1645917472") + * .addAllTargetLanguageCodes(new ArrayList*/ public final OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> @@ -573,6 +828,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *()) + * .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(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * BatchTranslateTextRequest request = + * BatchTranslateTextRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setSourceLanguageCode("sourceLanguageCode1645917472") + * .addAllTargetLanguageCodes(new ArrayList*/ public final UnaryCallable()) + * .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(); + * } + * }
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
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
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
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * CreateGlossaryRequest request = + * CreateGlossaryRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setGlossary(Glossary.newBuilder().build()) + * .build(); + * OperationFuture*/ public final OperationCallablefuture = + * translationServiceClient.createGlossaryOperationCallable().futureCall(request); + * // Do something. + * Glossary response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * CreateGlossaryRequest request = + * CreateGlossaryRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setGlossary(Glossary.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = + * translationServiceClient.createGlossaryCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
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*/ public final UnaryCallablefuture = + * translationServiceClient.listGlossariesPagedCallable().futureCall(request); + * // Do something. + * for (Glossary element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
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
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*/ public final UnaryCallablefuture = + * translationServiceClient.getGlossaryCallable().futureCall(request); + * // Do something. + * Glossary response = future.get(); + * } + * }
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
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
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
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * DeleteGlossaryRequest request = + * DeleteGlossaryRequest.newBuilder() + * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + * .build(); + * OperationFuture*/ public final OperationCallable< DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> @@ -816,6 +1313,19 @@ public final OperationFuturefuture = + * translationServiceClient.deleteGlossaryOperationCallable().futureCall(request); + * // Do something. + * DeleteGlossaryResponse response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * DeleteGlossaryRequest request = + * DeleteGlossaryRequest.newBuilder() + * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = + * translationServiceClient.deleteGlossaryCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
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*/ @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 @@ *contents = new ArrayList<>(); + * TranslateTextResponse response = + * translationServiceClient.translateText(parent, targetLanguageCode, contents); + * } + * }
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+ * * @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. * *()) + * .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); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * TranslateTextRequest request = + * TranslateTextRequest.newBuilder() + * .addAllContents(new ArrayList*/ public final UnaryCallable()) + * .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(); + * } + * }
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+ * * @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. * *()) + * .build(); + * DetectLanguageResponse response = translationServiceClient.detectLanguage(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*/ public final UnaryCallable()) + * .build(); + * ApiFuture future = + * translationServiceClient.detectLanguageCallable().futureCall(request); + * // Do something. + * DetectLanguageResponse response = future.get(); + * } + * }
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*/ public final UnaryCallablefuture = + * translationServiceClient.getSupportedLanguagesCallable().futureCall(request); + * // Do something. + * SupportedLanguages response = future.get(); + * } + * }
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+ * * @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. * *()) + * .putAllModels(new HashMap ()) + * .addAllInputConfigs(new ArrayList ()) + * .setOutputConfig(OutputConfig.newBuilder().build()) + * .putAllGlossaries(new HashMap ()) + * .putAllLabels(new HashMap ()) + * .build(); + * BatchTranslateResponse response = + * translationServiceClient.batchTranslateTextAsync(request).get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * BatchTranslateTextRequest request = + * BatchTranslateTextRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setSourceLanguageCode("sourceLanguageCode1645917472") + * .addAllTargetLanguageCodes(new ArrayList*/ public final OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> @@ -401,6 +605,26 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque * status of the call. * *()) + * .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(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * BatchTranslateTextRequest request = + * BatchTranslateTextRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setSourceLanguageCode("sourceLanguageCode1645917472") + * .addAllTargetLanguageCodes(new ArrayList*/ public final UnaryCallable()) + * .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(); + * } + * }
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
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
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
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * CreateGlossaryRequest request = + * CreateGlossaryRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setGlossary(Glossary.newBuilder().build()) + * .build(); + * OperationFuture*/ public final OperationCallablefuture = + * translationServiceClient.createGlossaryOperationCallable().futureCall(request); + * // Do something. + * Glossary response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * CreateGlossaryRequest request = + * CreateGlossaryRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setGlossary(Glossary.newBuilder().build()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = + * translationServiceClient.createGlossaryCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
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*/ public final UnaryCallablefuture = + * translationServiceClient.listGlossariesPagedCallable().futureCall(request); + * // Do something. + * for (Glossary element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
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
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*/ public final UnaryCallablefuture = + * translationServiceClient.getGlossaryCallable().futureCall(request); + * // Do something. + * Glossary response = future.get(); + * } + * }
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
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
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
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * DeleteGlossaryRequest request = + * DeleteGlossaryRequest.newBuilder() + * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + * .build(); + * OperationFuture*/ public final OperationCallable< DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> @@ -679,6 +1151,19 @@ public final OperationFuturefuture = + * translationServiceClient.deleteGlossaryOperationCallable().futureCall(request); + * // Do something. + * DeleteGlossaryResponse response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * DeleteGlossaryRequest request = + * DeleteGlossaryRequest.newBuilder() + * .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + * .build(); + * ApiFuture*/ public final UnaryCallablefuture = + * translationServiceClient.deleteGlossaryCallable().futureCall(request); + * // Do something. + * Operation response = future.get(); + * } + * }
Service Description: Provides natural language translation operations. * *
Sample for TranslationServiceClient: + * + *
{@code + * try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + * TranslateTextRequest request = + * TranslateTextRequest.newBuilder() + * .addAllContents(new ArrayList*/ @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" } }, {()) + * .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); + * } + * }