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

fix: update gapic-generator-java with mock service generation fixes #266

Merged
merged 10 commits into from
Jun 28, 2022
16 changes: 16 additions & 0 deletions google-cloud-artifact-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
Expand Down Expand Up @@ -90,12 +94,24 @@
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
Expand All @@ -36,7 +36,6 @@
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
Expand Down Expand Up @@ -125,13 +124,29 @@
* ArtifactRegistryClient.create(artifactRegistrySettings);
* }</pre>
*
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* ArtifactRegistrySettings artifactRegistrySettings =
* ArtifactRegistrySettings.newBuilder()
* .setTransportChannelProvider(
* ArtifactRegistrySettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* ArtifactRegistryClient artifactRegistryClient =
* ArtifactRegistryClient.create(artifactRegistrySettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class ArtifactRegistryClient implements BackgroundResource {
private final ArtifactRegistrySettings settings;
private final ArtifactRegistryStub stub;
private final OperationsClient operationsClient;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;

/** Constructs an instance of ArtifactRegistryClient with default settings. */
public static final ArtifactRegistryClient create() throws IOException {
Expand All @@ -151,7 +166,6 @@ public static final ArtifactRegistryClient create(ArtifactRegistrySettings setti
* Constructs an instance of ArtifactRegistryClient, using the given stub for making calls. This
* is for advanced usage - prefer using create(ArtifactRegistrySettings).
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final ArtifactRegistryClient create(ArtifactRegistryStub stub) {
return new ArtifactRegistryClient(stub);
}
Expand All @@ -164,21 +178,23 @@ public static final ArtifactRegistryClient create(ArtifactRegistryStub stub) {
protected ArtifactRegistryClient(ArtifactRegistrySettings settings) throws IOException {
this.settings = settings;
this.stub = ((ArtifactRegistryStubSettings) settings.getStubSettings()).createStub();
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected ArtifactRegistryClient(ArtifactRegistryStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

public final ArtifactRegistrySettings getSettings() {
return settings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public ArtifactRegistryStub getStub() {
return stub;
}
Expand All @@ -187,10 +203,18 @@ public ArtifactRegistryStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final OperationsClient getOperationsClient() {
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}

/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists docker images.
Expand Down Expand Up @@ -295,7 +319,7 @@ public final ListDockerImagesPagedResponse listDockerImages(ListDockerImagesRequ
* while (true) {
* ListDockerImagesResponse response =
* artifactRegistryClient.listDockerImagesCallable().call(request);
* for (DockerImage element : response.getResponsesList()) {
* for (DockerImage element : response.getDockerImagesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -707,7 +731,7 @@ public final ListRepositoriesPagedResponse listRepositories(ListRepositoriesRequ
* while (true) {
* ListRepositoriesResponse response =
* artifactRegistryClient.listRepositoriesCallable().call(request);
* for (Repository element : response.getResponsesList()) {
* for (Repository element : response.getRepositoriesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -1297,7 +1321,7 @@ public final ListPackagesPagedResponse listPackages(ListPackagesRequest request)
* .build();
* while (true) {
* ListPackagesResponse response = artifactRegistryClient.listPackagesCallable().call(request);
* for (Package element : response.getResponsesList()) {
* for (Package element : response.getPackagesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -1586,7 +1610,7 @@ public final ListVersionsPagedResponse listVersions(ListVersionsRequest request)
* .build();
* while (true) {
* ListVersionsResponse response = artifactRegistryClient.listVersionsCallable().call(request);
* for (Version element : response.getResponsesList()) {
* for (Version element : response.getVersionsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -1882,7 +1906,7 @@ public final UnaryCallable<ListFilesRequest, ListFilesPagedResponse> listFilesPa
* .build();
* while (true) {
* ListFilesResponse response = artifactRegistryClient.listFilesCallable().call(request);
* for (File element : response.getResponsesList()) {
* for (File element : response.getFilesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -2068,7 +2092,7 @@ public final UnaryCallable<ListTagsRequest, ListTagsPagedResponse> listTagsPaged
* .build();
* while (true) {
* ListTagsResponse response = artifactRegistryClient.listTagsCallable().call(request);
* for (Tag element : response.getResponsesList()) {
* for (Tag element : response.getTagsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -2388,9 +2412,7 @@ public final UnaryCallable<DeleteTagRequest, Empty> deleteTagCallable() {
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
Expand All @@ -2417,9 +2439,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
Expand All @@ -2445,9 +2465,7 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* Policy response = artifactRegistryClient.getIamPolicy(request);
Expand All @@ -2473,9 +2491,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* ApiFuture<Policy> future = artifactRegistryClient.getIamPolicyCallable().futureCall(request);
Expand All @@ -2500,9 +2516,7 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* TestIamPermissionsResponse response = artifactRegistryClient.testIamPermissions(request);
Expand All @@ -2528,9 +2542,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
* try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(
* DockerImageName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]", "[DOCKER_IMAGE]")
* .toString())
* .setResource(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* ApiFuture<TestIamPermissionsResponse> future =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
Expand Down Expand Up @@ -294,11 +295,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return ArtifactRegistryStubSettings.defaultCredentialsProviderBuilder();
}

/** Returns a builder for the default ChannelProvider for this service. */
/** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return ArtifactRegistryStubSettings.defaultGrpcTransportProviderBuilder();
}

/** Returns a builder for the default REST ChannelProvider for this service. */
@BetaApi
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return ArtifactRegistryStubSettings.defaultHttpJsonTransportProviderBuilder();
}

public static TransportChannelProvider defaultTransportChannelProvider() {
return ArtifactRegistryStubSettings.defaultTransportChannelProvider();
}
Expand All @@ -308,11 +316,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return ArtifactRegistryStubSettings.defaultApiClientHeaderProviderBuilder();
}

/** Returns a new builder for this class. */
/** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}

/** Returns a new REST builder for this class. */
@BetaApi
public static Builder newHttpJsonBuilder() {
return Builder.createHttpJsonDefault();
}

/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
Expand Down Expand Up @@ -350,6 +364,11 @@ private static Builder createDefault() {
return new Builder(ArtifactRegistryStubSettings.newBuilder());
}

@BetaApi
private static Builder createHttpJsonDefault() {
return new Builder(ArtifactRegistryStubSettings.newHttpJsonBuilder());
}

public ArtifactRegistryStubSettings.Builder getStubSettingsBuilder() {
return ((ArtifactRegistryStubSettings.Builder) getStubSettings());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
public abstract class ArtifactRegistryStub implements BackgroundResource {

public OperationsStub getOperationsStub() {
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
return null;
}

public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
return null;
}

public UnaryCallable<ListDockerImagesRequest, ListDockerImagesPagedResponse>
Expand Down
Loading