• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.cloud.translate.v3;
18 
19 import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
20 
21 import com.google.api.core.ApiFunction;
22 import com.google.api.core.BetaApi;
23 import com.google.api.gax.core.GoogleCredentialsProvider;
24 import com.google.api.gax.core.InstantiatingExecutorProvider;
25 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
26 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
27 import com.google.api.gax.rpc.ApiClientHeaderProvider;
28 import com.google.api.gax.rpc.ClientContext;
29 import com.google.api.gax.rpc.ClientSettings;
30 import com.google.api.gax.rpc.OperationCallSettings;
31 import com.google.api.gax.rpc.PagedCallSettings;
32 import com.google.api.gax.rpc.TransportChannelProvider;
33 import com.google.api.gax.rpc.UnaryCallSettings;
34 import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings;
35 import com.google.longrunning.Operation;
36 import java.io.IOException;
37 import java.util.List;
38 import javax.annotation.Generated;
39 
40 // AUTO-GENERATED DOCUMENTATION AND CLASS.
41 /**
42  * Settings class to configure an instance of {@link TranslationServiceClient}.
43  *
44  * <p>The default instance has everything set to sensible defaults:
45  *
46  * <ul>
47  *   <li>The default service address (translate.googleapis.com) and default port (443) are used.
48  *   <li>Credentials are acquired automatically through Application Default Credentials.
49  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
50  * </ul>
51  *
52  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
53  * build() is called, the tree of builders is called to create the complete settings object.
54  *
55  * <p>For example, to set the total timeout of translateText to 30 seconds:
56  *
57  * <pre>{@code
58  * // This snippet has been automatically generated and should be regarded as a code template only.
59  * // It will require modifications to work:
60  * // - It may require correct/in-range values for request initialization.
61  * // - It may require specifying regional endpoints when creating the service client as shown in
62  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
63  * TranslationServiceSettings.Builder translationServiceSettingsBuilder =
64  *     TranslationServiceSettings.newBuilder();
65  * translationServiceSettingsBuilder
66  *     .translateTextSettings()
67  *     .setRetrySettings(
68  *         translationServiceSettingsBuilder
69  *             .translateTextSettings()
70  *             .getRetrySettings()
71  *             .toBuilder()
72  *             .setTotalTimeout(Duration.ofSeconds(30))
73  *             .build());
74  * TranslationServiceSettings translationServiceSettings =
75  *     translationServiceSettingsBuilder.build();
76  * }</pre>
77  */
78 @Generated("by gapic-generator-java")
79 public class TranslationServiceSettings extends ClientSettings<TranslationServiceSettings> {
80 
81   /** Returns the object with the settings used for calls to translateText. */
translateTextSettings()82   public UnaryCallSettings<TranslateTextRequest, TranslateTextResponse> translateTextSettings() {
83     return ((TranslationServiceStubSettings) getStubSettings()).translateTextSettings();
84   }
85 
86   /** Returns the object with the settings used for calls to detectLanguage. */
detectLanguageSettings()87   public UnaryCallSettings<DetectLanguageRequest, DetectLanguageResponse> detectLanguageSettings() {
88     return ((TranslationServiceStubSettings) getStubSettings()).detectLanguageSettings();
89   }
90 
91   /** Returns the object with the settings used for calls to getSupportedLanguages. */
92   public UnaryCallSettings<GetSupportedLanguagesRequest, SupportedLanguages>
getSupportedLanguagesSettings()93       getSupportedLanguagesSettings() {
94     return ((TranslationServiceStubSettings) getStubSettings()).getSupportedLanguagesSettings();
95   }
96 
97   /** Returns the object with the settings used for calls to translateDocument. */
98   public UnaryCallSettings<TranslateDocumentRequest, TranslateDocumentResponse>
translateDocumentSettings()99       translateDocumentSettings() {
100     return ((TranslationServiceStubSettings) getStubSettings()).translateDocumentSettings();
101   }
102 
103   /** Returns the object with the settings used for calls to batchTranslateText. */
batchTranslateTextSettings()104   public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTextSettings() {
105     return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateTextSettings();
106   }
107 
108   /** Returns the object with the settings used for calls to batchTranslateText. */
109   public OperationCallSettings<
110           BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
batchTranslateTextOperationSettings()111       batchTranslateTextOperationSettings() {
112     return ((TranslationServiceStubSettings) getStubSettings())
113         .batchTranslateTextOperationSettings();
114   }
115 
116   /** Returns the object with the settings used for calls to batchTranslateDocument. */
117   public UnaryCallSettings<BatchTranslateDocumentRequest, Operation>
batchTranslateDocumentSettings()118       batchTranslateDocumentSettings() {
119     return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateDocumentSettings();
120   }
121 
122   /** Returns the object with the settings used for calls to batchTranslateDocument. */
123   public OperationCallSettings<
124           BatchTranslateDocumentRequest,
125           BatchTranslateDocumentResponse,
126           BatchTranslateDocumentMetadata>
batchTranslateDocumentOperationSettings()127       batchTranslateDocumentOperationSettings() {
128     return ((TranslationServiceStubSettings) getStubSettings())
129         .batchTranslateDocumentOperationSettings();
130   }
131 
132   /** Returns the object with the settings used for calls to createGlossary. */
createGlossarySettings()133   public UnaryCallSettings<CreateGlossaryRequest, Operation> createGlossarySettings() {
134     return ((TranslationServiceStubSettings) getStubSettings()).createGlossarySettings();
135   }
136 
137   /** Returns the object with the settings used for calls to createGlossary. */
138   public OperationCallSettings<CreateGlossaryRequest, Glossary, CreateGlossaryMetadata>
createGlossaryOperationSettings()139       createGlossaryOperationSettings() {
140     return ((TranslationServiceStubSettings) getStubSettings()).createGlossaryOperationSettings();
141   }
142 
143   /** Returns the object with the settings used for calls to listGlossaries. */
144   public PagedCallSettings<
145           ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
listGlossariesSettings()146       listGlossariesSettings() {
147     return ((TranslationServiceStubSettings) getStubSettings()).listGlossariesSettings();
148   }
149 
150   /** Returns the object with the settings used for calls to getGlossary. */
getGlossarySettings()151   public UnaryCallSettings<GetGlossaryRequest, Glossary> getGlossarySettings() {
152     return ((TranslationServiceStubSettings) getStubSettings()).getGlossarySettings();
153   }
154 
155   /** Returns the object with the settings used for calls to deleteGlossary. */
deleteGlossarySettings()156   public UnaryCallSettings<DeleteGlossaryRequest, Operation> deleteGlossarySettings() {
157     return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossarySettings();
158   }
159 
160   /** Returns the object with the settings used for calls to deleteGlossary. */
161   public OperationCallSettings<
162           DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
deleteGlossaryOperationSettings()163       deleteGlossaryOperationSettings() {
164     return ((TranslationServiceStubSettings) getStubSettings()).deleteGlossaryOperationSettings();
165   }
166 
create(TranslationServiceStubSettings stub)167   public static final TranslationServiceSettings create(TranslationServiceStubSettings stub)
168       throws IOException {
169     return new TranslationServiceSettings.Builder(stub.toBuilder()).build();
170   }
171 
172   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()173   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
174     return TranslationServiceStubSettings.defaultExecutorProviderBuilder();
175   }
176 
177   /** Returns the default service endpoint. */
getDefaultEndpoint()178   public static String getDefaultEndpoint() {
179     return TranslationServiceStubSettings.getDefaultEndpoint();
180   }
181 
182   /** Returns the default service scopes. */
getDefaultServiceScopes()183   public static List<String> getDefaultServiceScopes() {
184     return TranslationServiceStubSettings.getDefaultServiceScopes();
185   }
186 
187   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()188   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
189     return TranslationServiceStubSettings.defaultCredentialsProviderBuilder();
190   }
191 
192   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()193   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
194     return TranslationServiceStubSettings.defaultGrpcTransportProviderBuilder();
195   }
196 
197   /** Returns a builder for the default REST ChannelProvider for this service. */
198   @BetaApi
199   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()200       defaultHttpJsonTransportProviderBuilder() {
201     return TranslationServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
202   }
203 
defaultTransportChannelProvider()204   public static TransportChannelProvider defaultTransportChannelProvider() {
205     return TranslationServiceStubSettings.defaultTransportChannelProvider();
206   }
207 
208   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()209   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
210     return TranslationServiceStubSettings.defaultApiClientHeaderProviderBuilder();
211   }
212 
213   /** Returns a new gRPC builder for this class. */
newBuilder()214   public static Builder newBuilder() {
215     return Builder.createDefault();
216   }
217 
218   /** Returns a new REST builder for this class. */
219   @BetaApi
newHttpJsonBuilder()220   public static Builder newHttpJsonBuilder() {
221     return Builder.createHttpJsonDefault();
222   }
223 
224   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)225   public static Builder newBuilder(ClientContext clientContext) {
226     return new Builder(clientContext);
227   }
228 
229   /** Returns a builder containing all the values of this settings class. */
toBuilder()230   public Builder toBuilder() {
231     return new Builder(this);
232   }
233 
TranslationServiceSettings(Builder settingsBuilder)234   protected TranslationServiceSettings(Builder settingsBuilder) throws IOException {
235     super(settingsBuilder);
236   }
237 
238   /** Builder for TranslationServiceSettings. */
239   public static class Builder extends ClientSettings.Builder<TranslationServiceSettings, Builder> {
240 
Builder()241     protected Builder() throws IOException {
242       this(((ClientContext) null));
243     }
244 
Builder(ClientContext clientContext)245     protected Builder(ClientContext clientContext) {
246       super(TranslationServiceStubSettings.newBuilder(clientContext));
247     }
248 
Builder(TranslationServiceSettings settings)249     protected Builder(TranslationServiceSettings settings) {
250       super(settings.getStubSettings().toBuilder());
251     }
252 
Builder(TranslationServiceStubSettings.Builder stubSettings)253     protected Builder(TranslationServiceStubSettings.Builder stubSettings) {
254       super(stubSettings);
255     }
256 
createDefault()257     private static Builder createDefault() {
258       return new Builder(TranslationServiceStubSettings.newBuilder());
259     }
260 
261     @BetaApi
createHttpJsonDefault()262     private static Builder createHttpJsonDefault() {
263       return new Builder(TranslationServiceStubSettings.newHttpJsonBuilder());
264     }
265 
getStubSettingsBuilder()266     public TranslationServiceStubSettings.Builder getStubSettingsBuilder() {
267       return ((TranslationServiceStubSettings.Builder) getStubSettings());
268     }
269 
270     /**
271      * Applies the given settings updater function to all of the unary API methods in this service.
272      *
273      * <p>Note: This method does not support applying settings to streaming methods.
274      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)275     public Builder applyToAllUnaryMethods(
276         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
277       super.applyToAllUnaryMethods(
278           getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
279       return this;
280     }
281 
282     /** Returns the builder for the settings used for calls to translateText. */
283     public UnaryCallSettings.Builder<TranslateTextRequest, TranslateTextResponse>
translateTextSettings()284         translateTextSettings() {
285       return getStubSettingsBuilder().translateTextSettings();
286     }
287 
288     /** Returns the builder for the settings used for calls to detectLanguage. */
289     public UnaryCallSettings.Builder<DetectLanguageRequest, DetectLanguageResponse>
detectLanguageSettings()290         detectLanguageSettings() {
291       return getStubSettingsBuilder().detectLanguageSettings();
292     }
293 
294     /** Returns the builder for the settings used for calls to getSupportedLanguages. */
295     public UnaryCallSettings.Builder<GetSupportedLanguagesRequest, SupportedLanguages>
getSupportedLanguagesSettings()296         getSupportedLanguagesSettings() {
297       return getStubSettingsBuilder().getSupportedLanguagesSettings();
298     }
299 
300     /** Returns the builder for the settings used for calls to translateDocument. */
301     public UnaryCallSettings.Builder<TranslateDocumentRequest, TranslateDocumentResponse>
translateDocumentSettings()302         translateDocumentSettings() {
303       return getStubSettingsBuilder().translateDocumentSettings();
304     }
305 
306     /** Returns the builder for the settings used for calls to batchTranslateText. */
307     public UnaryCallSettings.Builder<BatchTranslateTextRequest, Operation>
batchTranslateTextSettings()308         batchTranslateTextSettings() {
309       return getStubSettingsBuilder().batchTranslateTextSettings();
310     }
311 
312     /** Returns the builder for the settings used for calls to batchTranslateText. */
313     public OperationCallSettings.Builder<
314             BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata>
batchTranslateTextOperationSettings()315         batchTranslateTextOperationSettings() {
316       return getStubSettingsBuilder().batchTranslateTextOperationSettings();
317     }
318 
319     /** Returns the builder for the settings used for calls to batchTranslateDocument. */
320     public UnaryCallSettings.Builder<BatchTranslateDocumentRequest, Operation>
batchTranslateDocumentSettings()321         batchTranslateDocumentSettings() {
322       return getStubSettingsBuilder().batchTranslateDocumentSettings();
323     }
324 
325     /** Returns the builder for the settings used for calls to batchTranslateDocument. */
326     public OperationCallSettings.Builder<
327             BatchTranslateDocumentRequest,
328             BatchTranslateDocumentResponse,
329             BatchTranslateDocumentMetadata>
batchTranslateDocumentOperationSettings()330         batchTranslateDocumentOperationSettings() {
331       return getStubSettingsBuilder().batchTranslateDocumentOperationSettings();
332     }
333 
334     /** Returns the builder for the settings used for calls to createGlossary. */
createGlossarySettings()335     public UnaryCallSettings.Builder<CreateGlossaryRequest, Operation> createGlossarySettings() {
336       return getStubSettingsBuilder().createGlossarySettings();
337     }
338 
339     /** Returns the builder for the settings used for calls to createGlossary. */
340     public OperationCallSettings.Builder<CreateGlossaryRequest, Glossary, CreateGlossaryMetadata>
createGlossaryOperationSettings()341         createGlossaryOperationSettings() {
342       return getStubSettingsBuilder().createGlossaryOperationSettings();
343     }
344 
345     /** Returns the builder for the settings used for calls to listGlossaries. */
346     public PagedCallSettings.Builder<
347             ListGlossariesRequest, ListGlossariesResponse, ListGlossariesPagedResponse>
listGlossariesSettings()348         listGlossariesSettings() {
349       return getStubSettingsBuilder().listGlossariesSettings();
350     }
351 
352     /** Returns the builder for the settings used for calls to getGlossary. */
getGlossarySettings()353     public UnaryCallSettings.Builder<GetGlossaryRequest, Glossary> getGlossarySettings() {
354       return getStubSettingsBuilder().getGlossarySettings();
355     }
356 
357     /** Returns the builder for the settings used for calls to deleteGlossary. */
deleteGlossarySettings()358     public UnaryCallSettings.Builder<DeleteGlossaryRequest, Operation> deleteGlossarySettings() {
359       return getStubSettingsBuilder().deleteGlossarySettings();
360     }
361 
362     /** Returns the builder for the settings used for calls to deleteGlossary. */
363     public OperationCallSettings.Builder<
364             DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata>
deleteGlossaryOperationSettings()365         deleteGlossaryOperationSettings() {
366       return getStubSettingsBuilder().deleteGlossaryOperationSettings();
367     }
368 
369     @Override
build()370     public TranslationServiceSettings build() throws IOException {
371       return new TranslationServiceSettings(this);
372     }
373   }
374 }
375