diff --git a/google-cloud-translate-bom/pom.xml b/google-cloud-translate-bom/pom.xml
index 01cb02c9..3da38ac2 100644
--- a/google-cloud-translate-bom/pom.xml
+++ b/google-cloud-translate-bom/pom.xml
@@ -65,12 +65,21 @@
com.google.api.grpcgrpc-google-cloud-translate-v3beta10.76.1-SNAPSHOT
+
+ com.google.api.grpc
+ grpc-google-cloud-translate-v3
+ 0.76.1-SNAPSHOTcom.google.api.grpcproto-google-cloud-translate-v3beta10.76.1-SNAPSHOT
+
+ com.google.api.grpc
+ proto-google-cloud-translate-v3
+ 0.76.1-SNAPSHOT
+ com.google.cloudgoogle-cloud-translate
diff --git a/google-cloud-translate/pom.xml b/google-cloud-translate/pom.xml
index f33d59ec..a491f15c 100644
--- a/google-cloud-translate/pom.xml
+++ b/google-cloud-translate/pom.xml
@@ -46,6 +46,10 @@
com.google.api.grpcproto-google-cloud-translate-v3beta1
+
+ com.google.api.grpc
+ proto-google-cloud-translate-v3
+ com.google.guavaguava
@@ -107,6 +111,11 @@
grpc-google-cloud-translate-v3beta1test
+
+ com.google.api.grpc
+ grpc-google-cloud-translate-v3
+ test
+ com.google.cloudgoogle-cloud-core
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
new file mode 100644
index 00000000..07a9cd49
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java
@@ -0,0 +1,1445 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.ApiFuture;
+import com.google.api.core.ApiFutures;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.longrunning.OperationFuture;
+import com.google.api.gax.paging.AbstractFixedSizeCollection;
+import com.google.api.gax.paging.AbstractPage;
+import com.google.api.gax.paging.AbstractPagedListResponse;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.translate.v3.stub.TranslationServiceStub;
+import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.longrunning.Operation;
+import com.google.longrunning.OperationsClient;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND SERVICE
+/**
+ * Service Description: Provides natural language translation operations.
+ *
+ *
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:
+ *
+ *
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().
+ *
+ *
The surface of this class includes several types of Java methods for each of the API's
+ * methods:
+ *
+ *
+ *
A "flattened" method. With this type of method, the fields of the request type have been
+ * converted into function parameters. It may be the case that not all fields are available as
+ * parameters, and not every API method will have a flattened method entry point.
+ *
A "request object" method. This type of method only takes one parameter, a request object,
+ * which must be constructed before the call. Not every API method will have a request object
+ * method.
+ *
A "callable" method. This type of method takes no parameters and returns an immutable API
+ * callable object, which can be used to initiate calls to the service.
+ *
+ *
+ *
See the individual methods for example code.
+ *
+ *
Many parameters require resource names to be formatted in a particular way. To assist with
+ * these names, this class includes a format method for each type of name, and additionally a parse
+ * method to extract the individual identifiers contained within names that are returned.
+ *
+ *
This class can be customized by passing in a custom instance of TranslationServiceSettings to
+ * create(). For example:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class TranslationServiceClient implements BackgroundResource {
+ private final TranslationServiceSettings settings;
+ private final TranslationServiceStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of TranslationServiceClient with default settings. */
+ public static final TranslationServiceClient create() throws IOException {
+ return create(TranslationServiceSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of TranslationServiceClient, using the given settings. The channels are
+ * created based on the settings passed in, or defaults for any settings that are not set.
+ */
+ public static final TranslationServiceClient create(TranslationServiceSettings settings)
+ throws IOException {
+ return new TranslationServiceClient(settings);
+ }
+
+ /**
+ * Constructs an instance of TranslationServiceClient, using the given stub for making calls. This
+ * is for advanced usage - prefer to use TranslationServiceSettings}.
+ */
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public static final TranslationServiceClient create(TranslationServiceStub stub) {
+ return new TranslationServiceClient(stub);
+ }
+
+ /**
+ * Constructs an instance of TranslationServiceClient, using the given settings. This is protected
+ * so that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected TranslationServiceClient(TranslationServiceSettings settings) throws IOException {
+ this.settings = settings;
+ this.stub = ((TranslationServiceStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ protected TranslationServiceClient(TranslationServiceStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final TranslationServiceSettings getSettings() {
+ return settings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public TranslationServiceStub getStub() {
+ return stub;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for requests using AutoML models or custom glossaries.
+ *
Models and glossaries must be within the same region (have same location-id), otherwise
+ * an INVALID_ARGUMENT (400) error is returned.
+ * @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
+ * input text, set to one of the language codes listed in Language Support.
+ * @param contents Required. The content of the input in string format. We recommend the total
+ * content be less than 30k codepoints. Use BatchTranslateText for larger text.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final TranslateTextResponse translateText(
+ LocationName parent, String targetLanguageCode, List contents) {
+
+ TranslateTextRequest request =
+ TranslateTextRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setTargetLanguageCode(targetLanguageCode)
+ .addAllContents(contents)
+ .build();
+ return translateText(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for requests using AutoML models or custom glossaries.
+ *
Models and glossaries must be within the same region (have same location-id), otherwise
+ * an INVALID_ARGUMENT (400) error is returned.
+ * @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
+ * input text, set to one of the language codes listed in Language Support.
+ * @param contents Required. The content of the input in string format. We recommend the total
+ * content be less than 30k codepoints. Use BatchTranslateText for larger text.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final TranslateTextResponse translateText(
+ String parent, String targetLanguageCode, List contents) {
+
+ TranslateTextRequest request =
+ TranslateTextRequest.newBuilder()
+ .setParent(parent)
+ .setTargetLanguageCode(targetLanguageCode)
+ .addAllContents(contents)
+ .build();
+ return translateText(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for requests using AutoML models or custom glossaries.
+ *
Models and glossaries must be within the same region (have same location-id), otherwise
+ * an INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. The `model` type requested for this translation.
+ *
For global (non-regionalized) requests, use `location-id` `global`. For example,
+ * `projects/{project-number-or-id}/locations/global/models/general/nmt`.
+ *
If missing, the system decides which google base model to use.
+ * @param mimeType Optional. The format of the source text, for example, "text/html",
+ * "text/plain". If left blank, the MIME type defaults to "text/html".
+ * @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
+ * example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
+ * the source language isn't specified, the API attempts to identify the source language
+ * automatically and returns the source language within the response.
+ * @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
+ * input text, set to one of the language codes listed in Language Support.
+ * @param contents Required. The content of the input in string format. We recommend the total
+ * content be less than 30k codepoints. Use BatchTranslateText for larger text.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final TranslateTextResponse translateText(
+ LocationName parent,
+ String model,
+ String mimeType,
+ String sourceLanguageCode,
+ String targetLanguageCode,
+ List contents) {
+
+ TranslateTextRequest request =
+ TranslateTextRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setModel(model)
+ .setMimeType(mimeType)
+ .setSourceLanguageCode(sourceLanguageCode)
+ .setTargetLanguageCode(targetLanguageCode)
+ .addAllContents(contents)
+ .build();
+ return translateText(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for requests using AutoML models or custom glossaries.
+ *
Models and glossaries must be within the same region (have same location-id), otherwise
+ * an INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. The `model` type requested for this translation.
+ *
For global (non-regionalized) requests, use `location-id` `global`. For example,
+ * `projects/{project-number-or-id}/locations/global/models/general/nmt`.
+ *
If missing, the system decides which google base model to use.
+ * @param mimeType Optional. The format of the source text, for example, "text/html",
+ * "text/plain". If left blank, the MIME type defaults to "text/html".
+ * @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
+ * example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
+ * the source language isn't specified, the API attempts to identify the source language
+ * automatically and returns the source language within the response.
+ * @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
+ * input text, set to one of the language codes listed in Language Support.
+ * @param contents Required. The content of the input in string format. We recommend the total
+ * content be less than 30k codepoints. Use BatchTranslateText for larger text.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final TranslateTextResponse translateText(
+ String parent,
+ String model,
+ String mimeType,
+ String sourceLanguageCode,
+ String targetLanguageCode,
+ List contents) {
+
+ TranslateTextRequest request =
+ TranslateTextRequest.newBuilder()
+ .setParent(parent)
+ .setModel(model)
+ .setMimeType(mimeType)
+ .setSourceLanguageCode(sourceLanguageCode)
+ .setTargetLanguageCode(targetLanguageCode)
+ .addAllContents(contents)
+ .build();
+ return translateText(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ *
+ * @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
+ */
+ public final TranslateTextResponse translateText(TranslateTextRequest request) {
+ return translateTextCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates input text and returns translated text.
+ *
+ *
+ */
+ public final UnaryCallable translateTextCallable() {
+ return stub.translateTextCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Detects the language of text within a request.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Only models within the same region (has same location-id) can be used. Otherwise an
+ * INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. The language detection model to be used.
+ *
Only one language detection model is currently supported:
+ * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
+ *
If not specified, the default model is used.
+ * @param mimeType Optional. The format of the source text, for example, "text/html",
+ * "text/plain". If left blank, the MIME type defaults to "text/html".
+ * @param content The content of the input stored as a string.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final DetectLanguageResponse detectLanguage(
+ LocationName parent, String model, String mimeType, String content) {
+
+ DetectLanguageRequest request =
+ DetectLanguageRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setModel(model)
+ .setMimeType(mimeType)
+ .setContent(content)
+ .build();
+ return detectLanguage(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Detects the language of text within a request.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Only models within the same region (has same location-id) can be used. Otherwise an
+ * INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. The language detection model to be used.
+ *
Only one language detection model is currently supported:
+ * `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
+ *
If not specified, the default model is used.
+ * @param mimeType Optional. The format of the source text, for example, "text/html",
+ * "text/plain". If left blank, the MIME type defaults to "text/html".
+ * @param content The content of the input stored as a string.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final DetectLanguageResponse detectLanguage(
+ String parent, String model, String mimeType, String content) {
+
+ DetectLanguageRequest request =
+ DetectLanguageRequest.newBuilder()
+ .setParent(parent)
+ .setModel(model)
+ .setMimeType(mimeType)
+ .setContent(content)
+ .build();
+ return detectLanguage(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Detects the language of text within a 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
+ */
+ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request) {
+ return detectLanguageCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Detects the language of text within a request.
+ *
+ *
+ */
+ public final UnaryCallable
+ detectLanguageCallable() {
+ return stub.detectLanguageCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Returns a list of supported languages for translation.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for AutoML models.
+ *
Only models within the same region (have same location-id) can be used, otherwise an
+ * INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. Get supported languages of this model.
+ *
Returns languages supported by the specified model. If missing, we get supported
+ * languages of Google general base (PBMT) model.
+ * @param displayLanguageCode Optional. The language to use to return localized, human readable
+ * names of supported languages. If missing, then display names are not returned in a
+ * response.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final SupportedLanguages getSupportedLanguages(
+ LocationName parent, String model, String displayLanguageCode) {
+
+ GetSupportedLanguagesRequest request =
+ GetSupportedLanguagesRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setModel(model)
+ .setDisplayLanguageCode(displayLanguageCode)
+ .build();
+ return getSupportedLanguages(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Returns a list of supported languages for translation.
+ *
+ *
+ *
+ * @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}`.
+ *
For global calls, use `projects/{project-number-or-id}/locations/global` or
+ * `projects/{project-number-or-id}`.
+ *
Non-global location is required for AutoML models.
+ *
Only models within the same region (have same location-id) can be used, otherwise an
+ * INVALID_ARGUMENT (400) error is returned.
+ * @param model Optional. Get supported languages of this model.
+ *
Returns languages supported by the specified model. If missing, we get supported
+ * languages of Google general base (PBMT) model.
+ * @param displayLanguageCode Optional. The language to use to return localized, human readable
+ * names of supported languages. If missing, then display names are not returned in a
+ * response.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final SupportedLanguages getSupportedLanguages(
+ String parent, String model, String displayLanguageCode) {
+
+ GetSupportedLanguagesRequest request =
+ GetSupportedLanguagesRequest.newBuilder()
+ .setParent(parent)
+ .setModel(model)
+ .setDisplayLanguageCode(displayLanguageCode)
+ .build();
+ return getSupportedLanguages(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Returns a list of supported languages for translation.
+ *
+ *
+ *
+ * @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
+ */
+ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesRequest request) {
+ return getSupportedLanguagesCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Returns a list of supported languages for translation.
+ *
+ *
+ */
+ public final UnaryCallable
+ getSupportedLanguagesCallable() {
+ return stub.getSupportedLanguagesCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates a large volume of text in asynchronous batch mode. This function provides real-time
+ * output as the inputs are being processed. If caller cancels a request, the partial results (for
+ * an input file, it's all or nothing) may still be available on the specified output location.
+ *
+ *
This call returns immediately and you can use google.longrunning.Operation.name to poll the
+ * status of the call.
+ *
+ *
+ *
+ * @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
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture
+ batchTranslateTextAsync(BatchTranslateTextRequest request) {
+ return batchTranslateTextOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates a large volume of text in asynchronous batch mode. This function provides real-time
+ * output as the inputs are being processed. If caller cancels a request, the partial results (for
+ * an input file, it's all or nothing) may still be available on the specified output location.
+ *
+ *
This call returns immediately and you can use google.longrunning.Operation.name to poll the
+ * status of the call.
+ *
+ *
+ */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public final OperationCallable<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationCallable() {
+ return stub.batchTranslateTextOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Translates a large volume of text in asynchronous batch mode. This function provides real-time
+ * output as the inputs are being processed. If caller cancels a request, the partial results (for
+ * an input file, it's all or nothing) may still be available on the specified output location.
+ *
+ *
This call returns immediately and you can use google.longrunning.Operation.name to poll the
+ * status of the call.
+ *
+ *
+ *
+ * @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
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture createGlossaryAsync(
+ String parent, Glossary glossary) {
+
+ CreateGlossaryRequest request =
+ CreateGlossaryRequest.newBuilder().setParent(parent).setGlossary(glossary).build();
+ return createGlossaryAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project
+ * doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture createGlossaryAsync(
+ CreateGlossaryRequest request) {
+ return createGlossaryOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project
+ * doesn't exist.
+ *
+ *
+ */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public final OperationCallable
+ createGlossaryOperationCallable() {
+ return stub.createGlossaryOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project
+ * doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ public final ListGlossariesPagedResponse listGlossaries(LocationName parent) {
+ ListGlossariesRequest request =
+ ListGlossariesRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .build();
+ return listGlossaries(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ public final ListGlossariesPagedResponse listGlossaries(String parent) {
+ ListGlossariesRequest request = ListGlossariesRequest.newBuilder().setParent(parent).build();
+ return listGlossaries(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest request) {
+ return listGlossariesPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
+ *
+ *
+ *
+ * @param name Required. The name of the glossary to retrieve.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Glossary getGlossary(String name) {
+
+ GetGlossaryRequest request = GetGlossaryRequest.newBuilder().setName(name).build();
+ return getGlossary(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ public final Glossary getGlossary(GetGlossaryRequest request) {
+ return getGlossaryCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ */
+ public final UnaryCallable getGlossaryCallable() {
+ return stub.getGlossaryCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns
+ * NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ *
+ * @param name Required. The name of the glossary to delete.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture deleteGlossaryAsync(
+ GlossaryName name) {
+
+ DeleteGlossaryRequest request =
+ DeleteGlossaryRequest.newBuilder().setName(name == null ? null : name.toString()).build();
+ return deleteGlossaryAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns
+ * NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ *
+ * @param name Required. The name of the glossary to delete.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture deleteGlossaryAsync(
+ String name) {
+
+ DeleteGlossaryRequest request = DeleteGlossaryRequest.newBuilder().setName(name).build();
+ return deleteGlossaryAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns
+ * NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ *
+ * @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
+ */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public final OperationFuture deleteGlossaryAsync(
+ DeleteGlossaryRequest request) {
+ return deleteGlossaryOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns
+ * NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public final OperationCallable<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationCallable() {
+ return stub.deleteGlossaryOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD
+ /**
+ * Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns
+ * NOT_FOUND, if the glossary doesn't exist.
+ *
+ *
+ */
+ public final UnaryCallable deleteGlossaryCallable() {
+ return stub.deleteGlossaryCallable();
+ }
+
+ @Override
+ public final void close() {
+ stub.close();
+ }
+
+ @Override
+ public void shutdown() {
+ stub.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return stub.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return stub.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ stub.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return stub.awaitTermination(duration, unit);
+ }
+
+ public static class ListGlossariesPagedResponse
+ extends AbstractPagedListResponse<
+ ListGlossariesRequest,
+ ListGlossariesResponse,
+ Glossary,
+ ListGlossariesPage,
+ ListGlossariesFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListGlossariesPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage,
+ new ApiFunction() {
+ @Override
+ public ListGlossariesPagedResponse apply(ListGlossariesPage input) {
+ return new ListGlossariesPagedResponse(input);
+ }
+ },
+ MoreExecutors.directExecutor());
+ }
+
+ private ListGlossariesPagedResponse(ListGlossariesPage page) {
+ super(page, ListGlossariesFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListGlossariesPage
+ extends AbstractPage<
+ ListGlossariesRequest, ListGlossariesResponse, Glossary, ListGlossariesPage> {
+
+ private ListGlossariesPage(
+ PageContext context,
+ ListGlossariesResponse response) {
+ super(context, response);
+ }
+
+ private static ListGlossariesPage createEmptyPage() {
+ return new ListGlossariesPage(null, null);
+ }
+
+ @Override
+ protected ListGlossariesPage createPage(
+ PageContext context,
+ ListGlossariesResponse response) {
+ return new ListGlossariesPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListGlossariesFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListGlossariesRequest,
+ ListGlossariesResponse,
+ Glossary,
+ ListGlossariesPage,
+ ListGlossariesFixedSizeCollection> {
+
+ private ListGlossariesFixedSizeCollection(List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListGlossariesFixedSizeCollection createEmptyCollection() {
+ return new ListGlossariesFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListGlossariesFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListGlossariesFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java
new file mode 100644
index 00000000..47d6f6fe
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3;
+
+import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link TranslationServiceClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (translate.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of translateText to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class TranslationServiceSettings extends ClientSettings {
+ /** Returns the object with the settings used for calls to translateText. */
+ public UnaryCallSettings translateTextSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).translateTextSettings();
+ }
+
+ /** Returns the object with the settings used for calls to detectLanguage. */
+ public UnaryCallSettings detectLanguageSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).detectLanguageSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getSupportedLanguages. */
+ public UnaryCallSettings
+ getSupportedLanguagesSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).getSupportedLanguagesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to batchTranslateText. */
+ public UnaryCallSettings batchTranslateTextSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateTextSettings();
+ }
+
+ /** Returns the object with the settings used for calls to batchTranslateText. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings())
+ .batchTranslateTextOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to createGlossary. */
+ public UnaryCallSettings createGlossarySettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).createGlossarySettings();
+ }
+
+ /** Returns the object with the settings used for calls to createGlossary. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings
+ createGlossaryOperationSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).createGlossaryOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to listGlossaries. */
+ public PagedCallSettings<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).listGlossariesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getGlossary. */
+ public UnaryCallSettings getGlossarySettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).getGlossarySettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteGlossary. */
+ public UnaryCallSettings deleteGlossarySettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossarySettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteGlossary. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings() {
+ return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossaryOperationSettings();
+ }
+
+ public static final TranslationServiceSettings create(TranslationServiceStubSettings stub)
+ throws IOException {
+ return new TranslationServiceSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return TranslationServiceStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return TranslationServiceStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return TranslationServiceStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return TranslationServiceStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return TranslationServiceStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return TranslationServiceStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return TranslationServiceStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected TranslationServiceSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for TranslationServiceSettings. */
+ public static class Builder extends ClientSettings.Builder {
+ protected Builder() throws IOException {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(TranslationServiceStubSettings.newBuilder(clientContext));
+ }
+
+ private static Builder createDefault() {
+ return new Builder(TranslationServiceStubSettings.newBuilder());
+ }
+
+ protected Builder(TranslationServiceSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(TranslationServiceStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ public TranslationServiceStubSettings.Builder getStubSettingsBuilder() {
+ return ((TranslationServiceStubSettings.Builder) getStubSettings());
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to translateText. */
+ public UnaryCallSettings.Builder
+ translateTextSettings() {
+ return getStubSettingsBuilder().translateTextSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to detectLanguage. */
+ public UnaryCallSettings.Builder
+ detectLanguageSettings() {
+ return getStubSettingsBuilder().detectLanguageSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getSupportedLanguages. */
+ public UnaryCallSettings.Builder
+ getSupportedLanguagesSettings() {
+ return getStubSettingsBuilder().getSupportedLanguagesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to batchTranslateText. */
+ public UnaryCallSettings.Builder
+ batchTranslateTextSettings() {
+ return getStubSettingsBuilder().batchTranslateTextSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to batchTranslateText. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings() {
+ return getStubSettingsBuilder().batchTranslateTextOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createGlossary. */
+ public UnaryCallSettings.Builder createGlossarySettings() {
+ return getStubSettingsBuilder().createGlossarySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createGlossary. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ createGlossaryOperationSettings() {
+ return getStubSettingsBuilder().createGlossaryOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to listGlossaries. */
+ public PagedCallSettings.Builder<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings() {
+ return getStubSettingsBuilder().listGlossariesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getGlossary. */
+ public UnaryCallSettings.Builder getGlossarySettings() {
+ return getStubSettingsBuilder().getGlossarySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteGlossary. */
+ public UnaryCallSettings.Builder deleteGlossarySettings() {
+ return getStubSettingsBuilder().deleteGlossarySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteGlossary. */
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings() {
+ return getStubSettingsBuilder().deleteGlossaryOperationSettings();
+ }
+
+ @Override
+ public TranslationServiceSettings build() throws IOException {
+ return new TranslationServiceSettings(this);
+ }
+ }
+}
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
new file mode 100644
index 00000000..a12e6add
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A client to Cloud Translation API.
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
+ */
+@Generated("by gapic-generator")
+package com.google.cloud.translate.v3;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceCallableFactory.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceCallableFactory.java
new file mode 100644
index 00000000..b13a240c
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceCallableFactory.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC callable factory implementation for Cloud Translation API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator")
+@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+public class GrpcTranslationServiceCallableFactory implements GrpcStubCallableFactory {
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings pagedCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(
+ grpcCallSettings, pagedCallSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings batchingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, batchingCallSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings operationCallSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, operationCallSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings streamingCallSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, streamingCallSettings, clientContext);
+ }
+}
diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceStub.java
new file mode 100644
index 00000000..bd915e6d
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/GrpcTranslationServiceStub.java
@@ -0,0 +1,460 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3.stub;
+
+import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.RequestParamsExtractor;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.translate.v3.BatchTranslateMetadata;
+import com.google.cloud.translate.v3.BatchTranslateResponse;
+import com.google.cloud.translate.v3.BatchTranslateTextRequest;
+import com.google.cloud.translate.v3.CreateGlossaryMetadata;
+import com.google.cloud.translate.v3.CreateGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryMetadata;
+import com.google.cloud.translate.v3.DeleteGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryResponse;
+import com.google.cloud.translate.v3.DetectLanguageRequest;
+import com.google.cloud.translate.v3.DetectLanguageResponse;
+import com.google.cloud.translate.v3.GetGlossaryRequest;
+import com.google.cloud.translate.v3.GetSupportedLanguagesRequest;
+import com.google.cloud.translate.v3.Glossary;
+import com.google.cloud.translate.v3.ListGlossariesRequest;
+import com.google.cloud.translate.v3.ListGlossariesResponse;
+import com.google.cloud.translate.v3.SupportedLanguages;
+import com.google.cloud.translate.v3.TranslateTextRequest;
+import com.google.cloud.translate.v3.TranslateTextResponse;
+import com.google.common.collect.ImmutableMap;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * gRPC stub implementation for Cloud Translation API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public class GrpcTranslationServiceStub extends TranslationServiceStub {
+
+ private static final MethodDescriptor
+ translateTextMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateText")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(TranslateTextRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(TranslateTextResponse.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ detectLanguageMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/DetectLanguage")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(DetectLanguageRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(DetectLanguageResponse.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ getSupportedLanguagesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ "google.cloud.translation.v3.TranslationService/GetSupportedLanguages")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(GetSupportedLanguagesRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(SupportedLanguages.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ batchTranslateTextMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ "google.cloud.translation.v3.TranslationService/BatchTranslateText")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(BatchTranslateTextRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ createGlossaryMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateGlossary")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(CreateGlossaryRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ listGlossariesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/ListGlossaries")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ListGlossariesRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListGlossariesResponse.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor getGlossaryMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/GetGlossary")
+ .setRequestMarshaller(ProtoUtils.marshaller(GetGlossaryRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Glossary.getDefaultInstance()))
+ .build();
+ private static final MethodDescriptor
+ deleteGlossaryMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteGlossary")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(DeleteGlossaryRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+
+ private final UnaryCallable translateTextCallable;
+ private final UnaryCallable detectLanguageCallable;
+ private final UnaryCallable
+ getSupportedLanguagesCallable;
+ private final UnaryCallable batchTranslateTextCallable;
+ private final OperationCallable<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationCallable;
+ private final UnaryCallable createGlossaryCallable;
+ private final OperationCallable
+ createGlossaryOperationCallable;
+ private final UnaryCallable listGlossariesCallable;
+ private final UnaryCallable
+ listGlossariesPagedCallable;
+ private final UnaryCallable getGlossaryCallable;
+ private final UnaryCallable deleteGlossaryCallable;
+ private final OperationCallable<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationCallable;
+
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcTranslationServiceStub create(TranslationServiceStubSettings settings)
+ throws IOException {
+ return new GrpcTranslationServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcTranslationServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new GrpcTranslationServiceStub(
+ TranslationServiceStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcTranslationServiceStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcTranslationServiceStub(
+ TranslationServiceStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcTranslationServiceStub, using the given settings. This is
+ * protected so that it is easy to make a subclass, but otherwise, the static factory methods
+ * should be preferred.
+ */
+ protected GrpcTranslationServiceStub(
+ TranslationServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new GrpcTranslationServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcTranslationServiceStub, using the given settings. This is
+ * protected so that it is easy to make a subclass, but otherwise, the static factory methods
+ * should be preferred.
+ */
+ protected GrpcTranslationServiceStub(
+ TranslationServiceStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings translateTextTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(translateTextMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(TranslateTextRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings
+ detectLanguageTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(detectLanguageMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DetectLanguageRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings
+ getSupportedLanguagesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getSupportedLanguagesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetSupportedLanguagesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings batchTranslateTextTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(batchTranslateTextMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(BatchTranslateTextRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings createGlossaryTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createGlossaryMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(CreateGlossaryRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings
+ listGlossariesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(listGlossariesMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(ListGlossariesRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings getGlossaryTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getGlossaryMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(GetGlossaryRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
+ .build();
+ GrpcCallSettings deleteGlossaryTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(deleteGlossaryMethodDescriptor)
+ .setParamsExtractor(
+ new RequestParamsExtractor() {
+ @Override
+ public Map extract(DeleteGlossaryRequest request) {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ }
+ })
+ .build();
+
+ this.translateTextCallable =
+ callableFactory.createUnaryCallable(
+ translateTextTransportSettings, settings.translateTextSettings(), clientContext);
+ this.detectLanguageCallable =
+ callableFactory.createUnaryCallable(
+ detectLanguageTransportSettings, settings.detectLanguageSettings(), clientContext);
+ this.getSupportedLanguagesCallable =
+ callableFactory.createUnaryCallable(
+ getSupportedLanguagesTransportSettings,
+ settings.getSupportedLanguagesSettings(),
+ clientContext);
+ this.batchTranslateTextCallable =
+ callableFactory.createUnaryCallable(
+ batchTranslateTextTransportSettings,
+ settings.batchTranslateTextSettings(),
+ clientContext);
+ this.batchTranslateTextOperationCallable =
+ callableFactory.createOperationCallable(
+ batchTranslateTextTransportSettings,
+ settings.batchTranslateTextOperationSettings(),
+ clientContext,
+ this.operationsStub);
+ this.createGlossaryCallable =
+ callableFactory.createUnaryCallable(
+ createGlossaryTransportSettings, settings.createGlossarySettings(), clientContext);
+ this.createGlossaryOperationCallable =
+ callableFactory.createOperationCallable(
+ createGlossaryTransportSettings,
+ settings.createGlossaryOperationSettings(),
+ clientContext,
+ this.operationsStub);
+ this.listGlossariesCallable =
+ callableFactory.createUnaryCallable(
+ listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext);
+ this.listGlossariesPagedCallable =
+ callableFactory.createPagedCallable(
+ listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext);
+ this.getGlossaryCallable =
+ callableFactory.createUnaryCallable(
+ getGlossaryTransportSettings, settings.getGlossarySettings(), clientContext);
+ this.deleteGlossaryCallable =
+ callableFactory.createUnaryCallable(
+ deleteGlossaryTransportSettings, settings.deleteGlossarySettings(), clientContext);
+ this.deleteGlossaryOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteGlossaryTransportSettings,
+ settings.deleteGlossaryOperationSettings(),
+ clientContext,
+ this.operationsStub);
+
+ backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ public UnaryCallable translateTextCallable() {
+ return translateTextCallable;
+ }
+
+ public UnaryCallable detectLanguageCallable() {
+ return detectLanguageCallable;
+ }
+
+ public UnaryCallable
+ getSupportedLanguagesCallable() {
+ return getSupportedLanguagesCallable;
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationCallable() {
+ return batchTranslateTextOperationCallable;
+ }
+
+ public UnaryCallable batchTranslateTextCallable() {
+ return batchTranslateTextCallable;
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable
+ createGlossaryOperationCallable() {
+ return createGlossaryOperationCallable;
+ }
+
+ public UnaryCallable createGlossaryCallable() {
+ return createGlossaryCallable;
+ }
+
+ public UnaryCallable
+ listGlossariesPagedCallable() {
+ return listGlossariesPagedCallable;
+ }
+
+ public UnaryCallable listGlossariesCallable() {
+ return listGlossariesCallable;
+ }
+
+ public UnaryCallable getGlossaryCallable() {
+ return getGlossaryCallable;
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable
+ deleteGlossaryOperationCallable() {
+ return deleteGlossaryOperationCallable;
+ }
+
+ public UnaryCallable deleteGlossaryCallable() {
+ return deleteGlossaryCallable;
+ }
+
+ @Override
+ public final void close() {
+ shutdown();
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java
new file mode 100644
index 00000000..692a0739
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3.stub;
+
+import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.translate.v3.BatchTranslateMetadata;
+import com.google.cloud.translate.v3.BatchTranslateResponse;
+import com.google.cloud.translate.v3.BatchTranslateTextRequest;
+import com.google.cloud.translate.v3.CreateGlossaryMetadata;
+import com.google.cloud.translate.v3.CreateGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryMetadata;
+import com.google.cloud.translate.v3.DeleteGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryResponse;
+import com.google.cloud.translate.v3.DetectLanguageRequest;
+import com.google.cloud.translate.v3.DetectLanguageResponse;
+import com.google.cloud.translate.v3.GetGlossaryRequest;
+import com.google.cloud.translate.v3.GetSupportedLanguagesRequest;
+import com.google.cloud.translate.v3.Glossary;
+import com.google.cloud.translate.v3.ListGlossariesRequest;
+import com.google.cloud.translate.v3.ListGlossariesResponse;
+import com.google.cloud.translate.v3.SupportedLanguages;
+import com.google.cloud.translate.v3.TranslateTextRequest;
+import com.google.cloud.translate.v3.TranslateTextResponse;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Base stub class for Cloud Translation API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator")
+@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+public abstract class TranslationServiceStub implements BackgroundResource {
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ public UnaryCallable translateTextCallable() {
+ throw new UnsupportedOperationException("Not implemented: translateTextCallable()");
+ }
+
+ public UnaryCallable detectLanguageCallable() {
+ throw new UnsupportedOperationException("Not implemented: detectLanguageCallable()");
+ }
+
+ public UnaryCallable
+ getSupportedLanguagesCallable() {
+ throw new UnsupportedOperationException("Not implemented: getSupportedLanguagesCallable()");
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: batchTranslateTextOperationCallable()");
+ }
+
+ public UnaryCallable batchTranslateTextCallable() {
+ throw new UnsupportedOperationException("Not implemented: batchTranslateTextCallable()");
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable
+ createGlossaryOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: createGlossaryOperationCallable()");
+ }
+
+ public UnaryCallable createGlossaryCallable() {
+ throw new UnsupportedOperationException("Not implemented: createGlossaryCallable()");
+ }
+
+ public UnaryCallable
+ listGlossariesPagedCallable() {
+ throw new UnsupportedOperationException("Not implemented: listGlossariesPagedCallable()");
+ }
+
+ public UnaryCallable listGlossariesCallable() {
+ throw new UnsupportedOperationException("Not implemented: listGlossariesCallable()");
+ }
+
+ public UnaryCallable getGlossaryCallable() {
+ throw new UnsupportedOperationException("Not implemented: getGlossaryCallable()");
+ }
+
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallable
+ deleteGlossaryOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteGlossaryOperationCallable()");
+ }
+
+ public UnaryCallable deleteGlossaryCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteGlossaryCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java
new file mode 100644
index 00000000..fc33f594
--- /dev/null
+++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java
@@ -0,0 +1,688 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3.stub;
+
+import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.ApiFuture;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.GrpcTransportChannel;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.grpc.ProtoOperationTransformers;
+import com.google.api.gax.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiCallContext;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.PagedListDescriptor;
+import com.google.api.gax.rpc.PagedListResponseFactory;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.translate.v3.BatchTranslateMetadata;
+import com.google.cloud.translate.v3.BatchTranslateResponse;
+import com.google.cloud.translate.v3.BatchTranslateTextRequest;
+import com.google.cloud.translate.v3.CreateGlossaryMetadata;
+import com.google.cloud.translate.v3.CreateGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryMetadata;
+import com.google.cloud.translate.v3.DeleteGlossaryRequest;
+import com.google.cloud.translate.v3.DeleteGlossaryResponse;
+import com.google.cloud.translate.v3.DetectLanguageRequest;
+import com.google.cloud.translate.v3.DetectLanguageResponse;
+import com.google.cloud.translate.v3.GetGlossaryRequest;
+import com.google.cloud.translate.v3.GetSupportedLanguagesRequest;
+import com.google.cloud.translate.v3.Glossary;
+import com.google.cloud.translate.v3.ListGlossariesRequest;
+import com.google.cloud.translate.v3.ListGlossariesResponse;
+import com.google.cloud.translate.v3.SupportedLanguages;
+import com.google.cloud.translate.v3.TranslateTextRequest;
+import com.google.cloud.translate.v3.TranslateTextResponse;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS
+/**
+ * Settings class to configure an instance of {@link TranslationServiceStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (translate.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of translateText to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator")
+@BetaApi
+public class TranslationServiceStubSettings extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder()
+ .add("https://www.googleapis.com/auth/cloud-platform")
+ .add("https://www.googleapis.com/auth/cloud-translation")
+ .build();
+
+ private final UnaryCallSettings
+ translateTextSettings;
+ private final UnaryCallSettings
+ detectLanguageSettings;
+ private final UnaryCallSettings
+ getSupportedLanguagesSettings;
+ private final UnaryCallSettings batchTranslateTextSettings;
+ private final OperationCallSettings<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings;
+ private final UnaryCallSettings createGlossarySettings;
+ private final OperationCallSettings
+ createGlossaryOperationSettings;
+ private final PagedCallSettings<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings;
+ private final UnaryCallSettings getGlossarySettings;
+ private final UnaryCallSettings deleteGlossarySettings;
+ private final OperationCallSettings<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings;
+
+ /** Returns the object with the settings used for calls to translateText. */
+ public UnaryCallSettings translateTextSettings() {
+ return translateTextSettings;
+ }
+
+ /** Returns the object with the settings used for calls to detectLanguage. */
+ public UnaryCallSettings detectLanguageSettings() {
+ return detectLanguageSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getSupportedLanguages. */
+ public UnaryCallSettings
+ getSupportedLanguagesSettings() {
+ return getSupportedLanguagesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to batchTranslateText. */
+ public UnaryCallSettings batchTranslateTextSettings() {
+ return batchTranslateTextSettings;
+ }
+
+ /** Returns the object with the settings used for calls to batchTranslateText. */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings() {
+ return batchTranslateTextOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to createGlossary. */
+ public UnaryCallSettings createGlossarySettings() {
+ return createGlossarySettings;
+ }
+
+ /** Returns the object with the settings used for calls to createGlossary. */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings
+ createGlossaryOperationSettings() {
+ return createGlossaryOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to listGlossaries. */
+ public PagedCallSettings<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings() {
+ return listGlossariesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getGlossary. */
+ public UnaryCallSettings getGlossarySettings() {
+ return getGlossarySettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteGlossary. */
+ public UnaryCallSettings deleteGlossarySettings() {
+ return deleteGlossarySettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteGlossary. */
+ @BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings() {
+ return deleteGlossaryOperationSettings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public TranslationServiceStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcTranslationServiceStub.create(this);
+ } else {
+ throw new UnsupportedOperationException(
+ "Transport not supported: " + getTransportChannelProvider().getTransportName());
+ }
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "translate.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return defaultGrpcTransportProviderBuilder().build();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(TranslationServiceStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected TranslationServiceStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ translateTextSettings = settingsBuilder.translateTextSettings().build();
+ detectLanguageSettings = settingsBuilder.detectLanguageSettings().build();
+ getSupportedLanguagesSettings = settingsBuilder.getSupportedLanguagesSettings().build();
+ batchTranslateTextSettings = settingsBuilder.batchTranslateTextSettings().build();
+ batchTranslateTextOperationSettings =
+ settingsBuilder.batchTranslateTextOperationSettings().build();
+ createGlossarySettings = settingsBuilder.createGlossarySettings().build();
+ createGlossaryOperationSettings = settingsBuilder.createGlossaryOperationSettings().build();
+ listGlossariesSettings = settingsBuilder.listGlossariesSettings().build();
+ getGlossarySettings = settingsBuilder.getGlossarySettings().build();
+ deleteGlossarySettings = settingsBuilder.deleteGlossarySettings().build();
+ deleteGlossaryOperationSettings = settingsBuilder.deleteGlossaryOperationSettings().build();
+ }
+
+ private static final PagedListDescriptor
+ LIST_GLOSSARIES_PAGE_STR_DESC =
+ new PagedListDescriptor() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListGlossariesRequest injectToken(ListGlossariesRequest payload, String token) {
+ return ListGlossariesRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListGlossariesRequest injectPageSize(
+ ListGlossariesRequest payload, int pageSize) {
+ return ListGlossariesRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListGlossariesRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListGlossariesResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(ListGlossariesResponse payload) {
+ return payload.getGlossariesList() != null
+ ? payload.getGlossariesList()
+ : ImmutableList.of();
+ }
+ };
+
+ private static final PagedListResponseFactory<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ LIST_GLOSSARIES_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListGlossariesRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext pageContext =
+ PageContext.create(callable, LIST_GLOSSARIES_PAGE_STR_DESC, request, context);
+ return ListGlossariesPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
+ /** Builder for TranslationServiceStubSettings. */
+ public static class Builder
+ extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+
+ private final UnaryCallSettings.Builder
+ translateTextSettings;
+ private final UnaryCallSettings.Builder
+ detectLanguageSettings;
+ private final UnaryCallSettings.Builder
+ getSupportedLanguagesSettings;
+ private final UnaryCallSettings.Builder
+ batchTranslateTextSettings;
+ private final OperationCallSettings.Builder<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings;
+ private final UnaryCallSettings.Builder
+ createGlossarySettings;
+ private final OperationCallSettings.Builder<
+ CreateGlossaryRequest, Glossary, CreateGlossaryMetadata>
+ createGlossaryOperationSettings;
+ private final PagedCallSettings.Builder<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings;
+ private final UnaryCallSettings.Builder getGlossarySettings;
+ private final UnaryCallSettings.Builder
+ deleteGlossarySettings;
+ private final OperationCallSettings.Builder<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings;
+
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "idempotent",
+ ImmutableSet.copyOf(
+ Lists.newArrayList(
+ StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
+ definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList()));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(100L))
+ .setRetryDelayMultiplier(1.3)
+ .setMaxRetryDelay(Duration.ofMillis(60000L))
+ .setInitialRpcTimeout(Duration.ofMillis(20000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(20000L))
+ .setTotalTimeout(Duration.ofMillis(600000L))
+ .build();
+ definitions.put("default", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this((ClientContext) null);
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ translateTextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ detectLanguageSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ getSupportedLanguagesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ batchTranslateTextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ batchTranslateTextOperationSettings = OperationCallSettings.newBuilder();
+
+ createGlossarySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ createGlossaryOperationSettings = OperationCallSettings.newBuilder();
+
+ listGlossariesSettings = PagedCallSettings.newBuilder(LIST_GLOSSARIES_PAGE_STR_FACT);
+
+ getGlossarySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ deleteGlossarySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ deleteGlossaryOperationSettings = OperationCallSettings.newBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ translateTextSettings,
+ detectLanguageSettings,
+ getSupportedLanguagesSettings,
+ batchTranslateTextSettings,
+ createGlossarySettings,
+ listGlossariesSettings,
+ getGlossarySettings,
+ deleteGlossarySettings);
+
+ initDefaults(this);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder((ClientContext) null);
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+
+ builder
+ .translateTextSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .detectLanguageSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .getSupportedLanguagesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .batchTranslateTextSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .createGlossarySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .listGlossariesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .getGlossarySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
+ builder
+ .deleteGlossarySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+ builder
+ .batchTranslateTextOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(BatchTranslateResponse.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(BatchTranslateMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(500L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(5000L))
+ .setInitialRpcTimeout(Duration.ZERO) // ignored
+ .setRpcTimeoutMultiplier(1.0) // ignored
+ .setMaxRpcTimeout(Duration.ZERO) // ignored
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+ builder
+ .createGlossaryOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Glossary.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(CreateGlossaryMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(500L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(5000L))
+ .setInitialRpcTimeout(Duration.ZERO) // ignored
+ .setRpcTimeoutMultiplier(1.0) // ignored
+ .setMaxRpcTimeout(Duration.ZERO) // ignored
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+ builder
+ .deleteGlossaryOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(DeleteGlossaryResponse.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(DeleteGlossaryMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(500L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(5000L))
+ .setInitialRpcTimeout(Duration.ZERO) // ignored
+ .setRpcTimeoutMultiplier(1.0) // ignored
+ .setMaxRpcTimeout(Duration.ZERO) // ignored
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ return builder;
+ }
+
+ protected Builder(TranslationServiceStubSettings settings) {
+ super(settings);
+
+ translateTextSettings = settings.translateTextSettings.toBuilder();
+ detectLanguageSettings = settings.detectLanguageSettings.toBuilder();
+ getSupportedLanguagesSettings = settings.getSupportedLanguagesSettings.toBuilder();
+ batchTranslateTextSettings = settings.batchTranslateTextSettings.toBuilder();
+ batchTranslateTextOperationSettings =
+ settings.batchTranslateTextOperationSettings.toBuilder();
+ createGlossarySettings = settings.createGlossarySettings.toBuilder();
+ createGlossaryOperationSettings = settings.createGlossaryOperationSettings.toBuilder();
+ listGlossariesSettings = settings.listGlossariesSettings.toBuilder();
+ getGlossarySettings = settings.getGlossarySettings.toBuilder();
+ deleteGlossarySettings = settings.deleteGlossarySettings.toBuilder();
+ deleteGlossaryOperationSettings = settings.deleteGlossaryOperationSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ translateTextSettings,
+ detectLanguageSettings,
+ getSupportedLanguagesSettings,
+ batchTranslateTextSettings,
+ createGlossarySettings,
+ listGlossariesSettings,
+ getGlossarySettings,
+ deleteGlossarySettings);
+ }
+
+ // NEXT_MAJOR_VER: remove 'throws Exception'
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) throws Exception {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to translateText. */
+ public UnaryCallSettings.Builder
+ translateTextSettings() {
+ return translateTextSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to detectLanguage. */
+ public UnaryCallSettings.Builder
+ detectLanguageSettings() {
+ return detectLanguageSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getSupportedLanguages. */
+ public UnaryCallSettings.Builder
+ getSupportedLanguagesSettings() {
+ return getSupportedLanguagesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to batchTranslateText. */
+ public UnaryCallSettings.Builder
+ batchTranslateTextSettings() {
+ return batchTranslateTextSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to batchTranslateText. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
+ batchTranslateTextOperationSettings() {
+ return batchTranslateTextOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createGlossary. */
+ public UnaryCallSettings.Builder createGlossarySettings() {
+ return createGlossarySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createGlossary. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ createGlossaryOperationSettings() {
+ return createGlossaryOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to listGlossaries. */
+ public PagedCallSettings.Builder<
+ ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
+ listGlossariesSettings() {
+ return listGlossariesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getGlossary. */
+ public UnaryCallSettings.Builder getGlossarySettings() {
+ return getGlossarySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteGlossary. */
+ public UnaryCallSettings.Builder deleteGlossarySettings() {
+ return deleteGlossarySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteGlossary. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
+ deleteGlossaryOperationSettings() {
+ return deleteGlossaryOperationSettings;
+ }
+
+ @Override
+ public TranslationServiceStubSettings build() throws IOException {
+ return new TranslationServiceStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationService.java b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationService.java
new file mode 100644
index 00000000..e88269e3
--- /dev/null
+++ b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationService.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+
+@javax.annotation.Generated("by GAPIC")
+@BetaApi
+public class MockTranslationService implements MockGrpcService {
+ private final MockTranslationServiceImpl serviceImpl;
+
+ public MockTranslationService() {
+ serviceImpl = new MockTranslationServiceImpl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void addResponse(AbstractMessage response) {
+ serviceImpl.addResponse(response);
+ }
+
+ @Override
+ public void addException(Exception exception) {
+ serviceImpl.addException(exception);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationServiceImpl.java b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationServiceImpl.java
new file mode 100644
index 00000000..63d4b1f4
--- /dev/null
+++ b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/MockTranslationServiceImpl.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.translate.v3;
+
+import com.google.api.core.BetaApi;
+import com.google.cloud.translate.v3.TranslationServiceGrpc.TranslationServiceImplBase;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+@javax.annotation.Generated("by GAPIC")
+@BetaApi
+public class MockTranslationServiceImpl extends TranslationServiceImplBase {
+ private List requests;
+ private Queue