Search in sources :

Example 1 with ListJobTriggersRequest

use of com.google.privacy.dlp.v2.ListJobTriggersRequest in project java-docs-samples by GoogleCloudPlatform.

the class Triggers method listTriggers.

// [END dlp_create_trigger]
// [START dlp_list_triggers]
/**
 * List all DLP triggers for a given project.
 *
 * @param projectId The project ID to run the API call under.
 */
private static void listTriggers(String projectId) {
    // Instantiates a client
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
        ListJobTriggersRequest listJobTriggersRequest = ListJobTriggersRequest.newBuilder().setParent(ProjectName.of(projectId).toString()).build();
        DlpServiceClient.ListJobTriggersPagedResponse response = dlpServiceClient.listJobTriggers(listJobTriggersRequest);
        response.getPage().getValues().forEach(trigger -> {
            System.out.println("Trigger: " + trigger.getName());
            System.out.println("\tCreated: " + trigger.getCreateTime());
            System.out.println("\tUpdated: " + trigger.getUpdateTime());
            if (trigger.getDisplayName() != null) {
                System.out.println("\tDisplay name: " + trigger.getDisplayName());
            }
            if (trigger.getDescription() != null) {
                System.out.println("\tDescription: " + trigger.getDescription());
            }
            System.out.println("\tStatus: " + trigger.getStatus());
            System.out.println("\tError count: " + trigger.getErrorsCount());
        });
    } catch (Exception e) {
        System.out.println("Error listing triggers :" + e.getMessage());
    }
}
Also used : ListJobTriggersRequest(com.google.privacy.dlp.v2.ListJobTriggersRequest) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) ParseException(org.apache.commons.cli.ParseException)

Aggregations

DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)1 ListJobTriggersRequest (com.google.privacy.dlp.v2.ListJobTriggersRequest)1 ParseException (org.apache.commons.cli.ParseException)1