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

docs: generate samples in gapic client classes #454

Merged
merged 9 commits into from Feb 23, 2021
Expand Up @@ -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().
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
*/
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
*/
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
*/
Expand All @@ -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() {
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
*/
Expand All @@ -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>
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down