Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 62c542a

Browse files
authoredJun 23, 2022
feat: Enable REST transport for most of Java and Go clients (#676)
- [ ] 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 a2f9699 commit 62c542a

File tree

8 files changed

+3748
-8
lines changed

8 files changed

+3748
-8
lines changed
 

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
1919
<dependency>
2020
<groupId>com.google.cloud</groupId>
2121
<artifactId>google-cloud-bigqueryreservation</artifactId>
22-
<version>2.3.0</version>
22+
<version>2.3.1</version>
2323
</dependency>
2424
```
2525

2626
If you are using Gradle without BOM, add this to your dependencies
2727

2828
```Groovy
29-
implementation 'com.google.cloud:google-cloud-bigqueryreservation:2.3.0'
29+
implementation 'com.google.cloud:google-cloud-bigqueryreservation:2.3.1'
3030
```
3131

3232
If you are using SBT, add this to your dependencies
3333

3434
```Scala
35-
libraryDependencies += "com.google.cloud" % "google-cloud-bigqueryreservation" % "2.3.0"
35+
libraryDependencies += "com.google.cloud" % "google-cloud-bigqueryreservation" % "2.3.1"
3636
```
3737

3838
## Authentication

‎google-cloud-bigqueryreservation/pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<groupId>com.google.api</groupId>
6060
<artifactId>gax-grpc</artifactId>
6161
</dependency>
62+
<dependency>
63+
<groupId>com.google.api</groupId>
64+
<artifactId>gax-httpjson</artifactId>
65+
</dependency>
6266
<dependency>
6367
<groupId>org.threeten</groupId>
6468
<artifactId>threetenbp</artifactId>
@@ -77,12 +81,24 @@
7781
<scope>test</scope>
7882
</dependency>
7983
<!-- Need testing utility classes for generated gRPC clients tests -->
84+
<dependency>
85+
<groupId>com.google.api</groupId>
86+
<artifactId>gax</artifactId>
87+
<classifier>testlib</classifier>
88+
<scope>test</scope>
89+
</dependency>
8090
<dependency>
8191
<groupId>com.google.api</groupId>
8292
<artifactId>gax-grpc</artifactId>
8393
<classifier>testlib</classifier>
8494
<scope>test</scope>
8595
</dependency>
96+
<dependency>
97+
<groupId>com.google.api</groupId>
98+
<artifactId>gax-httpjson</artifactId>
99+
<classifier>testlib</classifier>
100+
<scope>test</scope>
101+
</dependency>
86102
</dependencies>
87103

88104
<profiles>

‎google-cloud-bigqueryreservation/src/main/java/com/google/cloud/bigquery/reservation/v1/ReservationServiceClient.java

+15
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@
116116
* ReservationServiceClient.create(reservationServiceSettings);
117117
* }</pre>
118118
*
119+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
120+
* the wire:
121+
*
122+
* <pre>{@code
123+
* // This snippet has been automatically generated for illustrative purposes only.
124+
* // It may require modifications to work in your environment.
125+
* ReservationServiceSettings reservationServiceSettings =
126+
* ReservationServiceSettings.newBuilder()
127+
* .setTransportChannelProvider(
128+
* ReservationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
129+
* .build();
130+
* ReservationServiceClient reservationServiceClient =
131+
* ReservationServiceClient.create(reservationServiceSettings);
132+
* }</pre>
133+
*
119134
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
120135
*/
121136
@Generated("by gapic-generator-java")

‎google-cloud-bigqueryreservation/src/main/java/com/google/cloud/bigquery/reservation/v1/ReservationServiceSettings.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.api.gax.core.GoogleCredentialsProvider;
2828
import com.google.api.gax.core.InstantiatingExecutorProvider;
2929
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
30+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
3031
import com.google.api.gax.rpc.ApiClientHeaderProvider;
3132
import com.google.api.gax.rpc.ClientContext;
3233
import com.google.api.gax.rpc.ClientSettings;
@@ -234,11 +235,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
234235
return ReservationServiceStubSettings.defaultCredentialsProviderBuilder();
235236
}
236237

237-
/** Returns a builder for the default ChannelProvider for this service. */
238+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
238239
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
239240
return ReservationServiceStubSettings.defaultGrpcTransportProviderBuilder();
240241
}
241242

243+
/** Returns a builder for the default REST ChannelProvider for this service. */
244+
@BetaApi
245+
public static InstantiatingHttpJsonChannelProvider.Builder
246+
defaultHttpJsonTransportProviderBuilder() {
247+
return ReservationServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
248+
}
249+
242250
public static TransportChannelProvider defaultTransportChannelProvider() {
243251
return ReservationServiceStubSettings.defaultTransportChannelProvider();
244252
}
@@ -248,11 +256,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
248256
return ReservationServiceStubSettings.defaultApiClientHeaderProviderBuilder();
249257
}
250258

251-
/** Returns a new builder for this class. */
259+
/** Returns a new gRPC builder for this class. */
252260
public static Builder newBuilder() {
253261
return Builder.createDefault();
254262
}
255263

264+
/** Returns a new REST builder for this class. */
265+
@BetaApi
266+
public static Builder newHttpJsonBuilder() {
267+
return Builder.createHttpJsonDefault();
268+
}
269+
256270
/** Returns a new builder for this class. */
257271
public static Builder newBuilder(ClientContext clientContext) {
258272
return new Builder(clientContext);
@@ -290,6 +304,11 @@ private static Builder createDefault() {
290304
return new Builder(ReservationServiceStubSettings.newBuilder());
291305
}
292306

307+
@BetaApi
308+
private static Builder createHttpJsonDefault() {
309+
return new Builder(ReservationServiceStubSettings.newHttpJsonBuilder());
310+
}
311+
293312
public ReservationServiceStubSettings.Builder getStubSettingsBuilder() {
294313
return ((ReservationServiceStubSettings.Builder) getStubSettings());
295314
}
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.bigquery.reservation.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 ReservationService service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonReservationServiceCallableFactory
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+
}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.