Search in sources :

Example 1 with ProjectJobTriggerName

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

the class Triggers method deleteTrigger.

// [END dlp_list_triggers]
// [START dlp_delete_trigger]
/**
 * Delete a DLP trigger in a project.
 *
 * @param projectId The project ID to run the API call under.
 * @param triggerId Trigger ID
 */
private static void deleteTrigger(String projectId, String triggerId) {
    ProjectJobTriggerName triggerName = ProjectJobTriggerName.of(projectId, triggerId);
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
        DeleteJobTriggerRequest deleteJobTriggerRequest = DeleteJobTriggerRequest.newBuilder().setName(triggerName.toString()).build();
        dlpServiceClient.deleteJobTrigger(deleteJobTriggerRequest);
        System.out.println("Trigger deleted: " + triggerName.toString());
    } catch (Exception e) {
        System.out.println("Error deleting trigger :" + e.getMessage());
    }
}
Also used : ProjectJobTriggerName(com.google.privacy.dlp.v2.ProjectJobTriggerName) DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) DeleteJobTriggerRequest(com.google.privacy.dlp.v2.DeleteJobTriggerRequest) ParseException(org.apache.commons.cli.ParseException)

Aggregations

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