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

Commit 503cc00

Browse files
fix: update gapic-generator-java with mock service generation fixes (#456)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 457524730 Source-Link: googleapis/googleapis@917e7f2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9 feat: Enable REST transport for most of Java and Go clients PiperOrigin-RevId: 456641589 Source-Link: googleapis/googleapis@8a251f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 chore: Integrate new gapic-generator-java and rules_gapic PiperOrigin-RevId: 454027580 Source-Link: googleapis/googleapis@1b22277 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9 chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 PiperOrigin-RevId: 450543911 Source-Link: googleapis/googleapis@5528344 Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f6775cab1958982b88967a43e5e806af0f135db Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWY2Nzc1Y2FiMTk1ODk4MmI4ODk2N2E0M2U1ZTgwNmFmMGYxMzVkYiJ9
1 parent f639c2f commit 503cc00

File tree

71 files changed

+5038
-32
lines changed

Some content is hidden

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

71 files changed

+5038
-32
lines changed

google-cloud-workflows/pom.xml

Lines changed: 16 additions & 0 deletions
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>
@@ -86,12 +90,24 @@
8690
<scope>test</scope>
8791
</dependency>
8892
<!-- Need testing utility classes for generated gRPC clients tests -->
93+
<dependency>
94+
<groupId>com.google.api</groupId>
95+
<artifactId>gax</artifactId>
96+
<classifier>testlib</classifier>
97+
<scope>test</scope>
98+
</dependency>
8999
<dependency>
90100
<groupId>com.google.api</groupId>
91101
<artifactId>gax-grpc</artifactId>
92102
<classifier>testlib</classifier>
93103
<scope>test</scope>
94104
</dependency>
105+
<dependency>
106+
<groupId>com.google.api</groupId>
107+
<artifactId>gax-httpjson</artifactId>
108+
<classifier>testlib</classifier>
109+
<scope>test</scope>
110+
</dependency>
95111
</dependencies>
96112

97113
<profiles>

google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1/WorkflowsClient.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.api.core.ApiFutures;
2121
import com.google.api.core.BetaApi;
2222
import com.google.api.gax.core.BackgroundResource;
23+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2324
import com.google.api.gax.longrunning.OperationFuture;
2425
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2526
import com.google.api.gax.paging.AbstractPage;
@@ -31,7 +32,6 @@
3132
import com.google.cloud.workflows.v1.stub.WorkflowsStubSettings;
3233
import com.google.common.util.concurrent.MoreExecutors;
3334
import com.google.longrunning.Operation;
34-
import com.google.longrunning.OperationsClient;
3535
import com.google.protobuf.Empty;
3636
import com.google.protobuf.FieldMask;
3737
import java.io.IOException;
@@ -104,13 +104,28 @@
104104
* WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings);
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+
* WorkflowsSettings workflowsSettings =
114+
* WorkflowsSettings.newBuilder()
115+
* .setTransportChannelProvider(
116+
* WorkflowsSettings.defaultHttpJsonTransportProviderBuilder().build())
117+
* .build();
118+
* WorkflowsClient workflowsClient = WorkflowsClient.create(workflowsSettings);
119+
* }</pre>
120+
*
107121
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
108122
*/
109123
@Generated("by gapic-generator-java")
110124
public class WorkflowsClient implements BackgroundResource {
111125
private final WorkflowsSettings settings;
112126
private final WorkflowsStub stub;
113-
private final OperationsClient operationsClient;
127+
private final OperationsClient httpJsonOperationsClient;
128+
private final com.google.longrunning.OperationsClient operationsClient;
114129

115130
/** Constructs an instance of WorkflowsClient with default settings. */
116131
public static final WorkflowsClient create() throws IOException {
@@ -129,7 +144,6 @@ public static final WorkflowsClient create(WorkflowsSettings settings) throws IO
129144
* Constructs an instance of WorkflowsClient, using the given stub for making calls. This is for
130145
* advanced usage - prefer using create(WorkflowsSettings).
131146
*/
132-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
133147
public static final WorkflowsClient create(WorkflowsStub stub) {
134148
return new WorkflowsClient(stub);
135149
}
@@ -141,21 +155,23 @@ public static final WorkflowsClient create(WorkflowsStub stub) {
141155
protected WorkflowsClient(WorkflowsSettings settings) throws IOException {
142156
this.settings = settings;
143157
this.stub = ((WorkflowsStubSettings) settings.getStubSettings()).createStub();
144-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
158+
this.operationsClient =
159+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
160+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
145161
}
146162

147-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
148163
protected WorkflowsClient(WorkflowsStub stub) {
149164
this.settings = null;
150165
this.stub = stub;
151-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
166+
this.operationsClient =
167+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
168+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
152169
}
153170

154171
public final WorkflowsSettings getSettings() {
155172
return settings;
156173
}
157174

158-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
159175
public WorkflowsStub getStub() {
160176
return stub;
161177
}
@@ -164,10 +180,19 @@ public WorkflowsStub getStub() {
164180
* Returns the OperationsClient that can be used to query the status of a long-running operation
165181
* returned by another API method call.
166182
*/
167-
public final OperationsClient getOperationsClient() {
183+
public final com.google.longrunning.OperationsClient getOperationsClient() {
168184
return operationsClient;
169185
}
170186

187+
/**
188+
* Returns the OperationsClient that can be used to query the status of a long-running operation
189+
* returned by another API method call.
190+
*/
191+
@BetaApi
192+
public final OperationsClient getHttpJsonOperationsClient() {
193+
return httpJsonOperationsClient;
194+
}
195+
171196
// AUTO-GENERATED DOCUMENTATION AND METHOD.
172197
/**
173198
* Lists Workflows in a given project and location. The default order is not specified.
@@ -305,7 +330,7 @@ public final ListWorkflowsPagedResponse listWorkflows(ListWorkflowsRequest reque
305330
* .build();
306331
* while (true) {
307332
* ListWorkflowsResponse response = workflowsClient.listWorkflowsCallable().call(request);
308-
* for (Workflow element : response.getResponsesList()) {
333+
* for (Workflow element : response.getWorkflowsList()) {
309334
* // doThingsWith(element);
310335
* }
311336
* String nextPageToken = response.getNextPageToken();

google-cloud-workflows/src/main/java/com/google/cloud/workflows/v1/WorkflowsSettings.java

Lines changed: 21 additions & 2 deletions
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;
@@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
141142
return WorkflowsStubSettings.defaultCredentialsProviderBuilder();
142143
}
143144

144-
/** Returns a builder for the default ChannelProvider for this service. */
145+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
145146
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
146147
return WorkflowsStubSettings.defaultGrpcTransportProviderBuilder();
147148
}
148149

150+
/** Returns a builder for the default REST ChannelProvider for this service. */
151+
@BetaApi
152+
public static InstantiatingHttpJsonChannelProvider.Builder
153+
defaultHttpJsonTransportProviderBuilder() {
154+
return WorkflowsStubSettings.defaultHttpJsonTransportProviderBuilder();
155+
}
156+
149157
public static TransportChannelProvider defaultTransportChannelProvider() {
150158
return WorkflowsStubSettings.defaultTransportChannelProvider();
151159
}
@@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
155163
return WorkflowsStubSettings.defaultApiClientHeaderProviderBuilder();
156164
}
157165

158-
/** Returns a new builder for this class. */
166+
/** Returns a new gRPC builder for this class. */
159167
public static Builder newBuilder() {
160168
return Builder.createDefault();
161169
}
162170

171+
/** Returns a new REST builder for this class. */
172+
@BetaApi
173+
public static Builder newHttpJsonBuilder() {
174+
return Builder.createHttpJsonDefault();
175+
}
176+
163177
/** Returns a new builder for this class. */
164178
public static Builder newBuilder(ClientContext clientContext) {
165179
return new Builder(clientContext);
@@ -197,6 +211,11 @@ private static Builder createDefault() {
197211
return new Builder(WorkflowsStubSettings.newBuilder());
198212
}
199213

214+
@BetaApi
215+
private static Builder createHttpJsonDefault() {
216+
return new Builder(WorkflowsStubSettings.newHttpJsonBuilder());
217+
}
218+
200219
public WorkflowsStubSettings.Builder getStubSettingsBuilder() {
201220
return ((WorkflowsStubSettings.Builder) getStubSettings());
202221
}
Lines changed: 105 additions & 0 deletions
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.workflows.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 Workflows service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonWorkflowsCallableFactory
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)