Skip to content
Permalink
Browse files
docs: generate samples in gapic client classes (#454)
* changes without context

        autosynth cannot find the source of changes triggered by earlier changes in this
        repository, or by version upgrades to tools such as linters.

* chore: Remove spurious build warnings by deleting--include_source_info from .bazelrc

Committer: @miraleung
PiperOrigin-RevId: 344134135

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Nov 24 14:38:21 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: b11a87f3b54be3a5e42c15020ee1e0781f86da90
Source-Link: googleapis/googleapis@b11a87f

* chore: Undo removal of --include_source_info from .bazelrc

Committer: @miraleung
PiperOrigin-RevId: 345067549

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Dec 1 11:49:14 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 8cfc6c874574b649b4524a4ef6a0651533325a84
Source-Link: googleapis/googleapis@8cfc6c8

* chore: migrate containeranalysis to the Java microgenerator

Committer: @miraleung
PiperOrigin-RevId: 345310543

Source-Author: Google APIs <noreply@google.com>
Source-Date: Wed Dec 2 14:14:40 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 4faa4a762126eb80db988e92065f25d628356c87
Source-Link: googleapis/googleapis@4faa4a7

* fix: Update gapic-generator-java to 0.0.7

Committer: @miraleung
PiperOrigin-RevId: 345476969

Source-Author: Google APIs <noreply@google.com>
Source-Date: Thu Dec 3 10:07:32 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 7be2c821dd88109038c55c89f7dd48f092eeab9d
Source-Link: googleapis/googleapis@7be2c82

* chore: update gapic-generator-java to 0.0.9

Committer: @miraleung
PiperOrigin-RevId: 346372957

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Dec 8 11:37:30 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 857f70daef9f4c38f042fb3dfb7b8423ae18fd19
Source-Link: googleapis/googleapis@857f70d

* chore: update gapic-generator-java to 0.0.18

Committer: @miraleung
PiperOrigin-RevId: 350949863

Source-Author: Google APIs <noreply@google.com>
Source-Date: Sat Jan 9 14:01:49 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 91e206bcfeaf8948ea03fe3cb1b7616108496cd3
Source-Link: googleapis/googleapis@91e206b

* feat: generate sample code in the Java microgenerator

Committer: @miraleung
PiperOrigin-RevId: 356341083

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Feb 8 13:33:28 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 8d8c008e56f1af31d57f75561e0f1848ffb29eeb
Source-Link: googleapis/googleapis@8d8c008

* chore: update gapic-generator-java to 0.0.20

Committer: @miraleung
PiperOrigin-RevId: 357800868

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Feb 16 14:06:04 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: e8bc4471a88ac5f60defe3ed436f517174e59ba0
Source-Link: googleapis/googleapis@e8bc447
  • Loading branch information
yoshi-automation committed Feb 23, 2021
1 parent 70f9df3 commit 874915cb9c8f42c1e56824cd4a8de44affbc7dc9
@@ -53,6 +53,14 @@
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the ContainerAnalysisClient object to clean up resources
* such as threads. In the example above, try-with-resources is used, which automatically calls
* close().
@@ -172,6 +180,16 @@ public ContainerAnalysisStub getStub() {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy is being specified. See the
* operation documentation for the appropriate value for this field.
* @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
@@ -197,6 +215,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* String resource = ProjectName.of("[PROJECT]").toString();
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy is being specified. See the
* operation documentation for the appropriate value for this field.
* @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
@@ -219,6 +247,19 @@ public final Policy setIamPolicy(String resource, Policy policy) {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setPolicy(Policy.newBuilder().build())
* .build();
* Policy response = containerAnalysisClient.setIamPolicy(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -236,6 +277,19 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setPolicy(Policy.newBuilder().build())
* .build();
* ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return stub.setIamPolicyCallable();
@@ -250,6 +304,15 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* Policy response = containerAnalysisClient.getIamPolicy(resource);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy is being requested. See the
* operation documentation for the appropriate value for this field.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -271,6 +334,15 @@ public final Policy getIamPolicy(ResourceName resource) {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* String resource = ProjectName.of("[PROJECT]").toString();
* Policy response = containerAnalysisClient.getIamPolicy(resource);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy is being requested. See the
* operation documentation for the appropriate value for this field.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -289,6 +361,19 @@ public final Policy getIamPolicy(String resource) {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* Policy response = containerAnalysisClient.getIamPolicy(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -306,6 +391,19 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
return stub.getIamPolicyCallable();
@@ -319,6 +417,17 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* List<String> permissions = new ArrayList<>();
* TestIamPermissionsResponse response =
* containerAnalysisClient.testIamPermissions(resource, permissions);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
* operation documentation for the appropriate value for this field.
* @param permissions The set of permissions to check for the `resource`. Permissions with
@@ -344,6 +453,17 @@ public final TestIamPermissionsResponse testIamPermissions(
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* String resource = ProjectName.of("[PROJECT]").toString();
* List<String> permissions = new ArrayList<>();
* TestIamPermissionsResponse response =
* containerAnalysisClient.testIamPermissions(resource, permissions);
* }
* }</pre>
*
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
* operation documentation for the appropriate value for this field.
* @param permissions The set of permissions to check for the `resource`. Permissions with
@@ -369,6 +489,19 @@ public final TestIamPermissionsResponse testIamPermissions(
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -385,6 +518,20 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(ProjectName.of("[PROJECT]").toString())
* .addAllPermissions(new ArrayList<String>())
* .build();
* ApiFuture<TestIamPermissionsResponse> future =
* containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
* // Do something.
* TestIamPermissionsResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable() {
@@ -395,6 +542,17 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
/**
* Gets a summary of the number and severity of occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* String filter = "filter-1274492040";
* VulnerabilityOccurrencesSummary response =
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
* }
* }</pre>
*
* @param parent The name of the project to get a vulnerability summary for in the form of
* `projects/[PROJECT_ID]`.
* @param filter The filter expression.
@@ -414,6 +572,17 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
/**
* Gets a summary of the number and severity of occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* String parent = ProjectName.of("[PROJECT]").toString();
* String filter = "filter-1274492040";
* VulnerabilityOccurrencesSummary response =
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
* }
* }</pre>
*
* @param parent The name of the project to get a vulnerability summary for in the form of
* `projects/[PROJECT_ID]`.
* @param filter The filter expression.
@@ -433,6 +602,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
/**
* Gets a summary of the number and severity of occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetVulnerabilityOccurrencesSummaryRequest request =
* GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setFilter("filter-1274492040")
* .build();
* VulnerabilityOccurrencesSummary response =
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@@ -446,6 +629,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
* Gets a summary of the number and severity of occurrences.
*
* <p>Sample code:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* GetVulnerabilityOccurrencesSummaryRequest request =
* GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setFilter("filter-1274492040")
* .build();
* ApiFuture<VulnerabilityOccurrencesSummary> future =
* containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
* // Do something.
* VulnerabilityOccurrencesSummary response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<
GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary>
@@ -32,6 +32,14 @@
* to that note.
*
* <p>Sample for ContainerAnalysisClient:
*
* <pre>{@code
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
* ResourceName resource = ProjectName.of("[PROJECT]");
* Policy policy = Policy.newBuilder().build();
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.devtools.containeranalysis.v1;
@@ -226,19 +226,23 @@ public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}

@Override
public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return setIamPolicyCallable;
}

@Override
public UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
return getIamPolicyCallable;
}

@Override
public UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable() {
return testIamPermissionsCallable;
}

@Override
public UnaryCallable<GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary>
getVulnerabilityOccurrencesSummaryCallable() {
return getVulnerabilityOccurrencesSummaryCallable;

0 comments on commit 874915c

Please sign in to comment.