Skip to content

Commit be55fdb

Browse files
feat: Enable REST transport for most of Java and Go clients (googleapis#705)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: googleapis/googleapis@8a251f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9
1 parent 37e1765 commit be55fdb

File tree

36 files changed

+2174
-12
lines changed

36 files changed

+2174
-12
lines changed

java-texttospeech/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-texttospeech'
5757
If you are using Gradle without BOM, add this to your dependencies
5858

5959
```Groovy
60-
implementation 'com.google.cloud:google-cloud-texttospeech:2.3.0'
60+
implementation 'com.google.cloud:google-cloud-texttospeech:2.3.1'
6161
```
6262

6363
If you are using SBT, add this to your dependencies
6464

6565
```Scala
66-
libraryDependencies += "com.google.cloud" % "google-cloud-texttospeech" % "2.3.0"
66+
libraryDependencies += "com.google.cloud" % "google-cloud-texttospeech" % "2.3.1"
6767
```
6868

6969
## Authentication

java-texttospeech/google-cloud-texttospeech/pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
<groupId>com.google.api</groupId>
6363
<artifactId>gax-grpc</artifactId>
6464
</dependency>
65+
<dependency>
66+
<groupId>com.google.api</groupId>
67+
<artifactId>gax-httpjson</artifactId>
68+
</dependency>
6569
<dependency>
6670
<groupId>org.threeten</groupId>
6771
<artifactId>threetenbp</artifactId>
@@ -85,12 +89,24 @@
8589
<scope>test</scope>
8690
</dependency>
8791
<!-- Need testing utility classes for generated gRPC clients tests -->
92+
<dependency>
93+
<groupId>com.google.api</groupId>
94+
<artifactId>gax</artifactId>
95+
<classifier>testlib</classifier>
96+
<scope>test</scope>
97+
</dependency>
8898
<dependency>
8999
<groupId>com.google.api</groupId>
90100
<artifactId>gax-grpc</artifactId>
91101
<classifier>testlib</classifier>
92102
<scope>test</scope>
93103
</dependency>
104+
<dependency>
105+
<groupId>com.google.api</groupId>
106+
<artifactId>gax-httpjson</artifactId>
107+
<classifier>testlib</classifier>
108+
<scope>test</scope>
109+
</dependency>
94110
</dependencies>
95111

96112
<profiles>

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

+14
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@
8888
* TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
8989
* }</pre>
9090
*
91+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
92+
* the wire:
93+
*
94+
* <pre>{@code
95+
* // This snippet has been automatically generated for illustrative purposes only.
96+
* // It may require modifications to work in your environment.
97+
* TextToSpeechSettings textToSpeechSettings =
98+
* TextToSpeechSettings.newBuilder()
99+
* .setTransportChannelProvider(
100+
* TextToSpeechSettings.defaultHttpJsonTransportProviderBuilder().build())
101+
* .build();
102+
* TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(textToSpeechSettings);
103+
* }</pre>
104+
*
91105
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
92106
*/
93107
@Generated("by gapic-generator-java")

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

+21-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.api.gax.core.GoogleCredentialsProvider;
2222
import com.google.api.gax.core.InstantiatingExecutorProvider;
2323
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
24+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2425
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2526
import com.google.api.gax.rpc.ClientContext;
2627
import com.google.api.gax.rpc.ClientSettings;
@@ -103,11 +104,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
103104
return TextToSpeechStubSettings.defaultCredentialsProviderBuilder();
104105
}
105106

106-
/** Returns a builder for the default ChannelProvider for this service. */
107+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
107108
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
108109
return TextToSpeechStubSettings.defaultGrpcTransportProviderBuilder();
109110
}
110111

112+
/** Returns a builder for the default REST ChannelProvider for this service. */
113+
@BetaApi
114+
public static InstantiatingHttpJsonChannelProvider.Builder
115+
defaultHttpJsonTransportProviderBuilder() {
116+
return TextToSpeechStubSettings.defaultHttpJsonTransportProviderBuilder();
117+
}
118+
111119
public static TransportChannelProvider defaultTransportChannelProvider() {
112120
return TextToSpeechStubSettings.defaultTransportChannelProvider();
113121
}
@@ -117,11 +125,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
117125
return TextToSpeechStubSettings.defaultApiClientHeaderProviderBuilder();
118126
}
119127

120-
/** Returns a new builder for this class. */
128+
/** Returns a new gRPC builder for this class. */
121129
public static Builder newBuilder() {
122130
return Builder.createDefault();
123131
}
124132

133+
/** Returns a new REST builder for this class. */
134+
@BetaApi
135+
public static Builder newHttpJsonBuilder() {
136+
return Builder.createHttpJsonDefault();
137+
}
138+
125139
/** Returns a new builder for this class. */
126140
public static Builder newBuilder(ClientContext clientContext) {
127141
return new Builder(clientContext);
@@ -159,6 +173,11 @@ private static Builder createDefault() {
159173
return new Builder(TextToSpeechStubSettings.newBuilder());
160174
}
161175

176+
@BetaApi
177+
private static Builder createHttpJsonDefault() {
178+
return new Builder(TextToSpeechStubSettings.newHttpJsonBuilder());
179+
}
180+
162181
public TextToSpeechStubSettings.Builder getStubSettingsBuilder() {
163182
return ((TextToSpeechStubSettings.Builder) getStubSettings());
164183
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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.stub;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.api.gax.httpjson.HttpJsonCallSettings;
21+
import com.google.api.gax.httpjson.HttpJsonCallableFactory;
22+
import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
23+
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
24+
import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
25+
import com.google.api.gax.rpc.BatchingCallSettings;
26+
import com.google.api.gax.rpc.ClientContext;
27+
import com.google.api.gax.rpc.OperationCallSettings;
28+
import com.google.api.gax.rpc.OperationCallable;
29+
import com.google.api.gax.rpc.PagedCallSettings;
30+
import com.google.api.gax.rpc.ServerStreamingCallSettings;
31+
import com.google.api.gax.rpc.ServerStreamingCallable;
32+
import com.google.api.gax.rpc.UnaryCallSettings;
33+
import com.google.api.gax.rpc.UnaryCallable;
34+
import com.google.longrunning.Operation;
35+
import javax.annotation.Generated;
36+
37+
// AUTO-GENERATED DOCUMENTATION AND CLASS.
38+
/**
39+
* REST callable factory implementation for the TextToSpeech service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonTextToSpeechCallableFactory
46+
implements HttpJsonStubCallableFactory<Operation, OperationsStub> {
47+
48+
@Override
49+
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable(
50+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
51+
UnaryCallSettings<RequestT, ResponseT> callSettings,
52+
ClientContext clientContext) {
53+
return HttpJsonCallableFactory.createUnaryCallable(
54+
httpJsonCallSettings, callSettings, clientContext);
55+
}
56+
57+
@Override
58+
public <RequestT, ResponseT, PagedListResponseT>
59+
UnaryCallable<RequestT, PagedListResponseT> createPagedCallable(
60+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
61+
PagedCallSettings<RequestT, ResponseT, PagedListResponseT> callSettings,
62+
ClientContext clientContext) {
63+
return HttpJsonCallableFactory.createPagedCallable(
64+
httpJsonCallSettings, callSettings, clientContext);
65+
}
66+
67+
@Override
68+
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable(
69+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
70+
BatchingCallSettings<RequestT, ResponseT> callSettings,
71+
ClientContext clientContext) {
72+
return HttpJsonCallableFactory.createBatchingCallable(
73+
httpJsonCallSettings, callSettings, clientContext);
74+
}
75+
76+
@BetaApi(
77+
"The surface for long-running operations is not stable yet and may change in the future.")
78+
@Override
79+
public <RequestT, ResponseT, MetadataT>
80+
OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable(
81+
HttpJsonCallSettings<RequestT, Operation> httpJsonCallSettings,
82+
OperationCallSettings<RequestT, ResponseT, MetadataT> callSettings,
83+
ClientContext clientContext,
84+
OperationsStub operationsStub) {
85+
UnaryCallable<RequestT, Operation> innerCallable =
86+
HttpJsonCallableFactory.createBaseUnaryCallable(
87+
httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
88+
HttpJsonOperationSnapshotCallable<RequestT, Operation> initialCallable =
89+
new HttpJsonOperationSnapshotCallable<RequestT, Operation>(
90+
innerCallable,
91+
httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
92+
return HttpJsonCallableFactory.createOperationCallable(
93+
callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
94+
}
95+
96+
@Override
97+
public <RequestT, ResponseT>
98+
ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable(
99+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
100+
ServerStreamingCallSettings<RequestT, ResponseT> callSettings,
101+
ClientContext clientContext) {
102+
return HttpJsonCallableFactory.createServerStreamingCallable(
103+
httpJsonCallSettings, callSettings, clientContext);
104+
}
105+
}

0 commit comments

Comments
 (0)