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

Commit 908b1f6

Browse files
fix: update gapic-generator-java with mock service generation fixes (#206)
- [ ] 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
1 parent 8db5504 commit 908b1f6

32 files changed

+2199
-11
lines changed

google-cloud-vpcaccess/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-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
import com.google.api.core.ApiFuture;
2020
import com.google.api.core.ApiFutures;
21+
import com.google.api.core.BetaApi;
2122
import com.google.api.gax.core.BackgroundResource;
23+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2224
import com.google.api.gax.longrunning.OperationFuture;
2325
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2426
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +32,6 @@
3032
import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStubSettings;
3133
import com.google.common.util.concurrent.MoreExecutors;
3234
import com.google.longrunning.Operation;
33-
import com.google.longrunning.OperationsClient;
3435
import com.google.protobuf.Empty;
3536
import java.io.IOException;
3637
import java.util.List;
@@ -106,13 +107,29 @@
106107
* VpcAccessServiceClient.create(vpcAccessServiceSettings);
107108
* }</pre>
108109
*
110+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
111+
* the wire:
112+
*
113+
* <pre>{@code
114+
* // This snippet has been automatically generated for illustrative purposes only.
115+
* // It may require modifications to work in your environment.
116+
* VpcAccessServiceSettings vpcAccessServiceSettings =
117+
* VpcAccessServiceSettings.newBuilder()
118+
* .setTransportChannelProvider(
119+
* VpcAccessServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
120+
* .build();
121+
* VpcAccessServiceClient vpcAccessServiceClient =
122+
* VpcAccessServiceClient.create(vpcAccessServiceSettings);
123+
* }</pre>
124+
*
109125
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
110126
*/
111127
@Generated("by gapic-generator-java")
112128
public class VpcAccessServiceClient implements BackgroundResource {
113129
private final VpcAccessServiceSettings settings;
114130
private final VpcAccessServiceStub stub;
115-
private final OperationsClient operationsClient;
131+
private final OperationsClient httpJsonOperationsClient;
132+
private final com.google.longrunning.OperationsClient operationsClient;
116133

117134
/** Constructs an instance of VpcAccessServiceClient with default settings. */
118135
public static final VpcAccessServiceClient create() throws IOException {
@@ -144,13 +161,17 @@ public static final VpcAccessServiceClient create(VpcAccessServiceStub stub) {
144161
protected VpcAccessServiceClient(VpcAccessServiceSettings settings) throws IOException {
145162
this.settings = settings;
146163
this.stub = ((VpcAccessServiceStubSettings) settings.getStubSettings()).createStub();
147-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
164+
this.operationsClient =
165+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
166+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
148167
}
149168

150169
protected VpcAccessServiceClient(VpcAccessServiceStub stub) {
151170
this.settings = null;
152171
this.stub = stub;
153-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
172+
this.operationsClient =
173+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
174+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
154175
}
155176

156177
public final VpcAccessServiceSettings getSettings() {
@@ -165,10 +186,19 @@ public VpcAccessServiceStub getStub() {
165186
* Returns the OperationsClient that can be used to query the status of a long-running operation
166187
* returned by another API method call.
167188
*/
168-
public final OperationsClient getOperationsClient() {
189+
public final com.google.longrunning.OperationsClient getOperationsClient() {
169190
return operationsClient;
170191
}
171192

193+
/**
194+
* Returns the OperationsClient that can be used to query the status of a long-running operation
195+
* returned by another API method call.
196+
*/
197+
@BetaApi
198+
public final OperationsClient getHttpJsonOperationsClient() {
199+
return httpJsonOperationsClient;
200+
}
201+
172202
// AUTO-GENERATED DOCUMENTATION AND METHOD.
173203
/**
174204
* Creates a Serverless VPC Access connector, returns an operation.

google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.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;
@@ -133,11 +134,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
133134
return VpcAccessServiceStubSettings.defaultCredentialsProviderBuilder();
134135
}
135136

136-
/** Returns a builder for the default ChannelProvider for this service. */
137+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
137138
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
138139
return VpcAccessServiceStubSettings.defaultGrpcTransportProviderBuilder();
139140
}
140141

142+
/** Returns a builder for the default REST ChannelProvider for this service. */
143+
@BetaApi
144+
public static InstantiatingHttpJsonChannelProvider.Builder
145+
defaultHttpJsonTransportProviderBuilder() {
146+
return VpcAccessServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
147+
}
148+
141149
public static TransportChannelProvider defaultTransportChannelProvider() {
142150
return VpcAccessServiceStubSettings.defaultTransportChannelProvider();
143151
}
@@ -147,11 +155,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
147155
return VpcAccessServiceStubSettings.defaultApiClientHeaderProviderBuilder();
148156
}
149157

150-
/** Returns a new builder for this class. */
158+
/** Returns a new gRPC builder for this class. */
151159
public static Builder newBuilder() {
152160
return Builder.createDefault();
153161
}
154162

163+
/** Returns a new REST builder for this class. */
164+
@BetaApi
165+
public static Builder newHttpJsonBuilder() {
166+
return Builder.createHttpJsonDefault();
167+
}
168+
155169
/** Returns a new builder for this class. */
156170
public static Builder newBuilder(ClientContext clientContext) {
157171
return new Builder(clientContext);
@@ -189,6 +203,11 @@ private static Builder createDefault() {
189203
return new Builder(VpcAccessServiceStubSettings.newBuilder());
190204
}
191205

206+
@BetaApi
207+
private static Builder createHttpJsonDefault() {
208+
return new Builder(VpcAccessServiceStubSettings.newHttpJsonBuilder());
209+
}
210+
192211
public VpcAccessServiceStubSettings.Builder getStubSettingsBuilder() {
193212
return ((VpcAccessServiceStubSettings.Builder) getStubSettings());
194213
}
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.vpcaccess.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 VpcAccessService service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonVpcAccessServiceCallableFactory
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)