@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@Override public ListNoteOccurrencesRequest injectPageSize( ListNoteOccurrencesRequest payload, int pageSize) { return ListNoteOccurrencesRequest.newBuilder(payload).setPageSize(pageSize).build(); }
@Override public ListNoteOccurrencesRequest injectToken( ListNoteOccurrencesRequest payload, String token) { return ListNoteOccurrencesRequest.newBuilder(payload).setPageToken(token).build(); }
/** * Lists occurrences referencing the specified note. Provider projects can use this method to get * all occurrences across consumer projects referencing the specified note. * * <p>Sample code: * * <pre><code> * try (GrafeasV1Beta1Client grafeasV1Beta1Client = GrafeasV1Beta1Client.create()) { * NoteName name = NoteName.of("[PROJECT]", "[NOTE]"); * String filter = ""; * for (Occurrence element : grafeasV1Beta1Client.listNoteOccurrences(name.toString(), filter).iterateAll()) { * // doThingsWith(element); * } * } * </code></pre> * * @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. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListNoteOccurrencesPagedResponse listNoteOccurrences(String name, String filter) { ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder().setName(name).setFilter(filter).build(); return listNoteOccurrences(request); }
/** * Lists occurrences referencing the specified note. Provider projects can use this method to get * all occurrences across consumer projects referencing the specified note. * * <p>Sample code: * * <pre><code> * try (GrafeasV1Beta1Client grafeasV1Beta1Client = GrafeasV1Beta1Client.create()) { * NoteName name = NoteName.of("[PROJECT]", "[NOTE]"); * String filter = ""; * for (Occurrence element : grafeasV1Beta1Client.listNoteOccurrences(name, filter).iterateAll()) { * // doThingsWith(element); * } * } * </code></pre> * * @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. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListNoteOccurrencesPagedResponse listNoteOccurrences(NoteName name, String filter) { ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder() .setName(name == null ? null : name.toString()) .setFilter(filter) .build(); return listNoteOccurrences(request); }
/** * Retrieves all the Occurrences associated with a specified Note * Here, all Occurrences are printed and counted * @param client The Grafeas client used to perform the API requests. * @param noteId the Note's unique identifier * @param projectId the GCP project the Note belongs to * @return number of Occurrences found */ public static int getOccurrencesForNote(GrafeasV1Beta1Client client, String noteId, String projectId) { final NoteName noteName = NoteName.of(projectId, noteId); int i = 0; ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder() .setName(noteName.toString()) .build(); for (Occurrence o : client.listNoteOccurrences(request).iterateAll()) { // Write custom code to process each Occurrence here System.out.println(o.getName()); i = i + 1; } return i; } // [END occurrences_for_note]
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }