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

Commit 874915c

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
1 parent 70f9df3 commit 874915c

5 files changed

Lines changed: 240 additions & 7 deletions

File tree

google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
5353
* <p>This class provides the ability to make remote calls to the backing service through method
5454
* calls that map to API methods. Sample code to get started:
5555
*
56+
* <pre>{@code
57+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
58+
* ResourceName resource = ProjectName.of("[PROJECT]");
59+
* Policy policy = Policy.newBuilder().build();
60+
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
61+
* }
62+
* }</pre>
63+
*
5664
* <p>Note: close() needs to be called on the ContainerAnalysisClient object to clean up resources
5765
* such as threads. In the example above, try-with-resources is used, which automatically calls
5866
* close().
@@ -172,6 +180,16 @@ public ContainerAnalysisStub getStub() {
172180
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
173181
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
174182
*
183+
* <p>Sample code:
184+
*
185+
* <pre>{@code
186+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
187+
* ResourceName resource = ProjectName.of("[PROJECT]");
188+
* Policy policy = Policy.newBuilder().build();
189+
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
190+
* }
191+
* }</pre>
192+
*
175193
* @param resource REQUIRED: The resource for which the policy is being specified. See the
176194
* operation documentation for the appropriate value for this field.
177195
* @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) {
197215
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
198216
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
199217
*
218+
* <p>Sample code:
219+
*
220+
* <pre>{@code
221+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
222+
* String resource = ProjectName.of("[PROJECT]").toString();
223+
* Policy policy = Policy.newBuilder().build();
224+
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
225+
* }
226+
* }</pre>
227+
*
200228
* @param resource REQUIRED: The resource for which the policy is being specified. See the
201229
* operation documentation for the appropriate value for this field.
202230
* @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) {
219247
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
220248
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
221249
*
250+
* <p>Sample code:
251+
*
252+
* <pre>{@code
253+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
254+
* SetIamPolicyRequest request =
255+
* SetIamPolicyRequest.newBuilder()
256+
* .setResource(ProjectName.of("[PROJECT]").toString())
257+
* .setPolicy(Policy.newBuilder().build())
258+
* .build();
259+
* Policy response = containerAnalysisClient.setIamPolicy(request);
260+
* }
261+
* }</pre>
262+
*
222263
* @param request The request object containing all of the parameters for the API call.
223264
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
224265
*/
@@ -236,6 +277,19 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
236277
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
237278
*
238279
* <p>Sample code:
280+
*
281+
* <pre>{@code
282+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
283+
* SetIamPolicyRequest request =
284+
* SetIamPolicyRequest.newBuilder()
285+
* .setResource(ProjectName.of("[PROJECT]").toString())
286+
* .setPolicy(Policy.newBuilder().build())
287+
* .build();
288+
* ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
289+
* // Do something.
290+
* Policy response = future.get();
291+
* }
292+
* }</pre>
239293
*/
240294
public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
241295
return stub.setIamPolicyCallable();
@@ -250,6 +304,15 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
250304
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
251305
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
252306
*
307+
* <p>Sample code:
308+
*
309+
* <pre>{@code
310+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
311+
* ResourceName resource = ProjectName.of("[PROJECT]");
312+
* Policy response = containerAnalysisClient.getIamPolicy(resource);
313+
* }
314+
* }</pre>
315+
*
253316
* @param resource REQUIRED: The resource for which the policy is being requested. See the
254317
* operation documentation for the appropriate value for this field.
255318
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -271,6 +334,15 @@ public final Policy getIamPolicy(ResourceName resource) {
271334
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
272335
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
273336
*
337+
* <p>Sample code:
338+
*
339+
* <pre>{@code
340+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
341+
* String resource = ProjectName.of("[PROJECT]").toString();
342+
* Policy response = containerAnalysisClient.getIamPolicy(resource);
343+
* }
344+
* }</pre>
345+
*
274346
* @param resource REQUIRED: The resource for which the policy is being requested. See the
275347
* operation documentation for the appropriate value for this field.
276348
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -289,6 +361,19 @@ public final Policy getIamPolicy(String resource) {
289361
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
290362
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
291363
*
364+
* <p>Sample code:
365+
*
366+
* <pre>{@code
367+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
368+
* GetIamPolicyRequest request =
369+
* GetIamPolicyRequest.newBuilder()
370+
* .setResource(ProjectName.of("[PROJECT]").toString())
371+
* .setOptions(GetPolicyOptions.newBuilder().build())
372+
* .build();
373+
* Policy response = containerAnalysisClient.getIamPolicy(request);
374+
* }
375+
* }</pre>
376+
*
292377
* @param request The request object containing all of the parameters for the API call.
293378
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
294379
*/
@@ -306,6 +391,19 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
306391
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
307392
*
308393
* <p>Sample code:
394+
*
395+
* <pre>{@code
396+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
397+
* GetIamPolicyRequest request =
398+
* GetIamPolicyRequest.newBuilder()
399+
* .setResource(ProjectName.of("[PROJECT]").toString())
400+
* .setOptions(GetPolicyOptions.newBuilder().build())
401+
* .build();
402+
* ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
403+
* // Do something.
404+
* Policy response = future.get();
405+
* }
406+
* }</pre>
309407
*/
310408
public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
311409
return stub.getIamPolicyCallable();
@@ -319,6 +417,17 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
319417
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
320418
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
321419
*
420+
* <p>Sample code:
421+
*
422+
* <pre>{@code
423+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
424+
* ResourceName resource = ProjectName.of("[PROJECT]");
425+
* List<String> permissions = new ArrayList<>();
426+
* TestIamPermissionsResponse response =
427+
* containerAnalysisClient.testIamPermissions(resource, permissions);
428+
* }
429+
* }</pre>
430+
*
322431
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
323432
* operation documentation for the appropriate value for this field.
324433
* @param permissions The set of permissions to check for the `resource`. Permissions with
@@ -344,6 +453,17 @@ public final TestIamPermissionsResponse testIamPermissions(
344453
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
345454
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
346455
*
456+
* <p>Sample code:
457+
*
458+
* <pre>{@code
459+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
460+
* String resource = ProjectName.of("[PROJECT]").toString();
461+
* List<String> permissions = new ArrayList<>();
462+
* TestIamPermissionsResponse response =
463+
* containerAnalysisClient.testIamPermissions(resource, permissions);
464+
* }
465+
* }</pre>
466+
*
347467
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
348468
* operation documentation for the appropriate value for this field.
349469
* @param permissions The set of permissions to check for the `resource`. Permissions with
@@ -369,6 +489,19 @@ public final TestIamPermissionsResponse testIamPermissions(
369489
* <p>The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
370490
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
371491
*
492+
* <p>Sample code:
493+
*
494+
* <pre>{@code
495+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
496+
* TestIamPermissionsRequest request =
497+
* TestIamPermissionsRequest.newBuilder()
498+
* .setResource(ProjectName.of("[PROJECT]").toString())
499+
* .addAllPermissions(new ArrayList<String>())
500+
* .build();
501+
* TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
502+
* }
503+
* }</pre>
504+
*
372505
* @param request The request object containing all of the parameters for the API call.
373506
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
374507
*/
@@ -385,6 +518,20 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
385518
* `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
386519
*
387520
* <p>Sample code:
521+
*
522+
* <pre>{@code
523+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
524+
* TestIamPermissionsRequest request =
525+
* TestIamPermissionsRequest.newBuilder()
526+
* .setResource(ProjectName.of("[PROJECT]").toString())
527+
* .addAllPermissions(new ArrayList<String>())
528+
* .build();
529+
* ApiFuture<TestIamPermissionsResponse> future =
530+
* containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
531+
* // Do something.
532+
* TestIamPermissionsResponse response = future.get();
533+
* }
534+
* }</pre>
388535
*/
389536
public final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
390537
testIamPermissionsCallable() {
@@ -395,6 +542,17 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
395542
/**
396543
* Gets a summary of the number and severity of occurrences.
397544
*
545+
* <p>Sample code:
546+
*
547+
* <pre>{@code
548+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
549+
* ProjectName parent = ProjectName.of("[PROJECT]");
550+
* String filter = "filter-1274492040";
551+
* VulnerabilityOccurrencesSummary response =
552+
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
553+
* }
554+
* }</pre>
555+
*
398556
* @param parent The name of the project to get a vulnerability summary for in the form of
399557
* `projects/[PROJECT_ID]`.
400558
* @param filter The filter expression.
@@ -414,6 +572,17 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
414572
/**
415573
* Gets a summary of the number and severity of occurrences.
416574
*
575+
* <p>Sample code:
576+
*
577+
* <pre>{@code
578+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
579+
* String parent = ProjectName.of("[PROJECT]").toString();
580+
* String filter = "filter-1274492040";
581+
* VulnerabilityOccurrencesSummary response =
582+
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
583+
* }
584+
* }</pre>
585+
*
417586
* @param parent The name of the project to get a vulnerability summary for in the form of
418587
* `projects/[PROJECT_ID]`.
419588
* @param filter The filter expression.
@@ -433,6 +602,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
433602
/**
434603
* Gets a summary of the number and severity of occurrences.
435604
*
605+
* <p>Sample code:
606+
*
607+
* <pre>{@code
608+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
609+
* GetVulnerabilityOccurrencesSummaryRequest request =
610+
* GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
611+
* .setParent(ProjectName.of("[PROJECT]").toString())
612+
* .setFilter("filter-1274492040")
613+
* .build();
614+
* VulnerabilityOccurrencesSummary response =
615+
* containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
616+
* }
617+
* }</pre>
618+
*
436619
* @param request The request object containing all of the parameters for the API call.
437620
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
438621
*/
@@ -446,6 +629,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary(
446629
* Gets a summary of the number and severity of occurrences.
447630
*
448631
* <p>Sample code:
632+
*
633+
* <pre>{@code
634+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
635+
* GetVulnerabilityOccurrencesSummaryRequest request =
636+
* GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
637+
* .setParent(ProjectName.of("[PROJECT]").toString())
638+
* .setFilter("filter-1274492040")
639+
* .build();
640+
* ApiFuture<VulnerabilityOccurrencesSummary> future =
641+
* containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
642+
* // Do something.
643+
* VulnerabilityOccurrencesSummary response = future.get();
644+
* }
645+
* }</pre>
449646
*/
450647
public final UnaryCallable<
451648
GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary>

google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
* to that note.
3333
*
3434
* <p>Sample for ContainerAnalysisClient:
35+
*
36+
* <pre>{@code
37+
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
38+
* ResourceName resource = ProjectName.of("[PROJECT]");
39+
* Policy policy = Policy.newBuilder().build();
40+
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
41+
* }
42+
* }</pre>
3543
*/
3644
@Generated("by gapic-generator-java")
3745
package com.google.cloud.devtools.containeranalysis.v1;

google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,23 @@ public GrpcOperationsStub getOperationsStub() {
226226
return operationsStub;
227227
}
228228

229+
@Override
229230
public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
230231
return setIamPolicyCallable;
231232
}
232233

234+
@Override
233235
public UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
234236
return getIamPolicyCallable;
235237
}
236238

239+
@Override
237240
public UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
238241
testIamPermissionsCallable() {
239242
return testIamPermissionsCallable;
240243
}
241244

245+
@Override
242246
public UnaryCallable<GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary>
243247
getVulnerabilityOccurrencesSummaryCallable() {
244248
return getVulnerabilityOccurrencesSummaryCallable;

0 commit comments

Comments
 (0)