Skip to content

Commit

Permalink
feat: Enable REST transport for most of Java and Go clients (googleap…
Browse files Browse the repository at this point in the history
…is#885)

* 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

* Exclude a few dependencies in dependency list check

* Exclude dependencies.sh from owlbot

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Exclude a few dependencies from dependency list check

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Neenu Shaji <Neenu1995@users.noreply.github.com>
Co-authored-by: Blake Li <blakeli@google.com>
  • Loading branch information
4 people committed Jun 30, 2022
1 parent 889ddce commit 022f1a2
Show file tree
Hide file tree
Showing 11 changed files with 1,370 additions and 30 deletions.
4 changes: 2 additions & 2 deletions java-containeranalysis/.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 java-containeranalysis/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

0 comments on commit 022f1a2

Please sign in to comment.