use of com.google.privacy.dlp.v2.ListDlpJobsRequest in project java-docs-samples by GoogleCloudPlatform.
the class Jobs method listJobs.
// [START dlp_list_jobs]
/*
* List DLP jobs
*
* @param projectId The project ID to run the API call under
* @param filter The filter expression to use, eg. state=DONE For more information on filter
* syntax see https://cloud.google.com/dlp/docs/reference/rest/v2/projects.dlpJobs/list
* @param jobType The type of job to list (either 'INSPECT_JOB' or 'RISK_ANALYSIS_JOB')
*/
private static void listJobs(String projectId, String filter, DlpJobType jobType) throws Exception {
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
ListDlpJobsRequest listDlpJobsRequest = ListDlpJobsRequest.newBuilder().setParent(ProjectName.of(projectId).toString()).setFilter(filter).setType(jobType).build();
DlpServiceClient.ListDlpJobsPagedResponse response = dlpServiceClient.listDlpJobs(listDlpJobsRequest);
for (DlpJob dlpJob : response.getPage().getValues()) {
System.out.println(dlpJob.getName() + " -- " + dlpJob.getState());
}
}
}
Aggregations