@Generated(value="by gapic-generator") @BetaApi public class GrafeasClient extends Object implements com.google.api.gax.core.BackgroundResource
Retrieves analysis results of Cloud components such as Docker container images.
Analysis results are stored as a series of occurrences. An `Occurrence` contains information about a specific analysis instance on a resource. An occurrence refers to a `Note`. A note contains details describing the analysis and is generally stored in a separate project, called a `Provider`. Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case, there would be one note for the vulnerability and an occurrence for each image with the vulnerability referring to that note.
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:
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().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of GrafeasSettings to create(). For example:
To customize credentials:
GrafeasSettings grafeasSettings =
GrafeasSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GrafeasClient grafeasClient =
GrafeasClient.create(grafeasSettings);
To customize the endpoint:
GrafeasSettings grafeasSettings =
GrafeasSettings.newBuilder().setEndpoint(myEndpoint).build();
GrafeasClient grafeasClient =
GrafeasClient.create(grafeasSettings);
Modifier and Type | Class and Description |
---|---|
static class |
GrafeasClient.ListNoteOccurrencesFixedSizeCollection |
static class |
GrafeasClient.ListNoteOccurrencesPage |
static class |
GrafeasClient.ListNoteOccurrencesPagedResponse |
static class |
GrafeasClient.ListNotesFixedSizeCollection |
static class |
GrafeasClient.ListNotesPage |
static class |
GrafeasClient.ListNotesPagedResponse |
static class |
GrafeasClient.ListOccurrencesFixedSizeCollection |
static class |
GrafeasClient.ListOccurrencesPage |
static class |
GrafeasClient.ListOccurrencesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
GrafeasClient(GrafeasSettings settings)
Constructs an instance of GrafeasClient, using the given settings.
|
protected |
GrafeasClient(GrafeasStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
BatchCreateNotesResponse |
batchCreateNotes(BatchCreateNotesRequest request)
Creates new notes in batch.
|
BatchCreateNotesResponse |
batchCreateNotes(ProjectName parent,
Map<String,Note> notes)
Creates new notes in batch.
|
BatchCreateNotesResponse |
batchCreateNotes(String parent,
Map<String,Note> notes)
Creates new notes in batch.
|
com.google.api.gax.rpc.UnaryCallable<BatchCreateNotesRequest,BatchCreateNotesResponse> |
batchCreateNotesCallable()
Creates new notes in batch.
|
BatchCreateOccurrencesResponse |
batchCreateOccurrences(BatchCreateOccurrencesRequest request)
Creates new occurrences in batch.
|
BatchCreateOccurrencesResponse |
batchCreateOccurrences(ProjectName parent,
List<Occurrence> occurrences)
Creates new occurrences in batch.
|
BatchCreateOccurrencesResponse |
batchCreateOccurrences(String parent,
List<Occurrence> occurrences)
Creates new occurrences in batch.
|
com.google.api.gax.rpc.UnaryCallable<BatchCreateOccurrencesRequest,BatchCreateOccurrencesResponse> |
batchCreateOccurrencesCallable()
Creates new occurrences in batch.
|
void |
close() |
static GrafeasClient |
create()
Constructs an instance of GrafeasClient with default settings.
|
static GrafeasClient |
create(GrafeasSettings settings)
Constructs an instance of GrafeasClient, using the given settings.
|
static GrafeasClient |
create(GrafeasStub stub)
Constructs an instance of GrafeasClient, using the given stub for making calls.
|
Note |
createNote(CreateNoteRequest request)
Creates a new note.
|
Note |
createNote(ProjectName parent,
String noteId,
Note note)
Creates a new note.
|
Note |
createNote(String parent,
String noteId,
Note note)
Creates a new note.
|
com.google.api.gax.rpc.UnaryCallable<CreateNoteRequest,Note> |
createNoteCallable()
Creates a new note.
|
Occurrence |
createOccurrence(CreateOccurrenceRequest request)
Creates a new occurrence.
|
Occurrence |
createOccurrence(ProjectName parent,
Occurrence occurrence)
Creates a new occurrence.
|
Occurrence |
createOccurrence(String parent,
Occurrence occurrence)
Creates a new occurrence.
|
com.google.api.gax.rpc.UnaryCallable<CreateOccurrenceRequest,Occurrence> |
createOccurrenceCallable()
Creates a new occurrence.
|
void |
deleteNote(DeleteNoteRequest request)
Deletes the specified note.
|
void |
deleteNote(NoteName name)
Deletes the specified note.
|
void |
deleteNote(String name)
Deletes the specified note.
|
com.google.api.gax.rpc.UnaryCallable<DeleteNoteRequest,Empty> |
deleteNoteCallable()
Deletes the specified note.
|
void |
deleteOccurrence(DeleteOccurrenceRequest request)
Deletes the specified occurrence.
|
void |
deleteOccurrence(OccurrenceName name)
Deletes the specified occurrence.
|
void |
deleteOccurrence(String name)
Deletes the specified occurrence.
|
com.google.api.gax.rpc.UnaryCallable<DeleteOccurrenceRequest,Empty> |
deleteOccurrenceCallable()
Deletes the specified occurrence.
|
Note |
getNote(GetNoteRequest request)
Gets the specified note.
|
Note |
getNote(NoteName name)
Gets the specified note.
|
Note |
getNote(String name)
Gets the specified note.
|
com.google.api.gax.rpc.UnaryCallable<GetNoteRequest,Note> |
getNoteCallable()
Gets the specified note.
|
Occurrence |
getOccurrence(GetOccurrenceRequest request)
Gets the specified occurrence.
|
Occurrence |
getOccurrence(OccurrenceName name)
Gets the specified occurrence.
|
Occurrence |
getOccurrence(String name)
Gets the specified occurrence.
|
com.google.api.gax.rpc.UnaryCallable<GetOccurrenceRequest,Occurrence> |
getOccurrenceCallable()
Gets the specified occurrence.
|
Note |
getOccurrenceNote(GetOccurrenceNoteRequest request)
Gets the note attached to the specified occurrence.
|
Note |
getOccurrenceNote(OccurrenceName name)
Gets the note attached to the specified occurrence.
|
Note |
getOccurrenceNote(String name)
Gets the note attached to the specified occurrence.
|
com.google.api.gax.rpc.UnaryCallable<GetOccurrenceNoteRequest,Note> |
getOccurrenceNoteCallable()
Gets the note attached to the specified occurrence.
|
GrafeasSettings |
getSettings() |
GrafeasStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
GrafeasClient.ListNoteOccurrencesPagedResponse |
listNoteOccurrences(ListNoteOccurrencesRequest request)
Lists occurrences referencing the specified note.
|
GrafeasClient.ListNoteOccurrencesPagedResponse |
listNoteOccurrences(NoteName name,
String filter)
Lists occurrences referencing the specified note.
|
GrafeasClient.ListNoteOccurrencesPagedResponse |
listNoteOccurrences(String name,
String filter)
Lists occurrences referencing the specified note.
|
com.google.api.gax.rpc.UnaryCallable<ListNoteOccurrencesRequest,ListNoteOccurrencesResponse> |
listNoteOccurrencesCallable()
Lists occurrences referencing the specified note.
|
com.google.api.gax.rpc.UnaryCallable<ListNoteOccurrencesRequest,GrafeasClient.ListNoteOccurrencesPagedResponse> |
listNoteOccurrencesPagedCallable()
Lists occurrences referencing the specified note.
|
GrafeasClient.ListNotesPagedResponse |
listNotes(ListNotesRequest request)
Lists notes for the specified project.
|
GrafeasClient.ListNotesPagedResponse |
listNotes(ProjectName parent,
String filter)
Lists notes for the specified project.
|
GrafeasClient.ListNotesPagedResponse |
listNotes(String parent,
String filter)
Lists notes for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListNotesRequest,ListNotesResponse> |
listNotesCallable()
Lists notes for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListNotesRequest,GrafeasClient.ListNotesPagedResponse> |
listNotesPagedCallable()
Lists notes for the specified project.
|
GrafeasClient.ListOccurrencesPagedResponse |
listOccurrences(ListOccurrencesRequest request)
Lists occurrences for the specified project.
|
GrafeasClient.ListOccurrencesPagedResponse |
listOccurrences(ProjectName parent,
String filter)
Lists occurrences for the specified project.
|
GrafeasClient.ListOccurrencesPagedResponse |
listOccurrences(String parent,
String filter)
Lists occurrences for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListOccurrencesRequest,ListOccurrencesResponse> |
listOccurrencesCallable()
Lists occurrences for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListOccurrencesRequest,GrafeasClient.ListOccurrencesPagedResponse> |
listOccurrencesPagedCallable()
Lists occurrences for the specified project.
|
void |
shutdown() |
void |
shutdownNow() |
Note |
updateNote(NoteName name,
Note note,
FieldMask updateMask)
Updates the specified note.
|
Note |
updateNote(String name,
Note note,
FieldMask updateMask)
Updates the specified note.
|
Note |
updateNote(UpdateNoteRequest request)
Updates the specified note.
|
com.google.api.gax.rpc.UnaryCallable<UpdateNoteRequest,Note> |
updateNoteCallable()
Updates the specified note.
|
Occurrence |
updateOccurrence(OccurrenceName name,
Occurrence occurrence,
FieldMask updateMask)
Updates the specified occurrence.
|
Occurrence |
updateOccurrence(String name,
Occurrence occurrence,
FieldMask updateMask)
Updates the specified occurrence.
|
Occurrence |
updateOccurrence(UpdateOccurrenceRequest request)
Updates the specified occurrence.
|
com.google.api.gax.rpc.UnaryCallable<UpdateOccurrenceRequest,Occurrence> |
updateOccurrenceCallable()
Updates the specified occurrence.
|
protected GrafeasClient(GrafeasSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected GrafeasClient(GrafeasStub stub)
public static final GrafeasClient create() throws IOException
IOException
public static final GrafeasClient create(GrafeasSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final GrafeasClient create(GrafeasStub stub)
public final GrafeasSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public GrafeasStub getStub()
public final Occurrence getOccurrence(OccurrenceName name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Occurrence response = grafeasClient.getOccurrence(name);
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence getOccurrence(String name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Occurrence response = grafeasClient.getOccurrence(name.toString());
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence getOccurrence(GetOccurrenceRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
GetOccurrenceRequest request = GetOccurrenceRequest.newBuilder()
.setName(name.toString())
.build();
Occurrence response = grafeasClient.getOccurrence(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetOccurrenceRequest,Occurrence> getOccurrenceCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
GetOccurrenceRequest request = GetOccurrenceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Occurrence> future = grafeasClient.getOccurrenceCallable().futureCall(request);
// Do something
Occurrence response = future.get();
}
public final GrafeasClient.ListOccurrencesPagedResponse listOccurrences(ProjectName parent, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "";
for (Occurrence element : grafeasClient.listOccurrences(parent, filter).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The name of the project to list occurrences for in the form of
`projects/[PROJECT_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListOccurrencesPagedResponse listOccurrences(String parent, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "";
for (Occurrence element : grafeasClient.listOccurrences(parent.toString(), filter).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The name of the project to list occurrences for in the form of
`projects/[PROJECT_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListOccurrencesPagedResponse listOccurrences(ListOccurrencesRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListOccurrencesRequest request = ListOccurrencesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Occurrence element : grafeasClient.listOccurrences(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListOccurrencesRequest,GrafeasClient.ListOccurrencesPagedResponse> listOccurrencesPagedCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListOccurrencesRequest request = ListOccurrencesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListOccurrencesPagedResponse> future = grafeasClient.listOccurrencesPagedCallable().futureCall(request);
// Do something
for (Occurrence element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListOccurrencesRequest,ListOccurrencesResponse> listOccurrencesCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListOccurrencesRequest request = ListOccurrencesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListOccurrencesResponse response = grafeasClient.listOccurrencesCallable().call(request);
for (Occurrence element : response.getOccurrencesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void deleteOccurrence(OccurrenceName name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
grafeasClient.deleteOccurrence(name);
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteOccurrence(String name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
grafeasClient.deleteOccurrence(name.toString());
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteOccurrence(DeleteOccurrenceRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
DeleteOccurrenceRequest request = DeleteOccurrenceRequest.newBuilder()
.setName(name.toString())
.build();
grafeasClient.deleteOccurrence(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteOccurrenceRequest,Empty> deleteOccurrenceCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
DeleteOccurrenceRequest request = DeleteOccurrenceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = grafeasClient.deleteOccurrenceCallable().futureCall(request);
// Do something
future.get();
}
public final Occurrence createOccurrence(ProjectName parent, Occurrence occurrence)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
Occurrence response = grafeasClient.createOccurrence(parent, occurrence);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
occurrence is to be created.occurrence
- The occurrence to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence createOccurrence(String parent, Occurrence occurrence)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
Occurrence response = grafeasClient.createOccurrence(parent.toString(), occurrence);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
occurrence is to be created.occurrence
- The occurrence to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence createOccurrence(CreateOccurrenceRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
CreateOccurrenceRequest request = CreateOccurrenceRequest.newBuilder()
.setParent(parent.toString())
.setOccurrence(occurrence)
.build();
Occurrence response = grafeasClient.createOccurrence(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateOccurrenceRequest,Occurrence> createOccurrenceCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
CreateOccurrenceRequest request = CreateOccurrenceRequest.newBuilder()
.setParent(parent.toString())
.setOccurrence(occurrence)
.build();
ApiFuture<Occurrence> future = grafeasClient.createOccurrenceCallable().futureCall(request);
// Do something
Occurrence response = future.get();
}
public final BatchCreateOccurrencesResponse batchCreateOccurrences(ProjectName parent, List<Occurrence> occurrences)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
BatchCreateOccurrencesResponse response = grafeasClient.batchCreateOccurrences(parent, occurrences);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
occurrences are to be created.occurrences
- The occurrences to create. Max allowed length is 1000.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final BatchCreateOccurrencesResponse batchCreateOccurrences(String parent, List<Occurrence> occurrences)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
BatchCreateOccurrencesResponse response = grafeasClient.batchCreateOccurrences(parent.toString(), occurrences);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
occurrences are to be created.occurrences
- The occurrences to create. Max allowed length is 1000.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final BatchCreateOccurrencesResponse batchCreateOccurrences(BatchCreateOccurrencesRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
BatchCreateOccurrencesRequest request = BatchCreateOccurrencesRequest.newBuilder()
.setParent(parent.toString())
.addAllOccurrences(occurrences)
.build();
BatchCreateOccurrencesResponse response = grafeasClient.batchCreateOccurrences(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<BatchCreateOccurrencesRequest,BatchCreateOccurrencesResponse> batchCreateOccurrencesCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
BatchCreateOccurrencesRequest request = BatchCreateOccurrencesRequest.newBuilder()
.setParent(parent.toString())
.addAllOccurrences(occurrences)
.build();
ApiFuture<BatchCreateOccurrencesResponse> future = grafeasClient.batchCreateOccurrencesCallable().futureCall(request);
// Do something
BatchCreateOccurrencesResponse response = future.get();
}
public final Occurrence updateOccurrence(OccurrenceName name, Occurrence occurrence, FieldMask updateMask)
Sample 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);
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.occurrence
- The updated occurrence.updateMask
- The fields to update.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence updateOccurrence(String name, Occurrence occurrence, FieldMask updateMask)
Sample 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.toString(), occurrence, updateMask);
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.occurrence
- The updated occurrence.updateMask
- The fields to update.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Occurrence updateOccurrence(UpdateOccurrenceRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Occurrence occurrence = Occurrence.newBuilder().build();
UpdateOccurrenceRequest request = UpdateOccurrenceRequest.newBuilder()
.setName(name.toString())
.setOccurrence(occurrence)
.build();
Occurrence response = grafeasClient.updateOccurrence(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateOccurrenceRequest,Occurrence> updateOccurrenceCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Occurrence occurrence = Occurrence.newBuilder().build();
UpdateOccurrenceRequest request = UpdateOccurrenceRequest.newBuilder()
.setName(name.toString())
.setOccurrence(occurrence)
.build();
ApiFuture<Occurrence> future = grafeasClient.updateOccurrenceCallable().futureCall(request);
// Do something
Occurrence response = future.get();
}
public final Note getOccurrenceNote(OccurrenceName name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Note response = grafeasClient.getOccurrenceNote(name);
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note getOccurrenceNote(String name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
Note response = grafeasClient.getOccurrenceNote(name.toString());
}
name
- The name of the occurrence in the form of
`projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note getOccurrenceNote(GetOccurrenceNoteRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
GetOccurrenceNoteRequest request = GetOccurrenceNoteRequest.newBuilder()
.setName(name.toString())
.build();
Note response = grafeasClient.getOccurrenceNote(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetOccurrenceNoteRequest,Note> getOccurrenceNoteCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]");
GetOccurrenceNoteRequest request = GetOccurrenceNoteRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Note> future = grafeasClient.getOccurrenceNoteCallable().futureCall(request);
// Do something
Note response = future.get();
}
public final Note getNote(NoteName name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
Note response = grafeasClient.getNote(name);
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note getNote(String name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
Note response = grafeasClient.getNote(name.toString());
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note getNote(GetNoteRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
GetNoteRequest request = GetNoteRequest.newBuilder()
.setName(name.toString())
.build();
Note response = grafeasClient.getNote(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetNoteRequest,Note> getNoteCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
GetNoteRequest request = GetNoteRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Note> future = grafeasClient.getNoteCallable().futureCall(request);
// Do something
Note response = future.get();
}
public final GrafeasClient.ListNotesPagedResponse listNotes(ProjectName parent, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "";
for (Note element : grafeasClient.listNotes(parent, filter).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListNotesPagedResponse listNotes(String parent, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "";
for (Note element : grafeasClient.listNotes(parent.toString(), filter).iterateAll()) {
// doThingsWith(element);
}
}
parent
- The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListNotesPagedResponse listNotes(ListNotesRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListNotesRequest request = ListNotesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Note element : grafeasClient.listNotes(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListNotesRequest,GrafeasClient.ListNotesPagedResponse> listNotesPagedCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListNotesRequest request = ListNotesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListNotesPagedResponse> future = grafeasClient.listNotesPagedCallable().futureCall(request);
// Do something
for (Note element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListNotesRequest,ListNotesResponse> listNotesCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListNotesRequest request = ListNotesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListNotesResponse response = grafeasClient.listNotesCallable().call(request);
for (Note element : response.getNotesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void deleteNote(NoteName name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
grafeasClient.deleteNote(name);
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteNote(String name)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
grafeasClient.deleteNote(name.toString());
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteNote(DeleteNoteRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
DeleteNoteRequest request = DeleteNoteRequest.newBuilder()
.setName(name.toString())
.build();
grafeasClient.deleteNote(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteNoteRequest,Empty> deleteNoteCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
DeleteNoteRequest request = DeleteNoteRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = grafeasClient.deleteNoteCallable().futureCall(request);
// Do something
future.get();
}
public final Note createNote(ProjectName parent, String noteId, Note note)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "";
Note note = Note.newBuilder().build();
Note response = grafeasClient.createNote(parent, noteId, note);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
note is to be created.noteId
- The ID to use for this note.note
- The note to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note createNote(String parent, String noteId, Note note)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "";
Note note = Note.newBuilder().build();
Note response = grafeasClient.createNote(parent.toString(), noteId, note);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
note is to be created.noteId
- The ID to use for this note.note
- The note to create.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note createNote(CreateNoteRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "";
Note note = Note.newBuilder().build();
CreateNoteRequest request = CreateNoteRequest.newBuilder()
.setParent(parent.toString())
.setNoteId(noteId)
.setNote(note)
.build();
Note response = grafeasClient.createNote(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateNoteRequest,Note> createNoteCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "";
Note note = Note.newBuilder().build();
CreateNoteRequest request = CreateNoteRequest.newBuilder()
.setParent(parent.toString())
.setNoteId(noteId)
.setNote(note)
.build();
ApiFuture<Note> future = grafeasClient.createNoteCallable().futureCall(request);
// Do something
Note response = future.get();
}
public final BatchCreateNotesResponse batchCreateNotes(ProjectName parent, Map<String,Note> notes)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Map<String, Note> notes = new HashMap<>();
BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(parent, notes);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
notes are to be created.notes
- The notes to create. Max allowed length is 1000.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final BatchCreateNotesResponse batchCreateNotes(String parent, Map<String,Note> notes)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Map<String, Note> notes = new HashMap<>();
BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(parent.toString(), notes);
}
parent
- The name of the project in the form of `projects/[PROJECT_ID]`, under which the
notes are to be created.notes
- The notes to create. Max allowed length is 1000.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final BatchCreateNotesResponse batchCreateNotes(BatchCreateNotesRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Map<String, Note> notes = new HashMap<>();
BatchCreateNotesRequest request = BatchCreateNotesRequest.newBuilder()
.setParent(parent.toString())
.putAllNotes(notes)
.build();
BatchCreateNotesResponse response = grafeasClient.batchCreateNotes(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<BatchCreateNotesRequest,BatchCreateNotesResponse> batchCreateNotesCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Map<String, Note> notes = new HashMap<>();
BatchCreateNotesRequest request = BatchCreateNotesRequest.newBuilder()
.setParent(parent.toString())
.putAllNotes(notes)
.build();
ApiFuture<BatchCreateNotesResponse> future = grafeasClient.batchCreateNotesCallable().futureCall(request);
// Do something
BatchCreateNotesResponse response = future.get();
}
public final Note updateNote(NoteName name, Note note, FieldMask updateMask)
Sample 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);
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.note
- The updated note.updateMask
- The fields to update.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note updateNote(String name, Note note, FieldMask updateMask)
Sample 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.toString(), note, updateMask);
}
name
- The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.note
- The updated note.updateMask
- The fields to update.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Note updateNote(UpdateNoteRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
Note note = Note.newBuilder().build();
UpdateNoteRequest request = UpdateNoteRequest.newBuilder()
.setName(name.toString())
.setNote(note)
.build();
Note response = grafeasClient.updateNote(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateNoteRequest,Note> updateNoteCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
Note note = Note.newBuilder().build();
UpdateNoteRequest request = UpdateNoteRequest.newBuilder()
.setName(name.toString())
.setNote(note)
.build();
ApiFuture<Note> future = grafeasClient.updateNoteCallable().futureCall(request);
// Do something
Note response = future.get();
}
public final GrafeasClient.ListNoteOccurrencesPagedResponse listNoteOccurrences(NoteName name, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
String filter = "";
for (Occurrence element : grafeasClient.listNoteOccurrences(name, filter).iterateAll()) {
// doThingsWith(element);
}
}
name
- The name of the note to list occurrences for in the form of
`projects/[PROVIDER_ID]/notes/[NOTE_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListNoteOccurrencesPagedResponse listNoteOccurrences(String name, String filter)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
String filter = "";
for (Occurrence element : grafeasClient.listNoteOccurrences(name.toString(), filter).iterateAll()) {
// doThingsWith(element);
}
}
name
- The name of the note to list occurrences for in the form of
`projects/[PROVIDER_ID]/notes/[NOTE_ID]`.filter
- The filter expression.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final GrafeasClient.ListNoteOccurrencesPagedResponse listNoteOccurrences(ListNoteOccurrencesRequest request)
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder()
.setName(name.toString())
.build();
for (Occurrence element : grafeasClient.listNoteOccurrences(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListNoteOccurrencesRequest,GrafeasClient.ListNoteOccurrencesPagedResponse> listNoteOccurrencesPagedCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<ListNoteOccurrencesPagedResponse> future = grafeasClient.listNoteOccurrencesPagedCallable().futureCall(request);
// Do something
for (Occurrence element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListNoteOccurrencesRequest,ListNoteOccurrencesResponse> listNoteOccurrencesCallable()
Sample code:
try (GrafeasClient grafeasClient = GrafeasClient.create()) {
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest.newBuilder()
.setName(name.toString())
.build();
while (true) {
ListNoteOccurrencesResponse response = grafeasClient.listNoteOccurrencesCallable().call(request);
for (Occurrence element : response.getOccurrencesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.