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);
}
}
Aggregations