From 06d4f003e0195882ed80bd9ac0f2432e104a75b1 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 8 Feb 2021 16:36:02 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#241) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/83d27b1b-599d-4795-9959-95d65d1baad5/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../java/io/grafeas/v1/GrafeasClient.java | 737 ++++++++++++++++++ src/main/java/io/grafeas/v1/package-info.java | 7 + synth.metadata | 6 +- 3 files changed, 747 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/grafeas/v1/GrafeasClient.java b/src/main/java/io/grafeas/v1/GrafeasClient.java index 8444948a..2b06b172 100644 --- a/src/main/java/io/grafeas/v1/GrafeasClient.java +++ b/src/main/java/io/grafeas/v1/GrafeasClient.java @@ -55,6 +55,13 @@ *

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: * + *

{@code
+ * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+ *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+ *   Occurrence response = grafeasClient.getOccurrence(name);
+ * }
+ * }
+ * *

Note: close() needs to be called on the GrafeasClient object to clean up resources such as * threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -155,6 +162,15 @@ public GrafeasStub getStub() { /** * Gets the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+   *   Occurrence response = grafeasClient.getOccurrence(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -169,6 +185,15 @@ public final Occurrence getOccurrence(OccurrenceName name) { /** * Gets the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString();
+   *   Occurrence response = grafeasClient.getOccurrence(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -182,6 +207,18 @@ public final Occurrence getOccurrence(String name) { /** * Gets the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetOccurrenceRequest request =
+   *       GetOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   Occurrence response = grafeasClient.getOccurrence(request);
+   * }
+   * }
+ * * @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 */ @@ -194,6 +231,18 @@ public final Occurrence getOccurrence(GetOccurrenceRequest request) { * Gets the specified occurrence. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetOccurrenceRequest request =
+   *       GetOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   ApiFuture future = grafeasClient.getOccurrenceCallable().futureCall(request);
+   *   // Do something.
+   *   Occurrence response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getOccurrenceCallable() { return stub.getOccurrenceCallable(); @@ -203,6 +252,18 @@ public final UnaryCallable getOccurrenceCallab /** * Lists occurrences for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String filter = "filter-1274492040";
+   *   for (Occurrence element : grafeasClient.listOccurrences(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent The name of the project to list occurrences for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -221,6 +282,18 @@ public final ListOccurrencesPagedResponse listOccurrences(ProjectName parent, St /** * Lists occurrences for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   String filter = "filter-1274492040";
+   *   for (Occurrence element : grafeasClient.listOccurrences(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent The name of the project to list occurrences for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -236,6 +309,23 @@ public final ListOccurrencesPagedResponse listOccurrences(String parent, String /** * Lists occurrences for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListOccurrencesRequest request =
+   *       ListOccurrencesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Occurrence element : grafeasClient.listOccurrences(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -248,6 +338,24 @@ public final ListOccurrencesPagedResponse listOccurrences(ListOccurrencesRequest * Lists occurrences for the specified project. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListOccurrencesRequest request =
+   *       ListOccurrencesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       grafeasClient.listOccurrencesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Occurrence element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listOccurrencesPagedCallable() { @@ -259,6 +367,23 @@ public final ListOccurrencesPagedResponse listOccurrences(ListOccurrencesRequest * Lists occurrences for the specified project. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   while (true) {
+   *     ListOccurrencesResponse response = grafeasClient.listOccurrencesCallable().call(request);
+   *     for (Occurrence element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listOccurrencesCallable() { @@ -270,6 +395,15 @@ public final ListOccurrencesPagedResponse listOccurrences(ListOccurrencesRequest * Deletes the specified occurrence. For example, use this method to delete an occurrence when the * occurrence is no longer applicable for the given resource. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+   *   grafeasClient.deleteOccurrence(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -285,6 +419,15 @@ public final void deleteOccurrence(OccurrenceName name) { * Deletes the specified occurrence. For example, use this method to delete an occurrence when the * occurrence is no longer applicable for the given resource. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString();
+   *   grafeasClient.deleteOccurrence(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -299,6 +442,18 @@ public final void deleteOccurrence(String name) { * Deletes the specified occurrence. For example, use this method to delete an occurrence when the * occurrence is no longer applicable for the given resource. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   DeleteOccurrenceRequest request =
+   *       DeleteOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   grafeasClient.deleteOccurrence(request);
+   * }
+   * }
+ * * @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 */ @@ -312,6 +467,18 @@ public final void deleteOccurrence(DeleteOccurrenceRequest request) { * occurrence is no longer applicable for the given resource. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   DeleteOccurrenceRequest request =
+   *       DeleteOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   ApiFuture future = grafeasClient.deleteOccurrenceCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteOccurrenceCallable() { return stub.deleteOccurrenceCallable(); @@ -321,6 +488,16 @@ public final UnaryCallable deleteOccurrenceCalla /** * Creates a new occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Occurrence occurrence = Occurrence.newBuilder().build();
+   *   Occurrence response = grafeasClient.createOccurrence(parent, occurrence);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * occurrence is to be created. * @param occurrence The occurrence to create. @@ -339,6 +516,16 @@ public final Occurrence createOccurrence(ProjectName parent, Occurrence occurren /** * Creates a new occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   Occurrence occurrence = Occurrence.newBuilder().build();
+   *   Occurrence response = grafeasClient.createOccurrence(parent, occurrence);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * occurrence is to be created. * @param occurrence The occurrence to create. @@ -354,6 +541,19 @@ public final Occurrence createOccurrence(String parent, Occurrence occurrence) { /** * Creates a new occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   CreateOccurrenceRequest request =
+   *       CreateOccurrenceRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setOccurrence(Occurrence.newBuilder().build())
+   *           .build();
+   *   Occurrence response = grafeasClient.createOccurrence(request);
+   * }
+   * }
+ * * @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 */ @@ -366,6 +566,19 @@ public final Occurrence createOccurrence(CreateOccurrenceRequest request) { * Creates a new occurrence. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   CreateOccurrenceRequest request =
+   *       CreateOccurrenceRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setOccurrence(Occurrence.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = grafeasClient.createOccurrenceCallable().futureCall(request);
+   *   // Do something.
+   *   Occurrence response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createOccurrenceCallable() { return stub.createOccurrenceCallable(); @@ -375,6 +588,17 @@ public final UnaryCallable createOccurrence /** * Creates new occurrences in batch. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   List occurrences = new ArrayList<>();
+   *   BatchCreateOccurrencesResponse response =
+   *       grafeasClient.batchCreateOccurrences(parent, occurrences);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * occurrences are to be created. * @param occurrences The occurrences to create. Max allowed length is 1000. @@ -394,6 +618,17 @@ public final BatchCreateOccurrencesResponse batchCreateOccurrences( /** * Creates new occurrences in batch. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   List occurrences = new ArrayList<>();
+   *   BatchCreateOccurrencesResponse response =
+   *       grafeasClient.batchCreateOccurrences(parent, occurrences);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * occurrences are to be created. * @param occurrences The occurrences to create. Max allowed length is 1000. @@ -413,6 +648,19 @@ public final BatchCreateOccurrencesResponse batchCreateOccurrences( /** * Creates new occurrences in batch. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   BatchCreateOccurrencesRequest request =
+   *       BatchCreateOccurrencesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .addAllOccurrences(new ArrayList())
+   *           .build();
+   *   BatchCreateOccurrencesResponse response = grafeasClient.batchCreateOccurrences(request);
+   * }
+   * }
+ * * @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 */ @@ -426,6 +674,20 @@ public final BatchCreateOccurrencesResponse batchCreateOccurrences( * Creates new occurrences in batch. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   BatchCreateOccurrencesRequest request =
+   *       BatchCreateOccurrencesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .addAllOccurrences(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       grafeasClient.batchCreateOccurrencesCallable().futureCall(request);
+   *   // Do something.
+   *   BatchCreateOccurrencesResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable batchCreateOccurrencesCallable() { @@ -436,6 +698,17 @@ public final BatchCreateOccurrencesResponse batchCreateOccurrences( /** * Updates the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+   *   Occurrence occurrence = Occurrence.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Occurrence response = grafeasClient.updateOccurrence(name, occurrence, updateMask);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @param occurrence The updated occurrence. @@ -457,6 +730,17 @@ public final Occurrence updateOccurrence( /** * Updates the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString();
+   *   Occurrence occurrence = Occurrence.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Occurrence response = grafeasClient.updateOccurrence(name, occurrence, updateMask);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @param occurrence The updated occurrence. @@ -478,6 +762,20 @@ public final Occurrence updateOccurrence( /** * Updates the specified occurrence. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   UpdateOccurrenceRequest request =
+   *       UpdateOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .setOccurrence(Occurrence.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Occurrence response = grafeasClient.updateOccurrence(request);
+   * }
+   * }
+ * * @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 */ @@ -490,6 +788,20 @@ public final Occurrence updateOccurrence(UpdateOccurrenceRequest request) { * Updates the specified occurrence. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   UpdateOccurrenceRequest request =
+   *       UpdateOccurrenceRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .setOccurrence(Occurrence.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = grafeasClient.updateOccurrenceCallable().futureCall(request);
+   *   // Do something.
+   *   Occurrence response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateOccurrenceCallable() { return stub.updateOccurrenceCallable(); @@ -500,6 +812,15 @@ public final UnaryCallable updateOccurrence * Gets the note attached to the specified occurrence. Consumer projects can use this method to * get a note that belongs to a provider project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+   *   Note response = grafeasClient.getOccurrenceNote(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -517,6 +838,15 @@ public final Note getOccurrenceNote(OccurrenceName name) { * Gets the note attached to the specified occurrence. Consumer projects can use this method to * get a note that belongs to a provider project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString();
+   *   Note response = grafeasClient.getOccurrenceNote(name);
+   * }
+   * }
+ * * @param name The name of the occurrence in the form of * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -531,6 +861,18 @@ public final Note getOccurrenceNote(String name) { * Gets the note attached to the specified occurrence. Consumer projects can use this method to * get a note that belongs to a provider project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetOccurrenceNoteRequest request =
+   *       GetOccurrenceNoteRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   Note response = grafeasClient.getOccurrenceNote(request);
+   * }
+   * }
+ * * @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 */ @@ -544,6 +886,18 @@ public final Note getOccurrenceNote(GetOccurrenceNoteRequest request) { * get a note that belongs to a provider project. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetOccurrenceNoteRequest request =
+   *       GetOccurrenceNoteRequest.newBuilder()
+   *           .setName(OccurrenceName.of("[PROJECT]", "[OCCURRENCE]").toString())
+   *           .build();
+   *   ApiFuture future = grafeasClient.getOccurrenceNoteCallable().futureCall(request);
+   *   // Do something.
+   *   Note response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getOccurrenceNoteCallable() { return stub.getOccurrenceNoteCallable(); @@ -553,6 +907,15 @@ public final UnaryCallable getOccurrenceNoteCall /** * Gets the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
+   *   Note response = grafeasClient.getNote(name);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -566,6 +929,15 @@ public final Note getNote(NoteName name) { /** * Gets the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = NoteName.of("[PROJECT]", "[NOTE]").toString();
+   *   Note response = grafeasClient.getNote(name);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -578,6 +950,18 @@ public final Note getNote(String name) { /** * Gets the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetNoteRequest request =
+   *       GetNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .build();
+   *   Note response = grafeasClient.getNote(request);
+   * }
+   * }
+ * * @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 */ @@ -590,6 +974,18 @@ public final Note getNote(GetNoteRequest request) { * Gets the specified note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   GetNoteRequest request =
+   *       GetNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .build();
+   *   ApiFuture future = grafeasClient.getNoteCallable().futureCall(request);
+   *   // Do something.
+   *   Note response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getNoteCallable() { return stub.getNoteCallable(); @@ -599,6 +995,18 @@ public final UnaryCallable getNoteCallable() { /** * Lists notes for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String filter = "filter-1274492040";
+   *   for (Note element : grafeasClient.listNotes(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent The name of the project to list notes for in the form of `projects/[PROJECT_ID]`. * @param filter The filter expression. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -616,6 +1024,18 @@ public final ListNotesPagedResponse listNotes(ProjectName parent, String filter) /** * Lists notes for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   String filter = "filter-1274492040";
+   *   for (Note element : grafeasClient.listNotes(parent, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent The name of the project to list notes for in the form of `projects/[PROJECT_ID]`. * @param filter The filter expression. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -630,6 +1050,23 @@ public final ListNotesPagedResponse listNotes(String parent, String filter) { /** * Lists notes for the specified project. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListNotesRequest request =
+   *       ListNotesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Note element : grafeasClient.listNotes(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -642,6 +1079,23 @@ public final ListNotesPagedResponse listNotes(ListNotesRequest request) { * Lists notes for the specified project. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListNotesRequest request =
+   *       ListNotesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = grafeasClient.listNotesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Note element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listNotesPagedCallable() { return stub.listNotesPagedCallable(); @@ -652,6 +1106,23 @@ public final UnaryCallable listNotesPa * Lists notes for the specified project. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   while (true) {
+   *     ListNotesResponse response = grafeasClient.listNotesCallable().call(request);
+   *     for (Note element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listNotesCallable() { return stub.listNotesCallable(); @@ -661,6 +1132,15 @@ public final UnaryCallable listNotesCallabl /** * Deletes the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
+   *   grafeasClient.deleteNote(name);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -674,6 +1154,15 @@ public final void deleteNote(NoteName name) { /** * Deletes the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = NoteName.of("[PROJECT]", "[NOTE]").toString();
+   *   grafeasClient.deleteNote(name);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -686,6 +1175,18 @@ public final void deleteNote(String name) { /** * Deletes the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   DeleteNoteRequest request =
+   *       DeleteNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .build();
+   *   grafeasClient.deleteNote(request);
+   * }
+   * }
+ * * @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 */ @@ -698,6 +1199,18 @@ public final void deleteNote(DeleteNoteRequest request) { * Deletes the specified note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   DeleteNoteRequest request =
+   *       DeleteNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .build();
+   *   ApiFuture future = grafeasClient.deleteNoteCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteNoteCallable() { return stub.deleteNoteCallable(); @@ -707,6 +1220,17 @@ public final UnaryCallable deleteNoteCallable() { /** * Creates a new note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String noteId = "noteId-1039694675";
+   *   Note note = Note.newBuilder().build();
+   *   Note response = grafeasClient.createNote(parent, noteId, note);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * note is to be created. * @param noteId The ID to use for this note. @@ -727,6 +1251,17 @@ public final Note createNote(ProjectName parent, String noteId, Note note) { /** * Creates a new note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   String noteId = "noteId-1039694675";
+   *   Note note = Note.newBuilder().build();
+   *   Note response = grafeasClient.createNote(parent, noteId, note);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * note is to be created. * @param noteId The ID to use for this note. @@ -743,6 +1278,20 @@ public final Note createNote(String parent, String noteId, Note note) { /** * Creates a new note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   CreateNoteRequest request =
+   *       CreateNoteRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setNoteId("noteId-1039694675")
+   *           .setNote(Note.newBuilder().build())
+   *           .build();
+   *   Note response = grafeasClient.createNote(request);
+   * }
+   * }
+ * * @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 */ @@ -755,6 +1304,20 @@ public final Note createNote(CreateNoteRequest request) { * Creates a new note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   CreateNoteRequest request =
+   *       CreateNoteRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setNoteId("noteId-1039694675")
+   *           .setNote(Note.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = grafeasClient.createNoteCallable().futureCall(request);
+   *   // Do something.
+   *   Note response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createNoteCallable() { return stub.createNoteCallable(); @@ -764,6 +1327,16 @@ public final UnaryCallable createNoteCallable() { /** * Creates new notes in batch. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Map notes = new HashMap<>();
+   *   BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(parent, notes);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * notes are to be created. * @param notes The notes to create. Max allowed length is 1000. @@ -783,6 +1356,16 @@ public final BatchCreateNotesResponse batchCreateNotes( /** * Creates new notes in batch. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   Map notes = new HashMap<>();
+   *   BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(parent, notes);
+   * }
+   * }
+ * * @param parent The name of the project in the form of `projects/[PROJECT_ID]`, under which the * notes are to be created. * @param notes The notes to create. Max allowed length is 1000. @@ -798,6 +1381,19 @@ public final BatchCreateNotesResponse batchCreateNotes(String parent, MapSample code: + * + *
{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   BatchCreateNotesRequest request =
+   *       BatchCreateNotesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .putAllNotes(new HashMap())
+   *           .build();
+   *   BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(request);
+   * }
+   * }
+ * * @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 */ @@ -810,6 +1406,20 @@ public final BatchCreateNotesResponse batchCreateNotes(BatchCreateNotesRequest r * Creates new notes in batch. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   BatchCreateNotesRequest request =
+   *       BatchCreateNotesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .putAllNotes(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       grafeasClient.batchCreateNotesCallable().futureCall(request);
+   *   // Do something.
+   *   BatchCreateNotesResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable batchCreateNotesCallable() { @@ -820,6 +1430,17 @@ public final BatchCreateNotesResponse batchCreateNotes(BatchCreateNotesRequest r /** * Updates the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
+   *   Note note = Note.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Note response = grafeasClient.updateNote(name, note, updateMask);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @param note The updated note. * @param updateMask The fields to update. @@ -839,6 +1460,17 @@ public final Note updateNote(NoteName name, Note note, FieldMask updateMask) { /** * Updates the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = NoteName.of("[PROJECT]", "[NOTE]").toString();
+   *   Note note = Note.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Note response = grafeasClient.updateNote(name, note, updateMask);
+   * }
+   * }
+ * * @param name The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @param note The updated note. * @param updateMask The fields to update. @@ -858,6 +1490,20 @@ public final Note updateNote(String name, Note note, FieldMask updateMask) { /** * Updates the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   UpdateNoteRequest request =
+   *       UpdateNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .setNote(Note.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Note response = grafeasClient.updateNote(request);
+   * }
+   * }
+ * * @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 */ @@ -870,6 +1516,20 @@ public final Note updateNote(UpdateNoteRequest request) { * Updates the specified note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   UpdateNoteRequest request =
+   *       UpdateNoteRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .setNote(Note.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = grafeasClient.updateNoteCallable().futureCall(request);
+   *   // Do something.
+   *   Note response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateNoteCallable() { return stub.updateNoteCallable(); @@ -880,6 +1540,18 @@ public final UnaryCallable updateNoteCallable() { * Lists occurrences referencing the specified note. Provider projects can use this method to get * all occurrences across consumer projects referencing the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
+   *   String filter = "filter-1274492040";
+   *   for (Occurrence element : grafeasClient.listNoteOccurrences(name, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name The name of the note to list occurrences for in the form of * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @param filter The filter expression. @@ -899,6 +1571,18 @@ public final ListNoteOccurrencesPagedResponse listNoteOccurrences(NoteName name, * Lists occurrences referencing the specified note. Provider projects can use this method to get * all occurrences across consumer projects referencing the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   String name = NoteName.of("[PROJECT]", "[NOTE]").toString();
+   *   String filter = "filter-1274492040";
+   *   for (Occurrence element : grafeasClient.listNoteOccurrences(name, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name The name of the note to list occurrences for in the form of * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. * @param filter The filter expression. @@ -915,6 +1599,23 @@ public final ListNoteOccurrencesPagedResponse listNoteOccurrences(String name, S * Lists occurrences referencing the specified note. Provider projects can use this method to get * all occurrences across consumer projects referencing the specified note. * + *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListNoteOccurrencesRequest request =
+   *       ListNoteOccurrencesRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Occurrence element : grafeasClient.listNoteOccurrences(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @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 */ @@ -929,6 +1630,24 @@ public final ListNoteOccurrencesPagedResponse listNoteOccurrences( * all occurrences across consumer projects referencing the specified note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   ListNoteOccurrencesRequest request =
+   *       ListNoteOccurrencesRequest.newBuilder()
+   *           .setName(NoteName.of("[PROJECT]", "[NOTE]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       grafeasClient.listNoteOccurrencesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Occurrence element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listNoteOccurrencesPagedCallable() { @@ -941,6 +1660,24 @@ public final ListNoteOccurrencesPagedResponse listNoteOccurrences( * all occurrences across consumer projects referencing the specified note. * *

Sample code: + * + *

{@code
+   * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+   *   while (true) {
+   *     ListNoteOccurrencesResponse response =
+   *         grafeasClient.listNoteOccurrencesCallable().call(request);
+   *     for (Occurrence element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listNoteOccurrencesCallable() { diff --git a/src/main/java/io/grafeas/v1/package-info.java b/src/main/java/io/grafeas/v1/package-info.java index 0560590c..f93a5754 100644 --- a/src/main/java/io/grafeas/v1/package-info.java +++ b/src/main/java/io/grafeas/v1/package-info.java @@ -33,6 +33,13 @@ * to that note. * *

Sample for GrafeasClient: + * + *

{@code
+ * try (GrafeasClient grafeasClient = GrafeasClient.create()) {
+ *   OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
+ *   Occurrence response = grafeasClient.getOccurrence(name);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package io.grafeas.v1; diff --git a/synth.metadata b/synth.metadata index 593021aa..acfc002f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-grafeas.git", - "sha": "be04db3a0ff273446ebd0ba6ac7db9b4c0b19054" + "sha": "edae083b567f703fea43df36e2d829b3a8136115" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {