Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 94644ec

Browse files
fix: migrate retry settings to grpc_service_config (#177)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/8090a8db-78af-43ce-903e-cbc4378c9d99/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 317110345 Source-Link: googleapis/googleapis@bccd840 PiperOrigin-RevId: 317109450 Source-Link: googleapis/googleapis@7b21d44
1 parent 093cbc1 commit 94644ec

16 files changed

+346
-350
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
1717
<dependency>
1818
<groupId>com.google.cloud</groupId>
1919
<artifactId>libraries-bom</artifactId>
20-
<version>5.7.0</version>
20+
<version>7.0.0</version>
2121
<type>pom</type>
2222
<scope>import</scope>
2323
</dependency>

google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechClient.java

+69-71
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
* <pre>
3535
* <code>
3636
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
37-
* SynthesisInput input = SynthesisInput.newBuilder().build();
38-
* VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
39-
* AudioConfig audioConfig = AudioConfig.newBuilder().build();
40-
* SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
37+
* String languageCode = "";
38+
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
4139
* }
4240
* </code>
4341
* </pre>
@@ -145,6 +143,73 @@ public TextToSpeechStub getStub() {
145143
return stub;
146144
}
147145

146+
// AUTO-GENERATED DOCUMENTATION AND METHOD
147+
/**
148+
* Returns a list of Voice supported for synthesis.
149+
*
150+
* <p>Sample code:
151+
*
152+
* <pre><code>
153+
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
154+
* String languageCode = "";
155+
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
156+
* }
157+
* </code></pre>
158+
*
159+
* @param languageCode Optional. Recommended.
160+
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If specified, the
161+
* ListVoices call will only return voices that can be used to synthesize this language_code.
162+
* E.g. when specifying "en-NZ", you will get supported "en-&#42;" voices; when specifying
163+
* "no", you will get supported "no-&#42;" (Norwegian) and "nb-&#42;" (Norwegian Bokmal)
164+
* voices; specifying "zh" will also get supported "cmn-&#42;" voices; specifying "zh-hk" will
165+
* also get supported "yue-&#42;" voices.
166+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
167+
*/
168+
public final ListVoicesResponse listVoices(String languageCode) {
169+
ListVoicesRequest request =
170+
ListVoicesRequest.newBuilder().setLanguageCode(languageCode).build();
171+
return listVoices(request);
172+
}
173+
174+
// AUTO-GENERATED DOCUMENTATION AND METHOD
175+
/**
176+
* Returns a list of Voice supported for synthesis.
177+
*
178+
* <p>Sample code:
179+
*
180+
* <pre><code>
181+
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
182+
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
183+
* ListVoicesResponse response = textToSpeechClient.listVoices(request);
184+
* }
185+
* </code></pre>
186+
*
187+
* @param request The request object containing all of the parameters for the API call.
188+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
189+
*/
190+
public final ListVoicesResponse listVoices(ListVoicesRequest request) {
191+
return listVoicesCallable().call(request);
192+
}
193+
194+
// AUTO-GENERATED DOCUMENTATION AND METHOD
195+
/**
196+
* Returns a list of Voice supported for synthesis.
197+
*
198+
* <p>Sample code:
199+
*
200+
* <pre><code>
201+
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
202+
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
203+
* ApiFuture&lt;ListVoicesResponse&gt; future = textToSpeechClient.listVoicesCallable().futureCall(request);
204+
* // Do something
205+
* ListVoicesResponse response = future.get();
206+
* }
207+
* </code></pre>
208+
*/
209+
public final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
210+
return stub.listVoicesCallable();
211+
}
212+
148213
// AUTO-GENERATED DOCUMENTATION AND METHOD
149214
/**
150215
* Synthesizes speech synchronously: receive results after all text input has been processed.
@@ -230,73 +295,6 @@ public final SynthesizeSpeechResponse synthesizeSpeech(SynthesizeSpeechRequest r
230295
return stub.synthesizeSpeechCallable();
231296
}
232297

233-
// AUTO-GENERATED DOCUMENTATION AND METHOD
234-
/**
235-
* Returns a list of Voice supported for synthesis.
236-
*
237-
* <p>Sample code:
238-
*
239-
* <pre><code>
240-
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
241-
* String languageCode = "";
242-
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
243-
* }
244-
* </code></pre>
245-
*
246-
* @param languageCode Optional. Recommended.
247-
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If specified, the
248-
* ListVoices call will only return voices that can be used to synthesize this language_code.
249-
* E.g. when specifying "en-NZ", you will get supported "en-&#42;" voices; when specifying
250-
* "no", you will get supported "no-&#42;" (Norwegian) and "nb-&#42;" (Norwegian Bokmal)
251-
* voices; specifying "zh" will also get supported "cmn-&#42;" voices; specifying "zh-hk" will
252-
* also get supported "yue-&#42;" voices.
253-
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
254-
*/
255-
public final ListVoicesResponse listVoices(String languageCode) {
256-
ListVoicesRequest request =
257-
ListVoicesRequest.newBuilder().setLanguageCode(languageCode).build();
258-
return listVoices(request);
259-
}
260-
261-
// AUTO-GENERATED DOCUMENTATION AND METHOD
262-
/**
263-
* Returns a list of Voice supported for synthesis.
264-
*
265-
* <p>Sample code:
266-
*
267-
* <pre><code>
268-
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
269-
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
270-
* ListVoicesResponse response = textToSpeechClient.listVoices(request);
271-
* }
272-
* </code></pre>
273-
*
274-
* @param request The request object containing all of the parameters for the API call.
275-
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
276-
*/
277-
public final ListVoicesResponse listVoices(ListVoicesRequest request) {
278-
return listVoicesCallable().call(request);
279-
}
280-
281-
// AUTO-GENERATED DOCUMENTATION AND METHOD
282-
/**
283-
* Returns a list of Voice supported for synthesis.
284-
*
285-
* <p>Sample code:
286-
*
287-
* <pre><code>
288-
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
289-
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
290-
* ApiFuture&lt;ListVoicesResponse&gt; future = textToSpeechClient.listVoicesCallable().futureCall(request);
291-
* // Do something
292-
* ListVoicesResponse response = future.get();
293-
* }
294-
* </code></pre>
295-
*/
296-
public final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
297-
return stub.listVoicesCallable();
298-
}
299-
300298
@Override
301299
public final void close() {
302300
stub.close();

google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/TextToSpeechSettings.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@
4545
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
4646
* build() is called, the tree of builders is called to create the complete settings object.
4747
*
48-
* <p>For example, to set the total timeout of synthesizeSpeech to 30 seconds:
48+
* <p>For example, to set the total timeout of listVoices to 30 seconds:
4949
*
5050
* <pre>
5151
* <code>
5252
* TextToSpeechSettings.Builder textToSpeechSettingsBuilder =
5353
* TextToSpeechSettings.newBuilder();
5454
* textToSpeechSettingsBuilder
55-
* .synthesizeSpeechSettings()
55+
* .listVoicesSettings()
5656
* .setRetrySettings(
57-
* textToSpeechSettingsBuilder.synthesizeSpeechSettings().getRetrySettings().toBuilder()
57+
* textToSpeechSettingsBuilder.listVoicesSettings().getRetrySettings().toBuilder()
5858
* .setTotalTimeout(Duration.ofSeconds(30))
5959
* .build());
6060
* TextToSpeechSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
@@ -64,17 +64,17 @@
6464
@Generated("by gapic-generator")
6565
@BetaApi
6666
public class TextToSpeechSettings extends ClientSettings<TextToSpeechSettings> {
67+
/** Returns the object with the settings used for calls to listVoices. */
68+
public UnaryCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
69+
return ((TextToSpeechStubSettings) getStubSettings()).listVoicesSettings();
70+
}
71+
6772
/** Returns the object with the settings used for calls to synthesizeSpeech. */
6873
public UnaryCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
6974
synthesizeSpeechSettings() {
7075
return ((TextToSpeechStubSettings) getStubSettings()).synthesizeSpeechSettings();
7176
}
7277

73-
/** Returns the object with the settings used for calls to listVoices. */
74-
public UnaryCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
75-
return ((TextToSpeechStubSettings) getStubSettings()).listVoicesSettings();
76-
}
77-
7878
public static final TextToSpeechSettings create(TextToSpeechStubSettings stub)
7979
throws IOException {
8080
return new TextToSpeechSettings.Builder(stub.toBuilder()).build();
@@ -172,17 +172,17 @@ public Builder applyToAllUnaryMethods(
172172
return this;
173173
}
174174

175+
/** Returns the builder for the settings used for calls to listVoices. */
176+
public UnaryCallSettings.Builder<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
177+
return getStubSettingsBuilder().listVoicesSettings();
178+
}
179+
175180
/** Returns the builder for the settings used for calls to synthesizeSpeech. */
176181
public UnaryCallSettings.Builder<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
177182
synthesizeSpeechSettings() {
178183
return getStubSettingsBuilder().synthesizeSpeechSettings();
179184
}
180185

181-
/** Returns the builder for the settings used for calls to listVoices. */
182-
public UnaryCallSettings.Builder<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
183-
return getStubSettingsBuilder().listVoicesSettings();
184-
}
185-
186186
@Override
187187
public TextToSpeechSettings build() throws IOException {
188188
return new TextToSpeechSettings(this);

google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/package-info.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
* <pre>
2929
* <code>
3030
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
31-
* SynthesisInput input = SynthesisInput.newBuilder().build();
32-
* VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
33-
* AudioConfig audioConfig = AudioConfig.newBuilder().build();
34-
* SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
31+
* String languageCode = "";
32+
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
3533
* }
3634
* </code>
3735
* </pre>

google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/GrpcTextToSpeechStub.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
4343
public class GrpcTextToSpeechStub extends TextToSpeechStub {
4444

45+
private static final MethodDescriptor<ListVoicesRequest, ListVoicesResponse>
46+
listVoicesMethodDescriptor =
47+
MethodDescriptor.<ListVoicesRequest, ListVoicesResponse>newBuilder()
48+
.setType(MethodDescriptor.MethodType.UNARY)
49+
.setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/ListVoices")
50+
.setRequestMarshaller(ProtoUtils.marshaller(ListVoicesRequest.getDefaultInstance()))
51+
.setResponseMarshaller(ProtoUtils.marshaller(ListVoicesResponse.getDefaultInstance()))
52+
.build();
4553
private static final MethodDescriptor<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
4654
synthesizeSpeechMethodDescriptor =
4755
MethodDescriptor.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder()
@@ -52,20 +60,12 @@ public class GrpcTextToSpeechStub extends TextToSpeechStub {
5260
.setResponseMarshaller(
5361
ProtoUtils.marshaller(SynthesizeSpeechResponse.getDefaultInstance()))
5462
.build();
55-
private static final MethodDescriptor<ListVoicesRequest, ListVoicesResponse>
56-
listVoicesMethodDescriptor =
57-
MethodDescriptor.<ListVoicesRequest, ListVoicesResponse>newBuilder()
58-
.setType(MethodDescriptor.MethodType.UNARY)
59-
.setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/ListVoices")
60-
.setRequestMarshaller(ProtoUtils.marshaller(ListVoicesRequest.getDefaultInstance()))
61-
.setResponseMarshaller(ProtoUtils.marshaller(ListVoicesResponse.getDefaultInstance()))
62-
.build();
6363

6464
private final BackgroundResource backgroundResources;
6565

66+
private final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable;
6667
private final UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
6768
synthesizeSpeechCallable;
68-
private final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable;
6969

7070
private final GrpcStubCallableFactory callableFactory;
7171

@@ -106,35 +106,35 @@ protected GrpcTextToSpeechStub(
106106
throws IOException {
107107
this.callableFactory = callableFactory;
108108

109+
GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings =
110+
GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder()
111+
.setMethodDescriptor(listVoicesMethodDescriptor)
112+
.build();
109113
GrpcCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
110114
synthesizeSpeechTransportSettings =
111115
GrpcCallSettings.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder()
112116
.setMethodDescriptor(synthesizeSpeechMethodDescriptor)
113117
.build();
114-
GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings =
115-
GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder()
116-
.setMethodDescriptor(listVoicesMethodDescriptor)
117-
.build();
118118

119-
this.synthesizeSpeechCallable =
120-
callableFactory.createUnaryCallable(
121-
synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext);
122119
this.listVoicesCallable =
123120
callableFactory.createUnaryCallable(
124121
listVoicesTransportSettings, settings.listVoicesSettings(), clientContext);
122+
this.synthesizeSpeechCallable =
123+
callableFactory.createUnaryCallable(
124+
synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext);
125125

126126
backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
127127
}
128128

129+
public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
130+
return listVoicesCallable;
131+
}
132+
129133
public UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
130134
synthesizeSpeechCallable() {
131135
return synthesizeSpeechCallable;
132136
}
133137

134-
public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
135-
return listVoicesCallable;
136-
}
137-
138138
@Override
139139
public final void close() {
140140
shutdown();

google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1/stub/TextToSpeechStub.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
3535
public abstract class TextToSpeechStub implements BackgroundResource {
3636

37+
public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
38+
throw new UnsupportedOperationException("Not implemented: listVoicesCallable()");
39+
}
40+
3741
public UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
3842
synthesizeSpeechCallable() {
3943
throw new UnsupportedOperationException("Not implemented: synthesizeSpeechCallable()");
4044
}
4145

42-
public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
43-
throw new UnsupportedOperationException("Not implemented: listVoicesCallable()");
44-
}
45-
4646
@Override
4747
public abstract void close();
4848
}

0 commit comments

Comments
 (0)