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

fix: restore GAPIC v2 retry configs #143

Merged
merged 2 commits into from Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -34,8 +34,10 @@
* <pre>
* <code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* String languageCode = "";
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
* SynthesisInput input = SynthesisInput.newBuilder().build();
* VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
* AudioConfig audioConfig = AudioConfig.newBuilder().build();
* SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
* }
* </code>
* </pre>
Expand Down Expand Up @@ -143,73 +145,6 @@ public TextToSpeechStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* String languageCode = "";
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
* }
* </code></pre>
*
* @param languageCode Optional. Recommended.
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If specified, the
* ListVoices call will only return voices that can be used to synthesize this language_code.
* E.g. when specifying "en-NZ", you will get supported "en-&#42;" voices; when specifying
* "no", you will get supported "no-&#42;" (Norwegian) and "nb-&#42;" (Norwegian Bokmal)
* voices; specifying "zh" will also get supported "cmn-&#42;" voices; specifying "zh-hk" will
* also get supported "yue-&#42;" voices.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListVoicesResponse listVoices(String languageCode) {
ListVoicesRequest request =
ListVoicesRequest.newBuilder().setLanguageCode(languageCode).build();
return listVoices(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
* ListVoicesResponse response = textToSpeechClient.listVoices(request);
* }
* </code></pre>
*
* @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 ListVoicesResponse listVoices(ListVoicesRequest request) {
return listVoicesCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
* ApiFuture&lt;ListVoicesResponse&gt; future = textToSpeechClient.listVoicesCallable().futureCall(request);
* // Do something
* ListVoicesResponse response = future.get();
* }
* </code></pre>
*/
public final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
return stub.listVoicesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Synthesizes speech synchronously: receive results after all text input has been processed.
Expand Down Expand Up @@ -295,6 +230,73 @@ public final SynthesizeSpeechResponse synthesizeSpeech(SynthesizeSpeechRequest r
return stub.synthesizeSpeechCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* String languageCode = "";
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
* }
* </code></pre>
*
* @param languageCode Optional. Recommended.
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If specified, the
* ListVoices call will only return voices that can be used to synthesize this language_code.
* E.g. when specifying "en-NZ", you will get supported "en-&#42;" voices; when specifying
* "no", you will get supported "no-&#42;" (Norwegian) and "nb-&#42;" (Norwegian Bokmal)
* voices; specifying "zh" will also get supported "cmn-&#42;" voices; specifying "zh-hk" will
* also get supported "yue-&#42;" voices.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListVoicesResponse listVoices(String languageCode) {
ListVoicesRequest request =
ListVoicesRequest.newBuilder().setLanguageCode(languageCode).build();
return listVoices(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
* ListVoicesResponse response = textToSpeechClient.listVoices(request);
* }
* </code></pre>
*
* @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 ListVoicesResponse listVoices(ListVoicesRequest request) {
return listVoicesCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns a list of Voice supported for synthesis.
*
* <p>Sample code:
*
* <pre><code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* ListVoicesRequest request = ListVoicesRequest.newBuilder().build();
* ApiFuture&lt;ListVoicesResponse&gt; future = textToSpeechClient.listVoicesCallable().futureCall(request);
* // Do something
* ListVoicesResponse response = future.get();
* }
* </code></pre>
*/
public final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
return stub.listVoicesCallable();
}

@Override
public final void close() {
stub.close();
Expand Down
Expand Up @@ -45,16 +45,16 @@
* <p>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.
*
* <p>For example, to set the total timeout of listVoices to 30 seconds:
* <p>For example, to set the total timeout of synthesizeSpeech to 30 seconds:
*
* <pre>
* <code>
* TextToSpeechSettings.Builder textToSpeechSettingsBuilder =
* TextToSpeechSettings.newBuilder();
* textToSpeechSettingsBuilder
* .listVoicesSettings()
* .synthesizeSpeechSettings()
* .setRetrySettings(
* textToSpeechSettingsBuilder.listVoicesSettings().getRetrySettings().toBuilder()
* textToSpeechSettingsBuilder.synthesizeSpeechSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* TextToSpeechSettings textToSpeechSettings = textToSpeechSettingsBuilder.build();
Expand All @@ -64,17 +64,17 @@
@Generated("by gapic-generator")
@BetaApi
public class TextToSpeechSettings extends ClientSettings<TextToSpeechSettings> {
/** Returns the object with the settings used for calls to listVoices. */
public UnaryCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
return ((TextToSpeechStubSettings) getStubSettings()).listVoicesSettings();
}

/** Returns the object with the settings used for calls to synthesizeSpeech. */
public UnaryCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechSettings() {
return ((TextToSpeechStubSettings) getStubSettings()).synthesizeSpeechSettings();
}

/** Returns the object with the settings used for calls to listVoices. */
public UnaryCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
return ((TextToSpeechStubSettings) getStubSettings()).listVoicesSettings();
}

public static final TextToSpeechSettings create(TextToSpeechStubSettings stub)
throws IOException {
return new TextToSpeechSettings.Builder(stub.toBuilder()).build();
Expand Down Expand Up @@ -172,17 +172,17 @@ public Builder applyToAllUnaryMethods(
return this;
}

/** Returns the builder for the settings used for calls to listVoices. */
public UnaryCallSettings.Builder<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
return getStubSettingsBuilder().listVoicesSettings();
}

/** Returns the builder for the settings used for calls to synthesizeSpeech. */
public UnaryCallSettings.Builder<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechSettings() {
return getStubSettingsBuilder().synthesizeSpeechSettings();
}

/** Returns the builder for the settings used for calls to listVoices. */
public UnaryCallSettings.Builder<ListVoicesRequest, ListVoicesResponse> listVoicesSettings() {
return getStubSettingsBuilder().listVoicesSettings();
}

@Override
public TextToSpeechSettings build() throws IOException {
return new TextToSpeechSettings(this);
Expand Down
Expand Up @@ -28,8 +28,10 @@
* <pre>
* <code>
* try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
* String languageCode = "";
* ListVoicesResponse response = textToSpeechClient.listVoices(languageCode);
* SynthesisInput input = SynthesisInput.newBuilder().build();
* VoiceSelectionParams voice = VoiceSelectionParams.newBuilder().build();
* AudioConfig audioConfig = AudioConfig.newBuilder().build();
* SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
* }
* </code>
* </pre>
Expand Down
Expand Up @@ -42,14 +42,6 @@
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public class GrpcTextToSpeechStub extends TextToSpeechStub {

private static final MethodDescriptor<ListVoicesRequest, ListVoicesResponse>
listVoicesMethodDescriptor =
MethodDescriptor.<ListVoicesRequest, ListVoicesResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/ListVoices")
.setRequestMarshaller(ProtoUtils.marshaller(ListVoicesRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListVoicesResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechMethodDescriptor =
MethodDescriptor.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder()
Expand All @@ -60,12 +52,20 @@ public class GrpcTextToSpeechStub extends TextToSpeechStub {
.setResponseMarshaller(
ProtoUtils.marshaller(SynthesizeSpeechResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<ListVoicesRequest, ListVoicesResponse>
listVoicesMethodDescriptor =
MethodDescriptor.<ListVoicesRequest, ListVoicesResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.texttospeech.v1.TextToSpeech/ListVoices")
.setRequestMarshaller(ProtoUtils.marshaller(ListVoicesRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListVoicesResponse.getDefaultInstance()))
.build();

private final BackgroundResource backgroundResources;

private final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable;
private final UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechCallable;
private final UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable;

private final GrpcStubCallableFactory callableFactory;

Expand Down Expand Up @@ -106,35 +106,35 @@ protected GrpcTextToSpeechStub(
throws IOException {
this.callableFactory = callableFactory;

GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings =
GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder()
.setMethodDescriptor(listVoicesMethodDescriptor)
.build();
GrpcCallSettings<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechTransportSettings =
GrpcCallSettings.<SynthesizeSpeechRequest, SynthesizeSpeechResponse>newBuilder()
.setMethodDescriptor(synthesizeSpeechMethodDescriptor)
.build();
GrpcCallSettings<ListVoicesRequest, ListVoicesResponse> listVoicesTransportSettings =
GrpcCallSettings.<ListVoicesRequest, ListVoicesResponse>newBuilder()
.setMethodDescriptor(listVoicesMethodDescriptor)
.build();

this.listVoicesCallable =
callableFactory.createUnaryCallable(
listVoicesTransportSettings, settings.listVoicesSettings(), clientContext);
this.synthesizeSpeechCallable =
callableFactory.createUnaryCallable(
synthesizeSpeechTransportSettings, settings.synthesizeSpeechSettings(), clientContext);
this.listVoicesCallable =
callableFactory.createUnaryCallable(
listVoicesTransportSettings, settings.listVoicesSettings(), clientContext);

backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}

public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
return listVoicesCallable;
}

public UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechCallable() {
return synthesizeSpeechCallable;
}

public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
return listVoicesCallable;
}

@Override
public final void close() {
shutdown();
Expand Down
Expand Up @@ -34,15 +34,15 @@
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public abstract class TextToSpeechStub implements BackgroundResource {

public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
throw new UnsupportedOperationException("Not implemented: listVoicesCallable()");
}

public UnaryCallable<SynthesizeSpeechRequest, SynthesizeSpeechResponse>
synthesizeSpeechCallable() {
throw new UnsupportedOperationException("Not implemented: synthesizeSpeechCallable()");
}

public UnaryCallable<ListVoicesRequest, ListVoicesResponse> listVoicesCallable() {
throw new UnsupportedOperationException("Not implemented: listVoicesCallable()");
}

@Override
public abstract void close();
}