Skip to content

Commit 69c179b

Browse files
fix: update gapic-generator-java with mock service generation fixes (googleapis#266)
* 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 7cb3c75 commit 69c179b

17 files changed

+7308
-89
lines changed

java-artifact-registry/google-cloud-artifact-registry/pom.xml

+16
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>
@@ -90,12 +94,24 @@
9094
<scope>test</scope>
9195
</dependency>
9296
<!-- Need testing utility classes for generated gRPC clients tests -->
97+
<dependency>
98+
<groupId>com.google.api</groupId>
99+
<artifactId>gax</artifactId>
100+
<classifier>testlib</classifier>
101+
<scope>test</scope>
102+
</dependency>
93103
<dependency>
94104
<groupId>com.google.api</groupId>
95105
<artifactId>gax-grpc</artifactId>
96106
<classifier>testlib</classifier>
97107
<scope>test</scope>
98108
</dependency>
109+
<dependency>
110+
<groupId>com.google.api</groupId>
111+
<artifactId>gax-httpjson</artifactId>
112+
<classifier>testlib</classifier>
113+
<scope>test</scope>
114+
</dependency>
99115
</dependencies>
100116

101117
<profiles>

java-artifact-registry/google-cloud-artifact-registry/src/main/java/com/google/devtools/artifactregistry/v1/ArtifactRegistryClient.java

+46-32
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;
@@ -36,7 +37,6 @@
3637
import com.google.iam.v1.TestIamPermissionsRequest;
3738
import com.google.iam.v1.TestIamPermissionsResponse;
3839
import com.google.longrunning.Operation;
39-
import com.google.longrunning.OperationsClient;
4040
import com.google.protobuf.Empty;
4141
import com.google.protobuf.FieldMask;
4242
import java.io.IOException;
@@ -125,13 +125,29 @@
125125
* ArtifactRegistryClient.create(artifactRegistrySettings);
126126
* }</pre>
127127
*
128+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
129+
* the wire:
130+
*
131+
* <pre>{@code
132+
* // This snippet has been automatically generated for illustrative purposes only.
133+
* // It may require modifications to work in your environment.
134+
* ArtifactRegistrySettings artifactRegistrySettings =
135+
* ArtifactRegistrySettings.newBuilder()
136+
* .setTransportChannelProvider(
137+
* ArtifactRegistrySettings.defaultHttpJsonTransportProviderBuilder().build())
138+
* .build();
139+
* ArtifactRegistryClient artifactRegistryClient =
140+
* ArtifactRegistryClient.create(artifactRegistrySettings);
141+
* }</pre>
142+
*
128143
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
129144
*/
130145
@Generated("by gapic-generator-java")
131146
public class ArtifactRegistryClient implements BackgroundResource {
132147
private final ArtifactRegistrySettings settings;
133148
private final ArtifactRegistryStub stub;
134-
private final OperationsClient operationsClient;
149+
private final OperationsClient httpJsonOperationsClient;
150+
private final com.google.longrunning.OperationsClient operationsClient;
135151

136152
/** Constructs an instance of ArtifactRegistryClient with default settings. */
137153
public static final ArtifactRegistryClient create() throws IOException {
@@ -151,7 +167,6 @@ public static final ArtifactRegistryClient create(ArtifactRegistrySettings setti
151167
* Constructs an instance of ArtifactRegistryClient, using the given stub for making calls. This
152168
* is for advanced usage - prefer using create(ArtifactRegistrySettings).
153169
*/
154-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
155170
public static final ArtifactRegistryClient create(ArtifactRegistryStub stub) {
156171
return new ArtifactRegistryClient(stub);
157172
}
@@ -164,21 +179,23 @@ public static final ArtifactRegistryClient create(ArtifactRegistryStub stub) {
164179
protected ArtifactRegistryClient(ArtifactRegistrySettings settings) throws IOException {
165180
this.settings = settings;
166181
this.stub = ((ArtifactRegistryStubSettings) settings.getStubSettings()).createStub();
167-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
182+
this.operationsClient =
183+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
184+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
168185
}
169186

170-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
171187
protected ArtifactRegistryClient(ArtifactRegistryStub stub) {
172188
this.settings = null;
173189
this.stub = stub;
174-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
190+
this.operationsClient =
191+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
192+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
175193
}
176194

177195
public final ArtifactRegistrySettings getSettings() {
178196
return settings;
179197
}
180198

181-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
182199
public ArtifactRegistryStub getStub() {
183200
return stub;
184201
}
@@ -187,10 +204,19 @@ public ArtifactRegistryStub getStub() {
187204
* Returns the OperationsClient that can be used to query the status of a long-running operation
188205
* returned by another API method call.
189206
*/
190-
public final OperationsClient getOperationsClient() {
207+
public final com.google.longrunning.OperationsClient getOperationsClient() {
191208
return operationsClient;
192209
}
193210

211+
/**
212+
* Returns the OperationsClient that can be used to query the status of a long-running operation
213+
* returned by another API method call.
214+
*/
215+
@BetaApi
216+
public final OperationsClient getHttpJsonOperationsClient() {
217+
return httpJsonOperationsClient;
218+
}
219+
194220
// AUTO-GENERATED DOCUMENTATION AND METHOD.
195221
/**
196222
* Lists docker images.
@@ -295,7 +321,7 @@ public final ListDockerImagesPagedResponse listDockerImages(ListDockerImagesRequ
295321
* while (true) {
296322
* ListDockerImagesResponse response =
297323
* artifactRegistryClient.listDockerImagesCallable().call(request);
298-
* for (DockerImage element : response.getResponsesList()) {
324+
* for (DockerImage element : response.getDockerImagesList()) {
299325
* // doThingsWith(element);
300326
* }
301327
* String nextPageToken = response.getNextPageToken();
@@ -707,7 +733,7 @@ public final ListRepositoriesPagedResponse listRepositories(ListRepositoriesRequ
707733
* while (true) {
708734
* ListRepositoriesResponse response =
709735
* artifactRegistryClient.listRepositoriesCallable().call(request);
710-
* for (Repository element : response.getResponsesList()) {
736+
* for (Repository element : response.getRepositoriesList()) {
711737
* // doThingsWith(element);
712738
* }
713739
* String nextPageToken = response.getNextPageToken();
@@ -1297,7 +1323,7 @@ public final ListPackagesPagedResponse listPackages(ListPackagesRequest request)
12971323
* .build();
12981324
* while (true) {
12991325
* ListPackagesResponse response = artifactRegistryClient.listPackagesCallable().call(request);
1300-
* for (Package element : response.getResponsesList()) {
1326+
* for (Package element : response.getPackagesList()) {
13011327
* // doThingsWith(element);
13021328
* }
13031329
* String nextPageToken = response.getNextPageToken();
@@ -1586,7 +1612,7 @@ public final ListVersionsPagedResponse listVersions(ListVersionsRequest request)
15861612
* .build();
15871613
* while (true) {
15881614
* ListVersionsResponse response = artifactRegistryClient.listVersionsCallable().call(request);
1589-
* for (Version element : response.getResponsesList()) {
1615+
* for (Version element : response.getVersionsList()) {
15901616
* // doThingsWith(element);
15911617
* }
15921618
* String nextPageToken = response.getNextPageToken();
@@ -1882,7 +1908,7 @@ public final UnaryCallable<ListFilesRequest, ListFilesPagedResponse> listFilesPa
18821908
* .build();
18831909
* while (true) {
18841910
* ListFilesResponse response = artifactRegistryClient.listFilesCallable().call(request);
1885-
* for (File element : response.getResponsesList()) {
1911+
* for (File element : response.getFilesList()) {
18861912
* // doThingsWith(element);
18871913
* }
18881914
* String nextPageToken = response.getNextPageToken();
@@ -2068,7 +2094,7 @@ public final UnaryCallable<ListTagsRequest, ListTagsPagedResponse> listTagsPaged
20682094
* .build();
20692095
* while (true) {
20702096
* ListTagsResponse response = artifactRegistryClient.listTagsCallable().call(request);
2071-
* for (Tag element : response.getResponsesList()) {
2097+
* for (Tag element : response.getTagsList()) {
20722098
* // doThingsWith(element);
20732099
* }
20742100
* String nextPageToken = response.getNextPageToken();
@@ -2388,9 +2414,7 @@ public final UnaryCallable<DeleteTagRequest, Empty> deleteTagCallable() {
23882414
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
23892415
* SetIamPolicyRequest request =
23902416
* SetIamPolicyRequest.newBuilder()
2391-
* .setResource(
2392-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2393-
* .toString())
2417+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
23942418
* .setPolicy(Policy.newBuilder().build())
23952419
* .setUpdateMask(FieldMask.newBuilder().build())
23962420
* .build();
@@ -2417,9 +2441,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
24172441
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
24182442
* SetIamPolicyRequest request =
24192443
* SetIamPolicyRequest.newBuilder()
2420-
* .setResource(
2421-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2422-
* .toString())
2444+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
24232445
* .setPolicy(Policy.newBuilder().build())
24242446
* .setUpdateMask(FieldMask.newBuilder().build())
24252447
* .build();
@@ -2445,9 +2467,7 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
24452467
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
24462468
* GetIamPolicyRequest request =
24472469
* GetIamPolicyRequest.newBuilder()
2448-
* .setResource(
2449-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2450-
* .toString())
2470+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
24512471
* .setOptions(GetPolicyOptions.newBuilder().build())
24522472
* .build();
24532473
* Policy response = artifactRegistryClient.getIamPolicy(request);
@@ -2473,9 +2493,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
24732493
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
24742494
* GetIamPolicyRequest request =
24752495
* GetIamPolicyRequest.newBuilder()
2476-
* .setResource(
2477-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2478-
* .toString())
2496+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
24792497
* .setOptions(GetPolicyOptions.newBuilder().build())
24802498
* .build();
24812499
* ApiFuture<Policy> future = artifactRegistryClient.getIamPolicyCallable().futureCall(request);
@@ -2500,9 +2518,7 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
25002518
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
25012519
* TestIamPermissionsRequest request =
25022520
* TestIamPermissionsRequest.newBuilder()
2503-
* .setResource(
2504-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2505-
* .toString())
2521+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
25062522
* .addAllPermissions(new ArrayList<String>())
25072523
* .build();
25082524
* TestIamPermissionsResponse response = artifactRegistryClient.testIamPermissions(request);
@@ -2528,9 +2544,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
25282544
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
25292545
* TestIamPermissionsRequest request =
25302546
* TestIamPermissionsRequest.newBuilder()
2531-
* .setResource(
2532-
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
2533-
* .toString())
2547+
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
25342548
* .addAllPermissions(new ArrayList<String>())
25352549
* .build();
25362550
* ApiFuture<TestIamPermissionsResponse> future =

java-artifact-registry/google-cloud-artifact-registry/src/main/java/com/google/devtools/artifactregistry/v1/ArtifactRegistrySettings.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.api.gax.core.GoogleCredentialsProvider;
2929
import com.google.api.gax.core.InstantiatingExecutorProvider;
3030
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
31+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
3132
import com.google.api.gax.rpc.ApiClientHeaderProvider;
3233
import com.google.api.gax.rpc.ClientContext;
3334
import com.google.api.gax.rpc.ClientSettings;
@@ -294,11 +295,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
294295
return ArtifactRegistryStubSettings.defaultCredentialsProviderBuilder();
295296
}
296297

297-
/** Returns a builder for the default ChannelProvider for this service. */
298+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
298299
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
299300
return ArtifactRegistryStubSettings.defaultGrpcTransportProviderBuilder();
300301
}
301302

303+
/** Returns a builder for the default REST ChannelProvider for this service. */
304+
@BetaApi
305+
public static InstantiatingHttpJsonChannelProvider.Builder
306+
defaultHttpJsonTransportProviderBuilder() {
307+
return ArtifactRegistryStubSettings.defaultHttpJsonTransportProviderBuilder();
308+
}
309+
302310
public static TransportChannelProvider defaultTransportChannelProvider() {
303311
return ArtifactRegistryStubSettings.defaultTransportChannelProvider();
304312
}
@@ -308,11 +316,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
308316
return ArtifactRegistryStubSettings.defaultApiClientHeaderProviderBuilder();
309317
}
310318

311-
/** Returns a new builder for this class. */
319+
/** Returns a new gRPC builder for this class. */
312320
public static Builder newBuilder() {
313321
return Builder.createDefault();
314322
}
315323

324+
/** Returns a new REST builder for this class. */
325+
@BetaApi
326+
public static Builder newHttpJsonBuilder() {
327+
return Builder.createHttpJsonDefault();
328+
}
329+
316330
/** Returns a new builder for this class. */
317331
public static Builder newBuilder(ClientContext clientContext) {
318332
return new Builder(clientContext);
@@ -350,6 +364,11 @@ private static Builder createDefault() {
350364
return new Builder(ArtifactRegistryStubSettings.newBuilder());
351365
}
352366

367+
@BetaApi
368+
private static Builder createHttpJsonDefault() {
369+
return new Builder(ArtifactRegistryStubSettings.newHttpJsonBuilder());
370+
}
371+
353372
public ArtifactRegistryStubSettings.Builder getStubSettingsBuilder() {
354373
return ((ArtifactRegistryStubSettings.Builder) getStubSettings());
355374
}

java-artifact-registry/google-cloud-artifact-registry/src/main/java/com/google/devtools/artifactregistry/v1/stub/ArtifactRegistryStub.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@
8888
public abstract class ArtifactRegistryStub implements BackgroundResource {
8989

9090
public OperationsStub getOperationsStub() {
91-
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
91+
return null;
92+
}
93+
94+
public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
95+
return null;
9296
}
9397

9498
public UnaryCallable<ListDockerImagesRequest, ListDockerImagesPagedResponse>

0 commit comments

Comments
 (0)