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

Commit 6366fb2

Browse files
fix: update gapic-generator-java with mock service generation fixes (#184)
- [ ] 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: introduce a projects_missing_permissions field in the AbortInfo structure PiperOrigin-RevId: 457088244 Source-Link: googleapis/googleapis@dfefc95 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6258ccbb3baf50b94106400584326cc46d41e364 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjI1OGNjYmIzYmFmNTBiOTQxMDY0MDA1ODQzMjZjYzQ2ZDQxZTM2NCJ9 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 90ebfc5 commit 6366fb2

File tree

72 files changed

+5663
-111
lines changed

Some content is hidden

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

72 files changed

+5663
-111
lines changed

google-cloud-network-management/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-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.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.networkmanagement.v1.stub.ReachabilityServiceStubSettings;
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 com.google.protobuf.FieldMask;
3637
import java.io.IOException;
@@ -112,13 +113,29 @@
112113
* ReachabilityServiceClient.create(reachabilityServiceSettings);
113114
* }</pre>
114115
*
116+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
117+
* the wire:
118+
*
119+
* <pre>{@code
120+
* // This snippet has been automatically generated for illustrative purposes only.
121+
* // It may require modifications to work in your environment.
122+
* ReachabilityServiceSettings reachabilityServiceSettings =
123+
* ReachabilityServiceSettings.newBuilder()
124+
* .setTransportChannelProvider(
125+
* ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
126+
* .build();
127+
* ReachabilityServiceClient reachabilityServiceClient =
128+
* ReachabilityServiceClient.create(reachabilityServiceSettings);
129+
* }</pre>
130+
*
115131
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
116132
*/
117133
@Generated("by gapic-generator-java")
118134
public class ReachabilityServiceClient implements BackgroundResource {
119135
private final ReachabilityServiceSettings settings;
120136
private final ReachabilityServiceStub stub;
121-
private final OperationsClient operationsClient;
137+
private final OperationsClient httpJsonOperationsClient;
138+
private final com.google.longrunning.OperationsClient operationsClient;
122139

123140
/** Constructs an instance of ReachabilityServiceClient with default settings. */
124141
public static final ReachabilityServiceClient create() throws IOException {
@@ -150,13 +167,17 @@ public static final ReachabilityServiceClient create(ReachabilityServiceStub stu
150167
protected ReachabilityServiceClient(ReachabilityServiceSettings settings) throws IOException {
151168
this.settings = settings;
152169
this.stub = ((ReachabilityServiceStubSettings) settings.getStubSettings()).createStub();
153-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
170+
this.operationsClient =
171+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
172+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
154173
}
155174

156175
protected ReachabilityServiceClient(ReachabilityServiceStub stub) {
157176
this.settings = null;
158177
this.stub = stub;
159-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
178+
this.operationsClient =
179+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
180+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
160181
}
161182

162183
public final ReachabilityServiceSettings getSettings() {
@@ -171,10 +192,19 @@ public ReachabilityServiceStub getStub() {
171192
* Returns the OperationsClient that can be used to query the status of a long-running operation
172193
* returned by another API method call.
173194
*/
174-
public final OperationsClient getOperationsClient() {
195+
public final com.google.longrunning.OperationsClient getOperationsClient() {
175196
return operationsClient;
176197
}
177198

199+
/**
200+
* Returns the OperationsClient that can be used to query the status of a long-running operation
201+
* returned by another API method call.
202+
*/
203+
@BetaApi
204+
public final OperationsClient getHttpJsonOperationsClient() {
205+
return httpJsonOperationsClient;
206+
}
207+
178208
// AUTO-GENERATED DOCUMENTATION AND METHOD.
179209
/**
180210
* Lists all Connectivity Tests owned by a project.

google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.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;
@@ -168,11 +169,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
168169
return ReachabilityServiceStubSettings.defaultCredentialsProviderBuilder();
169170
}
170171

171-
/** Returns a builder for the default ChannelProvider for this service. */
172+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
172173
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
173174
return ReachabilityServiceStubSettings.defaultGrpcTransportProviderBuilder();
174175
}
175176

177+
/** Returns a builder for the default REST ChannelProvider for this service. */
178+
@BetaApi
179+
public static InstantiatingHttpJsonChannelProvider.Builder
180+
defaultHttpJsonTransportProviderBuilder() {
181+
return ReachabilityServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
182+
}
183+
176184
public static TransportChannelProvider defaultTransportChannelProvider() {
177185
return ReachabilityServiceStubSettings.defaultTransportChannelProvider();
178186
}
@@ -182,11 +190,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
182190
return ReachabilityServiceStubSettings.defaultApiClientHeaderProviderBuilder();
183191
}
184192

185-
/** Returns a new builder for this class. */
193+
/** Returns a new gRPC builder for this class. */
186194
public static Builder newBuilder() {
187195
return Builder.createDefault();
188196
}
189197

198+
/** Returns a new REST builder for this class. */
199+
@BetaApi
200+
public static Builder newHttpJsonBuilder() {
201+
return Builder.createHttpJsonDefault();
202+
}
203+
190204
/** Returns a new builder for this class. */
191205
public static Builder newBuilder(ClientContext clientContext) {
192206
return new Builder(clientContext);
@@ -224,6 +238,11 @@ private static Builder createDefault() {
224238
return new Builder(ReachabilityServiceStubSettings.newBuilder());
225239
}
226240

241+
@BetaApi
242+
private static Builder createHttpJsonDefault() {
243+
return new Builder(ReachabilityServiceStubSettings.newHttpJsonBuilder());
244+
}
245+
227246
public ReachabilityServiceStubSettings.Builder getStubSettingsBuilder() {
228247
return ((ReachabilityServiceStubSettings.Builder) getStubSettings());
229248
}
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.networkmanagement.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 ReachabilityService service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonReachabilityServiceCallableFactory
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)