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

Commit 2482f22

Browse files
fix: update gapic-generator-java with mock service generation fixes (#118)
* 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update pom.xml * fix: update gapic-generator-java with mock service generation fixes PiperOrigin-RevId: 457524730 Source-Link: googleapis/googleapis@917e7f2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Neenu Shaji <[email protected]>
1 parent d483cd3 commit 2482f22

File tree

95 files changed

+7680
-19
lines changed

Some content is hidden

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

95 files changed

+7680
-19
lines changed

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

Lines changed: 37 additions & 12 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.deploy.v1.stub.CloudDeployStubSettings;
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;
@@ -105,13 +105,28 @@
105105
* CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings);
106106
* }</pre>
107107
*
108+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
109+
* the wire:
110+
*
111+
* <pre>{@code
112+
* // This snippet has been automatically generated for illustrative purposes only.
113+
* // It may require modifications to work in your environment.
114+
* CloudDeploySettings cloudDeploySettings =
115+
* CloudDeploySettings.newBuilder()
116+
* .setTransportChannelProvider(
117+
* CloudDeploySettings.defaultHttpJsonTransportProviderBuilder().build())
118+
* .build();
119+
* CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings);
120+
* }</pre>
121+
*
108122
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
109123
*/
110124
@Generated("by gapic-generator-java")
111125
public class CloudDeployClient implements BackgroundResource {
112126
private final CloudDeploySettings settings;
113127
private final CloudDeployStub stub;
114-
private final OperationsClient operationsClient;
128+
private final OperationsClient httpJsonOperationsClient;
129+
private final com.google.longrunning.OperationsClient operationsClient;
115130

116131
/** Constructs an instance of CloudDeployClient with default settings. */
117132
public static final CloudDeployClient create() throws IOException {
@@ -130,7 +145,6 @@ public static final CloudDeployClient create(CloudDeploySettings settings) throw
130145
* Constructs an instance of CloudDeployClient, using the given stub for making calls. This is for
131146
* advanced usage - prefer using create(CloudDeploySettings).
132147
*/
133-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
134148
public static final CloudDeployClient create(CloudDeployStub stub) {
135149
return new CloudDeployClient(stub);
136150
}
@@ -143,21 +157,23 @@ public static final CloudDeployClient create(CloudDeployStub stub) {
143157
protected CloudDeployClient(CloudDeploySettings settings) throws IOException {
144158
this.settings = settings;
145159
this.stub = ((CloudDeployStubSettings) settings.getStubSettings()).createStub();
146-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
160+
this.operationsClient =
161+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
162+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
147163
}
148164

149-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
150165
protected CloudDeployClient(CloudDeployStub stub) {
151166
this.settings = null;
152167
this.stub = stub;
153-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
168+
this.operationsClient =
169+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
170+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
154171
}
155172

156173
public final CloudDeploySettings getSettings() {
157174
return settings;
158175
}
159176

160-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
161177
public CloudDeployStub getStub() {
162178
return stub;
163179
}
@@ -166,10 +182,19 @@ public CloudDeployStub getStub() {
166182
* Returns the OperationsClient that can be used to query the status of a long-running operation
167183
* returned by another API method call.
168184
*/
169-
public final OperationsClient getOperationsClient() {
185+
public final com.google.longrunning.OperationsClient getOperationsClient() {
170186
return operationsClient;
171187
}
172188

189+
/**
190+
* Returns the OperationsClient that can be used to query the status of a long-running operation
191+
* returned by another API method call.
192+
*/
193+
@BetaApi
194+
public final OperationsClient getHttpJsonOperationsClient() {
195+
return httpJsonOperationsClient;
196+
}
197+
173198
// AUTO-GENERATED DOCUMENTATION AND METHOD.
174199
/**
175200
* Lists DeliveryPipelines in a given project and location.
@@ -314,7 +339,7 @@ public final ListDeliveryPipelinesPagedResponse listDeliveryPipelines(
314339
* while (true) {
315340
* ListDeliveryPipelinesResponse response =
316341
* cloudDeployClient.listDeliveryPipelinesCallable().call(request);
317-
* for (DeliveryPipeline element : response.getResponsesList()) {
342+
* for (DeliveryPipeline element : response.getDeliveryPipelinesList()) {
318343
* // doThingsWith(element);
319344
* }
320345
* String nextPageToken = response.getNextPageToken();
@@ -1020,7 +1045,7 @@ public final ListTargetsPagedResponse listTargets(ListTargetsRequest request) {
10201045
* .build();
10211046
* while (true) {
10221047
* ListTargetsResponse response = cloudDeployClient.listTargetsCallable().call(request);
1023-
* for (Target element : response.getResponsesList()) {
1048+
* for (Target element : response.getTargetsList()) {
10241049
* // doThingsWith(element);
10251050
* }
10261051
* String nextPageToken = response.getNextPageToken();
@@ -1689,7 +1714,7 @@ public final ListReleasesPagedResponse listReleases(ListReleasesRequest request)
16891714
* .build();
16901715
* while (true) {
16911716
* ListReleasesResponse response = cloudDeployClient.listReleasesCallable().call(request);
1692-
* for (Release element : response.getResponsesList()) {
1717+
* for (Release element : response.getReleasesList()) {
16931718
* // doThingsWith(element);
16941719
* }
16951720
* String nextPageToken = response.getNextPageToken();
@@ -2241,7 +2266,7 @@ public final ListRolloutsPagedResponse listRollouts(ListRolloutsRequest request)
22412266
* .build();
22422267
* while (true) {
22432268
* ListRolloutsResponse response = cloudDeployClient.listRolloutsCallable().call(request);
2244-
* for (Rollout element : response.getResponsesList()) {
2269+
* for (Rollout element : response.getRolloutsList()) {
22452270
* // doThingsWith(element);
22462271
* }
22472272
* String nextPageToken = response.getNextPageToken();

google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeploySettings.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.api.gax.core.GoogleCredentialsProvider;
2727
import com.google.api.gax.core.InstantiatingExecutorProvider;
2828
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
29+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2930
import com.google.api.gax.rpc.ApiClientHeaderProvider;
3031
import com.google.api.gax.rpc.ClientContext;
3132
import com.google.api.gax.rpc.ClientSettings;
@@ -249,11 +250,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
249250
return CloudDeployStubSettings.defaultCredentialsProviderBuilder();
250251
}
251252

252-
/** Returns a builder for the default ChannelProvider for this service. */
253+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
253254
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
254255
return CloudDeployStubSettings.defaultGrpcTransportProviderBuilder();
255256
}
256257

258+
/** Returns a builder for the default REST ChannelProvider for this service. */
259+
@BetaApi
260+
public static InstantiatingHttpJsonChannelProvider.Builder
261+
defaultHttpJsonTransportProviderBuilder() {
262+
return CloudDeployStubSettings.defaultHttpJsonTransportProviderBuilder();
263+
}
264+
257265
public static TransportChannelProvider defaultTransportChannelProvider() {
258266
return CloudDeployStubSettings.defaultTransportChannelProvider();
259267
}
@@ -263,11 +271,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
263271
return CloudDeployStubSettings.defaultApiClientHeaderProviderBuilder();
264272
}
265273

266-
/** Returns a new builder for this class. */
274+
/** Returns a new gRPC builder for this class. */
267275
public static Builder newBuilder() {
268276
return Builder.createDefault();
269277
}
270278

279+
/** Returns a new REST builder for this class. */
280+
@BetaApi
281+
public static Builder newHttpJsonBuilder() {
282+
return Builder.createHttpJsonDefault();
283+
}
284+
271285
/** Returns a new builder for this class. */
272286
public static Builder newBuilder(ClientContext clientContext) {
273287
return new Builder(clientContext);
@@ -305,6 +319,11 @@ private static Builder createDefault() {
305319
return new Builder(CloudDeployStubSettings.newBuilder());
306320
}
307321

322+
@BetaApi
323+
private static Builder createHttpJsonDefault() {
324+
return new Builder(CloudDeployStubSettings.newHttpJsonBuilder());
325+
}
326+
308327
public CloudDeployStubSettings.Builder getStubSettingsBuilder() {
309328
return ((CloudDeployStubSettings.Builder) getStubSettings());
310329
}

google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStub.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@
6868
public abstract class CloudDeployStub implements BackgroundResource {
6969

7070
public OperationsStub getOperationsStub() {
71-
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
71+
return null;
72+
}
73+
74+
public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
75+
return null;
7276
}
7377

7478
public UnaryCallable<ListDeliveryPipelinesRequest, ListDeliveryPipelinesPagedResponse>

google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStubSettings.java

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
import com.google.api.gax.grpc.GrpcTransportChannel;
3232
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
3333
import com.google.api.gax.grpc.ProtoOperationTransformers;
34+
import com.google.api.gax.httpjson.GaxHttpJsonProperties;
35+
import com.google.api.gax.httpjson.HttpJsonTransportChannel;
36+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
3437
import com.google.api.gax.longrunning.OperationSnapshot;
3538
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
3639
import com.google.api.gax.retrying.RetrySettings;
@@ -551,13 +554,17 @@ public UnaryCallSettings<GetConfigRequest, Config> getConfigSettings() {
551554
return getConfigSettings;
552555
}
553556

554-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
555557
public CloudDeployStub createStub() throws IOException {
556558
if (getTransportChannelProvider()
557559
.getTransportName()
558560
.equals(GrpcTransportChannel.getGrpcTransportName())) {
559561
return GrpcCloudDeployStub.create(this);
560562
}
563+
if (getTransportChannelProvider()
564+
.getTransportName()
565+
.equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
566+
return HttpJsonCloudDeployStub.create(this);
567+
}
561568
throw new UnsupportedOperationException(
562569
String.format(
563570
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -590,30 +597,56 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
590597
.setUseJwtAccessWithScope(true);
591598
}
592599

593-
/** Returns a builder for the default ChannelProvider for this service. */
600+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
594601
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
595602
return InstantiatingGrpcChannelProvider.newBuilder()
596603
.setMaxInboundMessageSize(Integer.MAX_VALUE);
597604
}
598605

606+
/** Returns a builder for the default REST ChannelProvider for this service. */
607+
@BetaApi
608+
public static InstantiatingHttpJsonChannelProvider.Builder
609+
defaultHttpJsonTransportProviderBuilder() {
610+
return InstantiatingHttpJsonChannelProvider.newBuilder();
611+
}
612+
599613
public static TransportChannelProvider defaultTransportChannelProvider() {
600614
return defaultGrpcTransportProviderBuilder().build();
601615
}
602616

603617
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
604-
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
618+
public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
605619
return ApiClientHeaderProvider.newBuilder()
606620
.setGeneratedLibToken(
607621
"gapic", GaxProperties.getLibraryVersion(CloudDeployStubSettings.class))
608622
.setTransportToken(
609623
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
610624
}
611625

612-
/** Returns a new builder for this class. */
626+
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
627+
public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
628+
return ApiClientHeaderProvider.newBuilder()
629+
.setGeneratedLibToken(
630+
"gapic", GaxProperties.getLibraryVersion(CloudDeployStubSettings.class))
631+
.setTransportToken(
632+
GaxHttpJsonProperties.getHttpJsonTokenName(),
633+
GaxHttpJsonProperties.getHttpJsonVersion());
634+
}
635+
636+
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
637+
return CloudDeployStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
638+
}
639+
640+
/** Returns a new gRPC builder for this class. */
613641
public static Builder newBuilder() {
614642
return Builder.createDefault();
615643
}
616644

645+
/** Returns a new REST builder for this class. */
646+
public static Builder newHttpJsonBuilder() {
647+
return Builder.createHttpJsonDefault();
648+
}
649+
617650
/** Returns a new builder for this class. */
618651
public static Builder newBuilder(ClientContext clientContext) {
619652
return new Builder(clientContext);
@@ -880,6 +913,19 @@ private static Builder createDefault() {
880913
return initDefaults(builder);
881914
}
882915

916+
private static Builder createHttpJsonDefault() {
917+
Builder builder = new Builder(((ClientContext) null));
918+
919+
builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
920+
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
921+
builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
922+
builder.setEndpoint(getDefaultEndpoint());
923+
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
924+
builder.setSwitchToMtlsEndpointAllowed(true);
925+
926+
return initDefaults(builder);
927+
}
928+
883929
private static Builder initDefaults(Builder builder) {
884930
builder
885931
.listDeliveryPipelinesSettings()

0 commit comments

Comments
 (0)