Search in sources :

Example 1 with ListDlpJobsRequest

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());
        }
    }
}
Also used : ListDlpJobsRequest(com.google.privacy.dlp.v2.ListDlpJobsRequest) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) DlpJob(com.google.privacy.dlp.v2.DlpJob)

Aggregations

DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)1 DlpJob (com.google.privacy.dlp.v2.DlpJob)1 ListDlpJobsRequest (com.google.privacy.dlp.v2.ListDlpJobsRequest)1