• 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.texttospeech.v1;
18 
19 import com.google.api.core.ApiFunction;
20 import com.google.api.core.BetaApi;
21 import com.google.api.gax.core.GoogleCredentialsProvider;
22 import com.google.api.gax.core.InstantiatingExecutorProvider;
23 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
24 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
25 import com.google.api.gax.rpc.ApiClientHeaderProvider;
26 import com.google.api.gax.rpc.ClientContext;
27 import com.google.api.gax.rpc.ClientSettings;
28 import com.google.api.gax.rpc.TransportChannelProvider;
29 import com.google.api.gax.rpc.UnaryCallSettings;
30 import com.google.cloud.texttospeech.v1.stub.TextToSpeechStubSettings;
31 import java.io.IOException;
32 import java.util.List;
33 import javax.annotation.Generated;
34 
35 // AUTO-GENERATED DOCUMENTATION AND CLASS.
36 /**
37  * Settings class to configure an instance of {@link TextToSpeechClient}.
38  *
39  * <p>The default instance has everything set to sensible defaults:
40  *
41  * <ul>
42  *   <li>The default service address (texttospeech.googleapis.com) and default port (443) are used.
43  *   <li>Credentials are acquired automatically through Application Default Credentials.
44  *   <li>Retries are configured for idempotent methods but not for non-idempotent methods.
45  * </ul>
46  *
47  * <p>The builder of this class is recursive, so contained classes are themselves builders. When
48  * build() is called, the tree of builders is called to create the complete settings object.
49  *
50  * <p>For example, to set the total timeout of listVoices to 30 seconds:
51  *
52  * <pre>{@code
53  * // This snippet has been automatically generated and should be regarded as a code template only.
54  * // It will require modifications to work:
55  * // - It may require correct/in-range values for request initialization.
56  * // - It may require specifying regional endpoints when creating the service client as shown in
57  * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
58  * TextToSpeechSettings.Builder textToSpeechSettingsBuilder = TextToSpeechSettings.newBuilder();
59  * textToSpeechSettingsBuilder
60  *     .listVoicesSettings()
61  *     .setRetrySettings(
62  *         textToSpeechSettingsBuilder
63  *             .listVoicesSettings()
64  *             .getRetrySettings()
65  *             .toBuilder()
66  *             .setTotalTimeout(Duration.ofSeconds(30))
67  *             .build());
68  * TextToSpeechSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
69  * }</pre>
70  */
71 @Generated("by gapic-generator-java")
72 public class TextToSpeechSettings extends ClientSettings<TextToSpeechSettings> {
73 
74   /** Returns the object with the settings used for calls to listVoices. */
listVoicesSettings()75   public UnaryCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
76     return ((TextToSpeechStubSettings) getStubSettings()).listVoicesSettings();
77   }
78 
79   /** Returns the object with the settings used for calls to synthesizeSpeech. */
80   public UnaryCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechSettings()81       synthesizeSpeechSettings() {
82     return ((TextToSpeechStubSettings) getStubSettings()).synthesizeSpeechSettings();
83   }
84 
create(TextToSpeechStubSettings stub)85   public static final TextToSpeechSettings create(TextToSpeechStubSettings stub)
86       throws IOException {
87     return new TextToSpeechSettings.Builder(stub.toBuilder()).build();
88   }
89 
90   /** Returns a builder for the default ExecutorProvider for this service. */
defaultExecutorProviderBuilder()91   public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
92     return TextToSpeechStubSettings.defaultExecutorProviderBuilder();
93   }
94 
95   /** Returns the default service endpoint. */
getDefaultEndpoint()96   public static String getDefaultEndpoint() {
97     return TextToSpeechStubSettings.getDefaultEndpoint();
98   }
99 
100   /** Returns the default service scopes. */
getDefaultServiceScopes()101   public static List<String> getDefaultServiceScopes() {
102     return TextToSpeechStubSettings.getDefaultServiceScopes();
103   }
104 
105   /** Returns a builder for the default credentials for this service. */
defaultCredentialsProviderBuilder()106   public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
107     return TextToSpeechStubSettings.defaultCredentialsProviderBuilder();
108   }
109 
110   /** Returns a builder for the default gRPC ChannelProvider for this service. */
defaultGrpcTransportProviderBuilder()111   public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
112     return TextToSpeechStubSettings.defaultGrpcTransportProviderBuilder();
113   }
114 
115   /** Returns a builder for the default REST ChannelProvider for this service. */
116   @BetaApi
117   public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder()118       defaultHttpJsonTransportProviderBuilder() {
119     return TextToSpeechStubSettings.defaultHttpJsonTransportProviderBuilder();
120   }
121 
defaultTransportChannelProvider()122   public static TransportChannelProvider defaultTransportChannelProvider() {
123     return TextToSpeechStubSettings.defaultTransportChannelProvider();
124   }
125 
126   @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
defaultApiClientHeaderProviderBuilder()127   public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
128     return TextToSpeechStubSettings.defaultApiClientHeaderProviderBuilder();
129   }
130 
131   /** Returns a new gRPC builder for this class. */
newBuilder()132   public static Builder newBuilder() {
133     return Builder.createDefault();
134   }
135 
136   /** Returns a new REST builder for this class. */
137   @BetaApi
newHttpJsonBuilder()138   public static Builder newHttpJsonBuilder() {
139     return Builder.createHttpJsonDefault();
140   }
141 
142   /** Returns a new builder for this class. */
newBuilder(ClientContext clientContext)143   public static Builder newBuilder(ClientContext clientContext) {
144     return new Builder(clientContext);
145   }
146 
147   /** Returns a builder containing all the values of this settings class. */
toBuilder()148   public Builder toBuilder() {
149     return new Builder(this);
150   }
151 
TextToSpeechSettings(Builder settingsBuilder)152   protected TextToSpeechSettings(Builder settingsBuilder) throws IOException {
153     super(settingsBuilder);
154   }
155 
156   /** Builder for TextToSpeechSettings. */
157   public static class Builder extends ClientSettings.Builder<TextToSpeechSettings, Builder> {
158 
Builder()159     protected Builder() throws IOException {
160       this(((ClientContext) null));
161     }
162 
Builder(ClientContext clientContext)163     protected Builder(ClientContext clientContext) {
164       super(TextToSpeechStubSettings.newBuilder(clientContext));
165     }
166 
Builder(TextToSpeechSettings settings)167     protected Builder(TextToSpeechSettings settings) {
168       super(settings.getStubSettings().toBuilder());
169     }
170 
Builder(TextToSpeechStubSettings.Builder stubSettings)171     protected Builder(TextToSpeechStubSettings.Builder stubSettings) {
172       super(stubSettings);
173     }
174 
createDefault()175     private static Builder createDefault() {
176       return new Builder(TextToSpeechStubSettings.newBuilder());
177     }
178 
179     @BetaApi
createHttpJsonDefault()180     private static Builder createHttpJsonDefault() {
181       return new Builder(TextToSpeechStubSettings.newHttpJsonBuilder());
182     }
183 
getStubSettingsBuilder()184     public TextToSpeechStubSettings.Builder getStubSettingsBuilder() {
185       return ((TextToSpeechStubSettings.Builder) getStubSettings());
186     }
187 
188     /**
189      * Applies the given settings updater function to all of the unary API methods in this service.
190      *
191      * <p>Note: This method does not support applying settings to streaming methods.
192      */
applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)193     public Builder applyToAllUnaryMethods(
194         ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
195       super.applyToAllUnaryMethods(
196           getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
197       return this;
198     }
199 
200     /** Returns the builder for the settings used for calls to listVoices. */
listVoicesSettings()201     public UnaryCallSettings.Builder<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
202       return getStubSettingsBuilder().listVoicesSettings();
203     }
204 
205     /** Returns the builder for the settings used for calls to synthesizeSpeech. */
206     public UnaryCallSettings.Builder<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechSettings()207         synthesizeSpeechSettings() {
208       return getStubSettingsBuilder().synthesizeSpeechSettings();
209     }
210 
211     @Override
build()212     public TextToSpeechSettings build() throws IOException {
213       return new TextToSpeechSettings(this);
214     }
215   }
216 }
217