Skip to content

Commit a1d1971

Browse files
feat: Enable REST transport for most of Java and Go clients (googleapis#941)
- [ ] 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 3da152f commit a1d1971

File tree

1,194 files changed

+91240
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,194 files changed

+91240
-232
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
<dependency>
6262
<groupId>com.google.api</groupId>
6363
<artifactId>gax-grpc</artifactId>
64+
</dependency>
65+
<dependency>
66+
<groupId>com.google.api</groupId>
67+
<artifactId>gax-httpjson</artifactId>
6468
</dependency>
6569
<dependency>
6670
<groupId>org.threeten</groupId>
@@ -89,12 +93,24 @@
8993
<scope>test</scope>
9094
</dependency>
9195
<!-- Need testing utility classes for generated gRPC clients tests -->
96+
<dependency>
97+
<groupId>com.google.api</groupId>
98+
<artifactId>gax</artifactId>
99+
<classifier>testlib</classifier>
100+
<scope>test</scope>
101+
</dependency>
92102
<dependency>
93103
<groupId>com.google.api</groupId>
94104
<artifactId>gax-grpc</artifactId>
95105
<classifier>testlib</classifier>
96106
<scope>test</scope>
97107
</dependency>
108+
<dependency>
109+
<groupId>com.google.api</groupId>
110+
<artifactId>gax-httpjson</artifactId>
111+
<classifier>testlib</classifier>
112+
<scope>test</scope>
113+
</dependency>
98114
</dependencies>
99115

100116
<profiles>

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java

+32-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.core.ApiFuture;
2020
import com.google.api.core.ApiFutures;
2121
import com.google.api.gax.core.BackgroundResource;
22+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2223
import com.google.api.gax.longrunning.OperationFuture;
2324
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2425
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +31,6 @@
3031
import com.google.cloud.dialogflow.v2.stub.AgentsStubSettings;
3132
import com.google.common.util.concurrent.MoreExecutors;
3233
import com.google.longrunning.Operation;
33-
import com.google.longrunning.OperationsClient;
3434
import com.google.protobuf.Empty;
3535
import com.google.protobuf.Struct;
3636
import java.io.IOException;
@@ -101,13 +101,28 @@
101101
* AgentsClient agentsClient = AgentsClient.create(agentsSettings);
102102
* }</pre>
103103
*
104+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
105+
* the wire:
106+
*
107+
* <pre>{@code
108+
* // This snippet has been automatically generated for illustrative purposes only.
109+
* // It may require modifications to work in your environment.
110+
* AgentsSettings agentsSettings =
111+
* AgentsSettings.newBuilder()
112+
* .setTransportChannelProvider(
113+
* AgentsSettings.defaultHttpJsonTransportProviderBuilder().build())
114+
* .build();
115+
* AgentsClient agentsClient = AgentsClient.create(agentsSettings);
116+
* }</pre>
117+
*
104118
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
105119
*/
106120
@Generated("by gapic-generator-java")
107121
public class AgentsClient implements BackgroundResource {
108122
private final AgentsSettings settings;
109123
private final AgentsStub stub;
110-
private final OperationsClient operationsClient;
124+
private final OperationsClient httpJsonOperationsClient;
125+
private final com.google.longrunning.OperationsClient operationsClient;
111126

112127
/** Constructs an instance of AgentsClient with default settings. */
113128
public static final AgentsClient create() throws IOException {
@@ -137,13 +152,17 @@ public static final AgentsClient create(AgentsStub stub) {
137152
protected AgentsClient(AgentsSettings settings) throws IOException {
138153
this.settings = settings;
139154
this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub();
140-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
155+
this.operationsClient =
156+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
157+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
141158
}
142159

143160
protected AgentsClient(AgentsStub stub) {
144161
this.settings = null;
145162
this.stub = stub;
146-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
163+
this.operationsClient =
164+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
165+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
147166
}
148167

149168
public final AgentsSettings getSettings() {
@@ -158,10 +177,18 @@ public AgentsStub getStub() {
158177
* Returns the OperationsClient that can be used to query the status of a long-running operation
159178
* returned by another API method call.
160179
*/
161-
public final OperationsClient getOperationsClient() {
180+
public final com.google.longrunning.OperationsClient getOperationsClient() {
162181
return operationsClient;
163182
}
164183

184+
/**
185+
* Returns the OperationsClient that can be used to query the status of a long-running operation
186+
* returned by another API method call.
187+
*/
188+
public final OperationsClient getHttpJsonOperationsClient() {
189+
return httpJsonOperationsClient;
190+
}
191+
165192
// AUTO-GENERATED DOCUMENTATION AND METHOD.
166193
/**
167194
* Retrieves the specified agent.

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.core.GoogleCredentialsProvider;
2424
import com.google.api.gax.core.InstantiatingExecutorProvider;
2525
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
26+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2627
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2728
import com.google.api.gax.rpc.ClientContext;
2829
import com.google.api.gax.rpc.ClientSettings;
@@ -166,11 +167,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
166167
return AgentsStubSettings.defaultCredentialsProviderBuilder();
167168
}
168169

169-
/** Returns a builder for the default ChannelProvider for this service. */
170+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
170171
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
171172
return AgentsStubSettings.defaultGrpcTransportProviderBuilder();
172173
}
173174

175+
/** Returns a builder for the default REST ChannelProvider for this service. */
176+
@BetaApi
177+
public static InstantiatingHttpJsonChannelProvider.Builder
178+
defaultHttpJsonTransportProviderBuilder() {
179+
return AgentsStubSettings.defaultHttpJsonTransportProviderBuilder();
180+
}
181+
174182
public static TransportChannelProvider defaultTransportChannelProvider() {
175183
return AgentsStubSettings.defaultTransportChannelProvider();
176184
}
@@ -180,11 +188,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
180188
return AgentsStubSettings.defaultApiClientHeaderProviderBuilder();
181189
}
182190

183-
/** Returns a new builder for this class. */
191+
/** Returns a new gRPC builder for this class. */
184192
public static Builder newBuilder() {
185193
return Builder.createDefault();
186194
}
187195

196+
/** Returns a new REST builder for this class. */
197+
@BetaApi
198+
public static Builder newHttpJsonBuilder() {
199+
return Builder.createHttpJsonDefault();
200+
}
201+
188202
/** Returns a new builder for this class. */
189203
public static Builder newBuilder(ClientContext clientContext) {
190204
return new Builder(clientContext);
@@ -222,6 +236,11 @@ private static Builder createDefault() {
222236
return new Builder(AgentsStubSettings.newBuilder());
223237
}
224238

239+
@BetaApi
240+
private static Builder createHttpJsonDefault() {
241+
return new Builder(AgentsStubSettings.newHttpJsonBuilder());
242+
}
243+
225244
public AgentsStubSettings.Builder getStubSettingsBuilder() {
226245
return ((AgentsStubSettings.Builder) getStubSettings());
227246
}

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsClient.java

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@
9999
* AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings);
100100
* }</pre>
101101
*
102+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
103+
* the wire:
104+
*
105+
* <pre>{@code
106+
* // This snippet has been automatically generated for illustrative purposes only.
107+
* // It may require modifications to work in your environment.
108+
* AnswerRecordsSettings answerRecordsSettings =
109+
* AnswerRecordsSettings.newBuilder()
110+
* .setTransportChannelProvider(
111+
* AnswerRecordsSettings.defaultHttpJsonTransportProviderBuilder().build())
112+
* .build();
113+
* AnswerRecordsClient answerRecordsClient = AnswerRecordsClient.create(answerRecordsSettings);
114+
* }</pre>
115+
*
102116
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
103117
*/
104118
@Generated("by gapic-generator-java")

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AnswerRecordsSettings.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.core.GoogleCredentialsProvider;
2424
import com.google.api.gax.core.InstantiatingExecutorProvider;
2525
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
26+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2627
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2728
import com.google.api.gax.rpc.ClientContext;
2829
import com.google.api.gax.rpc.ClientSettings;
@@ -107,11 +108,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
107108
return AnswerRecordsStubSettings.defaultCredentialsProviderBuilder();
108109
}
109110

110-
/** Returns a builder for the default ChannelProvider for this service. */
111+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
111112
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
112113
return AnswerRecordsStubSettings.defaultGrpcTransportProviderBuilder();
113114
}
114115

116+
/** Returns a builder for the default REST ChannelProvider for this service. */
117+
@BetaApi
118+
public static InstantiatingHttpJsonChannelProvider.Builder
119+
defaultHttpJsonTransportProviderBuilder() {
120+
return AnswerRecordsStubSettings.defaultHttpJsonTransportProviderBuilder();
121+
}
122+
115123
public static TransportChannelProvider defaultTransportChannelProvider() {
116124
return AnswerRecordsStubSettings.defaultTransportChannelProvider();
117125
}
@@ -121,11 +129,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
121129
return AnswerRecordsStubSettings.defaultApiClientHeaderProviderBuilder();
122130
}
123131

124-
/** Returns a new builder for this class. */
132+
/** Returns a new gRPC builder for this class. */
125133
public static Builder newBuilder() {
126134
return Builder.createDefault();
127135
}
128136

137+
/** Returns a new REST builder for this class. */
138+
@BetaApi
139+
public static Builder newHttpJsonBuilder() {
140+
return Builder.createHttpJsonDefault();
141+
}
142+
129143
/** Returns a new builder for this class. */
130144
public static Builder newBuilder(ClientContext clientContext) {
131145
return new Builder(clientContext);
@@ -163,6 +177,11 @@ private static Builder createDefault() {
163177
return new Builder(AnswerRecordsStubSettings.newBuilder());
164178
}
165179

180+
@BetaApi
181+
private static Builder createHttpJsonDefault() {
182+
return new Builder(AnswerRecordsStubSettings.newHttpJsonBuilder());
183+
}
184+
166185
public AnswerRecordsStubSettings.Builder getStubSettingsBuilder() {
167186
return ((AnswerRecordsStubSettings.Builder) getStubSettings());
168187
}

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@
9999
* ContextsClient contextsClient = ContextsClient.create(contextsSettings);
100100
* }</pre>
101101
*
102+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
103+
* the wire:
104+
*
105+
* <pre>{@code
106+
* // This snippet has been automatically generated for illustrative purposes only.
107+
* // It may require modifications to work in your environment.
108+
* ContextsSettings contextsSettings =
109+
* ContextsSettings.newBuilder()
110+
* .setTransportChannelProvider(
111+
* ContextsSettings.defaultHttpJsonTransportProviderBuilder().build())
112+
* .build();
113+
* ContextsClient contextsClient = ContextsClient.create(contextsSettings);
114+
* }</pre>
115+
*
102116
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
103117
*/
104118
@Generated("by gapic-generator-java")

java-dialogflow/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.core.GoogleCredentialsProvider;
2424
import com.google.api.gax.core.InstantiatingExecutorProvider;
2525
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
26+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2627
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2728
import com.google.api.gax.rpc.ClientContext;
2829
import com.google.api.gax.rpc.ClientSettings;
@@ -126,11 +127,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
126127
return ContextsStubSettings.defaultCredentialsProviderBuilder();
127128
}
128129

129-
/** Returns a builder for the default ChannelProvider for this service. */
130+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
130131
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
131132
return ContextsStubSettings.defaultGrpcTransportProviderBuilder();
132133
}
133134

135+
/** Returns a builder for the default REST ChannelProvider for this service. */
136+
@BetaApi
137+
public static InstantiatingHttpJsonChannelProvider.Builder
138+
defaultHttpJsonTransportProviderBuilder() {
139+
return ContextsStubSettings.defaultHttpJsonTransportProviderBuilder();
140+
}
141+
134142
public static TransportChannelProvider defaultTransportChannelProvider() {
135143
return ContextsStubSettings.defaultTransportChannelProvider();
136144
}
@@ -140,11 +148,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
140148
return ContextsStubSettings.defaultApiClientHeaderProviderBuilder();
141149
}
142150

143-
/** Returns a new builder for this class. */
151+
/** Returns a new gRPC builder for this class. */
144152
public static Builder newBuilder() {
145153
return Builder.createDefault();
146154
}
147155

156+
/** Returns a new REST builder for this class. */
157+
@BetaApi
158+
public static Builder newHttpJsonBuilder() {
159+
return Builder.createHttpJsonDefault();
160+
}
161+
148162
/** Returns a new builder for this class. */
149163
public static Builder newBuilder(ClientContext clientContext) {
150164
return new Builder(clientContext);
@@ -182,6 +196,11 @@ private static Builder createDefault() {
182196
return new Builder(ContextsStubSettings.newBuilder());
183197
}
184198

199+
@BetaApi
200+
private static Builder createHttpJsonDefault() {
201+
return new Builder(ContextsStubSettings.newHttpJsonBuilder());
202+
}
203+
185204
public ContextsStubSettings.Builder getStubSettingsBuilder() {
186205
return ((ContextsStubSettings.Builder) getStubSettings());
187206
}

0 commit comments

Comments
 (0)