Search in sources :

Example 1 with DeleteInspectTemplateRequest

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

the class Templates method deleteInspectTemplate.

// [END dlp_list_inspect_templates]
// [START dlp_delete_inspect_template]
/**
 * Delete the DLP inspection configuration template with the specified name.
 *
 * @param projectId Google Cloud Project ID
 * @param templateId Template ID to be deleted
 */
private static void deleteInspectTemplate(String projectId, String templateId) {
    // construct the template name to be deleted
    String templateName = String.format("projects/%s/inspectTemplates/%s", projectId, templateId);
    // instantiate the client
    try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
        // create delete template request
        DeleteInspectTemplateRequest request = DeleteInspectTemplateRequest.newBuilder().setName(templateName).build();
        dlpServiceClient.deleteInspectTemplate(request);
        System.out.printf("Deleted template: %s\n", templateName);
    } catch (Exception e) {
        System.err.printf("Error deleting template: %s\n", templateName);
    }
}
Also used : DlpServiceClient(com.google.cloud.dlp.v2.DlpServiceClient) DeleteInspectTemplateRequest(com.google.privacy.dlp.v2.DeleteInspectTemplateRequest) ParseException(org.apache.commons.cli.ParseException)

Aggregations

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