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

feat: Enable REST transport for most of Java and Go clients #885

Merged
merged 13 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .kokoro/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function completenessCheck() {
# This is stripped from the output as it is not present in the flattened pom.
# Only dependencies with 'compile' or 'runtime' scope are included from original dependency list.
msg "Generating dependency list using original pom..."
mvn dependency:list -f pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e 's/ --.*//' >.org-list.txt
mvn dependency:list -f pom.xml -DexcludeArtifactIds=commons-codec,commons-logging,opencensus-api,opencensus-contrib-http-util,httpclient,httpcore -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e 's/ --.*//' >.org-list.txt

# Output dep list generated using the flattened pom (only 'compile' and 'runtime' scopes)
msg "Generating dependency list using flattened pom..."
mvn dependency:list -f .flattened-pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt
mvn dependency:list -f .flattened-pom.xml -DexcludeArtifactIds=commons-codec,commons-logging,opencensus-api,opencensus-contrib-http-util,httpclient,httpcore -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt

# Compare two dependency lists
msg "Comparing dependency lists..."
Expand Down
16 changes: 16 additions & 0 deletions google-cloud-containeranalysis/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 @@ -93,12 +97,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 @@ -16,7 +16,6 @@

package com.google.cloud.devtools.containeranalysis.v1;

import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.api.resourcenames.ResourceName;
Expand Down Expand Up @@ -57,7 +56,25 @@
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* ResourceName resource =
* new ResourceName() {
* {@literal @}Override
* public Map<String, String> getFieldValuesMap() {
* Map<String, String> fieldValuesMap = new HashMap<>();
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
* return fieldValuesMap;
* }
*
* {@literal @}Override
* public String getFieldValue(String fieldName) {
* return getFieldValuesMap().get(fieldName);
* }
*
* {@literal @}Override
* public String toString() {
* return "projects/project-8432/notes/note-8432";
* }
* };
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
Expand Down Expand Up @@ -114,6 +131,21 @@
* ContainerAnalysisClient.create(containerAnalysisSettings);
* }</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.
* ContainerAnalysisSettings containerAnalysisSettings =
* ContainerAnalysisSettings.newBuilder()
* .setTransportChannelProvider(
* ContainerAnalysisSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* ContainerAnalysisClient containerAnalysisClient =
* ContainerAnalysisClient.create(containerAnalysisSettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
Expand Down Expand Up @@ -147,7 +179,6 @@ public static final ContainerAnalysisClient create(ContainerAnalysisSettings set
* Constructs an instance of ContainerAnalysisClient, using the given stub for making calls. This
* is for advanced usage - prefer using create(ContainerAnalysisSettings).
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final ContainerAnalysisClient create(ContainerAnalysisStub stub) {
return new ContainerAnalysisClient(stub);
}
Expand All @@ -162,7 +193,6 @@ protected ContainerAnalysisClient(ContainerAnalysisSettings settings) throws IOE
this.stub = ((ContainerAnalysisStubSettings) settings.getStubSettings()).createStub();
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected ContainerAnalysisClient(ContainerAnalysisStub stub) {
this.settings = null;
this.stub = stub;
Expand All @@ -172,7 +202,6 @@ public final ContainerAnalysisSettings getSettings() {
return settings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public ContainerAnalysisStub getStub() {
return stub;
}
Expand All @@ -192,7 +221,25 @@ public ContainerAnalysisStub getStub() {
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* ResourceName resource =
* new ResourceName() {
* {@literal @}Override
* public Map<String, String> getFieldValuesMap() {
* Map<String, String> fieldValuesMap = new HashMap<>();
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
* return fieldValuesMap;
* }
*
* {@literal @}Override
* public String getFieldValue(String fieldName) {
* return getFieldValuesMap().get(fieldName);
* }
*
* {@literal @}Override
* public String toString() {
* return "projects/project-8432/notes/note-8432";
* }
* };
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
Expand Down Expand Up @@ -265,7 +312,7 @@ public final Policy setIamPolicy(String resource, Policy policy) {
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("SetIamPolicyRequest1223629066".toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
Expand Down Expand Up @@ -297,7 +344,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("SetIamPolicyRequest1223629066".toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
Expand Down Expand Up @@ -326,7 +373,25 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* ResourceName resource =
* new ResourceName() {
* {@literal @}Override
* public Map<String, String> getFieldValuesMap() {
* Map<String, String> fieldValuesMap = new HashMap<>();
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
* return fieldValuesMap;
* }
*
* {@literal @}Override
* public String getFieldValue(String fieldName) {
* return getFieldValuesMap().get(fieldName);
* }
*
* {@literal @}Override
* public String toString() {
* return "projects/project-8432/notes/note-8432";
* }
* };
* Policy response = containerAnalysisClient.getIamPolicy(resource);
* }
* }</pre>
Expand Down Expand Up @@ -389,7 +454,7 @@ public final Policy getIamPolicy(String resource) {
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("GetIamPolicyRequest-1527610370".toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* Policy response = containerAnalysisClient.getIamPolicy(request);
Expand Down Expand Up @@ -420,7 +485,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("GetIamPolicyRequest-1527610370".toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
Expand All @@ -447,7 +512,25 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* ResourceName resource =
* new ResourceName() {
* {@literal @}Override
* public Map<String, String> getFieldValuesMap() {
* Map<String, String> fieldValuesMap = new HashMap<>();
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
* return fieldValuesMap;
* }
*
* {@literal @}Override
* public String getFieldValue(String fieldName) {
* return getFieldValuesMap().get(fieldName);
* }
*
* {@literal @}Override
* public String toString() {
* return "projects/project-8432/notes/note-8432";
* }
* };
* List<String> permissions = new ArrayList<>();
* TestIamPermissionsResponse response =
* containerAnalysisClient.testIamPermissions(resource, permissions);
Expand Down Expand Up @@ -525,7 +608,7 @@ public final TestIamPermissionsResponse testIamPermissions(
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("TestIamPermissionsRequest942398222".toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
Expand Down Expand Up @@ -555,7 +638,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setResource("TestIamPermissionsRequest942398222".toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* ApiFuture<TestIamPermissionsResponse> future =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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 @@ -125,11 +126,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return ContainerAnalysisStubSettings.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 ContainerAnalysisStubSettings.defaultGrpcTransportProviderBuilder();
}

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

public static TransportChannelProvider defaultTransportChannelProvider() {
return ContainerAnalysisStubSettings.defaultTransportChannelProvider();
}
Expand All @@ -139,11 +147,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return ContainerAnalysisStubSettings.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 @@ -181,6 +195,11 @@ private static Builder createDefault() {
return new Builder(ContainerAnalysisStubSettings.newBuilder());
}

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

public ContainerAnalysisStubSettings.Builder getStubSettingsBuilder() {
return ((ContainerAnalysisStubSettings.Builder) getStubSettings());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]");
* ResourceName resource =
* new ResourceName() {
* {@literal @}Override
* public Map<String, String> getFieldValuesMap() {
* Map<String, String> fieldValuesMap = new HashMap<>();
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
* return fieldValuesMap;
* }
*
* {@literal @}Override
* public String getFieldValue(String fieldName) {
* return getFieldValuesMap().get(fieldName);
* }
*
* {@literal @}Override
* public String toString() {
* return "projects/project-8432/notes/note-8432";
* }
* };
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
Expand Down
Loading