Skip to content

Commit 7e231d1

Browse files
chore: update gapic-generator-java (#239)
* 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: Add Java REST transport to analytics, servicecontrol, servicemanagement, serviceusage and langauge APIs PiperOrigin-RevId: 454254635 Source-Link: googleapis/googleapis@84fb822 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ffb61264d6fb634c430829dd2da75c5bed08304 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZmYjYxMjY0ZDZmYjYzNGM0MzA4MjlkZDJkYTc1YzViZWQwODMwNCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: update gapic-generator-java PiperOrigin-RevId: 454939894 Source-Link: googleapis/googleapis@519ca44 Source-Link: https://github.com/googleapis/googleapis-gen/commit/fc639d21a7cbc30aa0a9b862586942a0fb46c5c8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZmM2MzlkMjFhN2NiYzMwYWEwYTliODYyNTg2OTQyYTBmYjQ2YzVjOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update pom.xml * Update pom.xml * Update pom.xml Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Neenu Shaji <Neenu1995@users.noreply.github.com>
1 parent d16c304 commit 7e231d1

15 files changed

Lines changed: 4135 additions & 27 deletions

java-service-usage/google-cloud-service-usage/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>

java-service-usage/google-cloud-service-usage/src/main/java/com/google/api/serviceusage/v1/ServiceUsageClient.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.core.ApiFuture;
2020
import com.google.api.core.ApiFutures;
2121
import com.google.api.gax.core.BackgroundResource;
22+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2223
import com.google.api.gax.longrunning.OperationFuture;
2324
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2425
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +31,6 @@
3031
import com.google.api.serviceusage.v1.stub.ServiceUsageStubSettings;
3132
import com.google.common.util.concurrent.MoreExecutors;
3233
import com.google.longrunning.Operation;
33-
import com.google.longrunning.OperationsClient;
3434
import java.io.IOException;
3535
import java.util.List;
3636
import java.util.concurrent.TimeUnit;
@@ -104,13 +104,28 @@
104104
* ServiceUsageClient serviceUsageClient = ServiceUsageClient.create(serviceUsageSettings);
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+
* ServiceUsageSettings serviceUsageSettings =
114+
* ServiceUsageSettings.newBuilder()
115+
* .setTransportChannelProvider(
116+
* ServiceUsageSettings.defaultHttpJsonTransportProviderBuilder().build())
117+
* .build();
118+
* ServiceUsageClient serviceUsageClient = ServiceUsageClient.create(serviceUsageSettings);
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 ServiceUsageClient implements BackgroundResource {
111125
private final ServiceUsageSettings settings;
112126
private final ServiceUsageStub 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 ServiceUsageClient with default settings. */
116131
public static final ServiceUsageClient create() throws IOException {
@@ -141,13 +156,17 @@ public static final ServiceUsageClient create(ServiceUsageStub stub) {
141156
protected ServiceUsageClient(ServiceUsageSettings settings) throws IOException {
142157
this.settings = settings;
143158
this.stub = ((ServiceUsageStubSettings) settings.getStubSettings()).createStub();
144-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
159+
this.operationsClient =
160+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
161+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
145162
}
146163

147164
protected ServiceUsageClient(ServiceUsageStub stub) {
148165
this.settings = null;
149166
this.stub = stub;
150-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
167+
this.operationsClient =
168+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
169+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
151170
}
152171

153172
public final ServiceUsageSettings getSettings() {
@@ -162,10 +181,18 @@ public ServiceUsageStub getStub() {
162181
* Returns the OperationsClient that can be used to query the status of a long-running operation
163182
* returned by another API method call.
164183
*/
165-
public final OperationsClient getOperationsClient() {
184+
public final com.google.longrunning.OperationsClient getOperationsClient() {
166185
return operationsClient;
167186
}
168187

188+
/**
189+
* Returns the OperationsClient that can be used to query the status of a long-running operation
190+
* returned by another API method call.
191+
*/
192+
public final OperationsClient getHttpJsonOperationsClient() {
193+
return httpJsonOperationsClient;
194+
}
195+
169196
// AUTO-GENERATED DOCUMENTATION AND METHOD.
170197
/**
171198
* Enable a service so that it can be used with a project.
@@ -477,7 +504,7 @@ public final ListServicesPagedResponse listServices(ListServicesRequest request)
477504
* .build();
478505
* while (true) {
479506
* ListServicesResponse response = serviceUsageClient.listServicesCallable().call(request);
480-
* for (Service element : response.getResponsesList()) {
507+
* for (Service element : response.getServicesList()) {
481508
* // doThingsWith(element);
482509
* }
483510
* String nextPageToken = response.getNextPageToken();

java-service-usage/google-cloud-service-usage/src/main/java/com/google/api/serviceusage/v1/ServiceUsageSettings.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;
@@ -148,11 +149,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
148149
return ServiceUsageStubSettings.defaultCredentialsProviderBuilder();
149150
}
150151

151-
/** Returns a builder for the default ChannelProvider for this service. */
152+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
152153
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
153154
return ServiceUsageStubSettings.defaultGrpcTransportProviderBuilder();
154155
}
155156

157+
/** Returns a builder for the default REST ChannelProvider for this service. */
158+
@BetaApi
159+
public static InstantiatingHttpJsonChannelProvider.Builder
160+
defaultHttpJsonTransportProviderBuilder() {
161+
return ServiceUsageStubSettings.defaultHttpJsonTransportProviderBuilder();
162+
}
163+
156164
public static TransportChannelProvider defaultTransportChannelProvider() {
157165
return ServiceUsageStubSettings.defaultTransportChannelProvider();
158166
}
@@ -162,11 +170,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
162170
return ServiceUsageStubSettings.defaultApiClientHeaderProviderBuilder();
163171
}
164172

165-
/** Returns a new builder for this class. */
173+
/** Returns a new gRPC builder for this class. */
166174
public static Builder newBuilder() {
167175
return Builder.createDefault();
168176
}
169177

178+
/** Returns a new REST builder for this class. */
179+
@BetaApi
180+
public static Builder newHttpJsonBuilder() {
181+
return Builder.createHttpJsonDefault();
182+
}
183+
170184
/** Returns a new builder for this class. */
171185
public static Builder newBuilder(ClientContext clientContext) {
172186
return new Builder(clientContext);
@@ -204,6 +218,11 @@ private static Builder createDefault() {
204218
return new Builder(ServiceUsageStubSettings.newBuilder());
205219
}
206220

221+
@BetaApi
222+
private static Builder createHttpJsonDefault() {
223+
return new Builder(ServiceUsageStubSettings.newHttpJsonBuilder());
224+
}
225+
207226
public ServiceUsageStubSettings.Builder getStubSettingsBuilder() {
208227
return ((ServiceUsageStubSettings.Builder) getStubSettings());
209228
}
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.api.serviceusage.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 ServiceUsage service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonServiceUsageCallableFactory
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)