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

Commit ede5b3b

Browse files
feat: Enable REST transport for most of Java and Go clients (#196)
- [ ] 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 0ec473f commit ede5b3b

File tree

17 files changed

+970
-14
lines changed

17 files changed

+970
-14
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ If you are using Maven, add this to your pom.xml file:
2222
<dependency>
2323
<groupId>com.google.cloud</groupId>
2424
<artifactId>google-cloud-life-sciences</artifactId>
25-
<version>0.4.0</version>
25+
<version>0.4.1</version>
2626
</dependency>
2727
```
2828

2929
If you are using Gradle without BOM, add this to your dependencies
3030

3131
```Groovy
32-
implementation 'com.google.cloud:google-cloud-life-sciences:0.4.0'
32+
implementation 'com.google.cloud:google-cloud-life-sciences:0.4.1'
3333
```
3434

3535
If you are using SBT, add this to your dependencies
3636

3737
```Scala
38-
libraryDependencies += "com.google.cloud" % "google-cloud-life-sciences" % "0.4.0"
38+
libraryDependencies += "com.google.cloud" % "google-cloud-life-sciences" % "0.4.1"
3939
```
4040

4141
## Authentication

google-cloud-life-sciences/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<groupId>com.google.api</groupId>
5959
<artifactId>gax-grpc</artifactId>
6060
</dependency>
61+
<dependency>
62+
<groupId>com.google.api</groupId>
63+
<artifactId>gax-httpjson</artifactId>
64+
</dependency>
6165
<dependency>
6266
<groupId>org.threeten</groupId>
6367
<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-life-sciences/src/main/java/com/google/cloud/lifesciences/v2beta/WorkflowsServiceV2BetaClient.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
import com.google.api.core.BetaApi;
2020
import com.google.api.gax.core.BackgroundResource;
21+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2122
import com.google.api.gax.longrunning.OperationFuture;
2223
import com.google.api.gax.rpc.OperationCallable;
2324
import com.google.api.gax.rpc.UnaryCallable;
2425
import com.google.cloud.lifesciences.v2beta.stub.WorkflowsServiceV2BetaStub;
2526
import com.google.cloud.lifesciences.v2beta.stub.WorkflowsServiceV2BetaStubSettings;
2627
import com.google.longrunning.Operation;
27-
import com.google.longrunning.OperationsClient;
2828
import java.io.IOException;
2929
import java.util.concurrent.TimeUnit;
3030
import javax.annotation.Generated;
@@ -104,14 +104,30 @@
104104
* WorkflowsServiceV2BetaClient.create(workflowsServiceV2BetaSettings);
105105
* }</pre>
106106
*
107+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
108+
* the wire:
109+
*
110+
* <pre>{@code
111+
* // This snippet has been automatically generated for illustrative purposes only.
112+
* // It may require modifications to work in your environment.
113+
* WorkflowsServiceV2BetaSettings workflowsServiceV2BetaSettings =
114+
* WorkflowsServiceV2BetaSettings.newBuilder()
115+
* .setTransportChannelProvider(
116+
* WorkflowsServiceV2BetaSettings.defaultHttpJsonTransportProviderBuilder().build())
117+
* .build();
118+
* WorkflowsServiceV2BetaClient workflowsServiceV2BetaClient =
119+
* WorkflowsServiceV2BetaClient.create(workflowsServiceV2BetaSettings);
120+
* }</pre>
121+
*
107122
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
108123
*/
109124
@BetaApi
110125
@Generated("by gapic-generator-java")
111126
public class WorkflowsServiceV2BetaClient implements BackgroundResource {
112127
private final WorkflowsServiceV2BetaSettings settings;
113128
private final WorkflowsServiceV2BetaStub stub;
114-
private final OperationsClient operationsClient;
129+
private final OperationsClient httpJsonOperationsClient;
130+
private final com.google.longrunning.OperationsClient operationsClient;
115131

116132
/** Constructs an instance of WorkflowsServiceV2BetaClient with default settings. */
117133
public static final WorkflowsServiceV2BetaClient create() throws IOException {
@@ -144,13 +160,17 @@ protected WorkflowsServiceV2BetaClient(WorkflowsServiceV2BetaSettings settings)
144160
throws IOException {
145161
this.settings = settings;
146162
this.stub = ((WorkflowsServiceV2BetaStubSettings) settings.getStubSettings()).createStub();
147-
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());
148166
}
149167

150168
protected WorkflowsServiceV2BetaClient(WorkflowsServiceV2BetaStub stub) {
151169
this.settings = null;
152170
this.stub = stub;
153-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
171+
this.operationsClient =
172+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
173+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
154174
}
155175

156176
public final WorkflowsServiceV2BetaSettings getSettings() {
@@ -165,10 +185,18 @@ public WorkflowsServiceV2BetaStub getStub() {
165185
* Returns the OperationsClient that can be used to query the status of a long-running operation
166186
* returned by another API method call.
167187
*/
168-
public final OperationsClient getOperationsClient() {
188+
public final com.google.longrunning.OperationsClient getOperationsClient() {
169189
return operationsClient;
170190
}
171191

192+
/**
193+
* Returns the OperationsClient that can be used to query the status of a long-running operation
194+
* returned by another API method call.
195+
*/
196+
public final OperationsClient getHttpJsonOperationsClient() {
197+
return httpJsonOperationsClient;
198+
}
199+
172200
// AUTO-GENERATED DOCUMENTATION AND METHOD.
173201
/**
174202
* Runs a pipeline. The returned Operation's [metadata] [google.longrunning.Operation.metadata]

google-cloud-life-sciences/src/main/java/com/google/cloud/lifesciences/v2beta/WorkflowsServiceV2BetaSettings.java

Lines changed: 21 additions & 2 deletions
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;
@@ -108,11 +109,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
108109
return WorkflowsServiceV2BetaStubSettings.defaultCredentialsProviderBuilder();
109110
}
110111

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

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

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

138+
/** Returns a new REST builder for this class. */
139+
@BetaApi
140+
public static Builder newHttpJsonBuilder() {
141+
return Builder.createHttpJsonDefault();
142+
}
143+
130144
/** Returns a new builder for this class. */
131145
public static Builder newBuilder(ClientContext clientContext) {
132146
return new Builder(clientContext);
@@ -165,6 +179,11 @@ private static Builder createDefault() {
165179
return new Builder(WorkflowsServiceV2BetaStubSettings.newBuilder());
166180
}
167181

182+
@BetaApi
183+
private static Builder createHttpJsonDefault() {
184+
return new Builder(WorkflowsServiceV2BetaStubSettings.newHttpJsonBuilder());
185+
}
186+
168187
public WorkflowsServiceV2BetaStubSettings.Builder getStubSettingsBuilder() {
169188
return ((WorkflowsServiceV2BetaStubSettings.Builder) getStubSettings());
170189
}
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.lifesciences.v2beta.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 WorkflowsServiceV2Beta service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@BetaApi
44+
@Generated("by gapic-generator-java")
45+
public class HttpJsonWorkflowsServiceV2BetaCallableFactory
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)