use of com.google.privacy.dlp.v2.ListInspectTemplatesRequest in project java-docs-samples by GoogleCloudPlatform.
the class Templates method listInspectTemplates.
// [END dlp_create_inspect_template]
// [START dlp_list_inspect_templates]
/**
* List DLP inspection templates created in a given project
*
* @param projectId Google Cloud Project ID
*/
private static void listInspectTemplates(String projectId) {
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
ListInspectTemplatesRequest request = ListInspectTemplatesRequest.newBuilder().setParent(ProjectName.of(projectId).toString()).setPageSize(1).build();
ListInspectTemplatesPagedResponse response = dlpServiceClient.listInspectTemplates(request);
ListInspectTemplatesPage page = response.getPage();
ListInspectTemplatesResponse templatesResponse = page.getResponse();
for (InspectTemplate template : templatesResponse.getInspectTemplatesList()) {
System.out.printf("Template name: %s\n", template.getName());
if (template.getDisplayName() != null) {
System.out.printf("\tDisplay name: %s \n", template.getDisplayName());
System.out.printf("\tCreate time: %s \n", template.getCreateTime());
System.out.printf("\tUpdate time: %s \n", template.getUpdateTime());
// print inspection config
InspectConfig inspectConfig = template.getInspectConfig();
for (InfoType infoType : inspectConfig.getInfoTypesList()) {
System.out.printf("\tInfoType: %s\n", infoType.getName());
}
System.out.printf("\tMin likelihood: %s\n", inspectConfig.getMinLikelihood());
System.out.printf("\tLimits: %s\n", inspectConfig.getLimits().getMaxFindingsPerRequest());
}
}
} catch (Exception e) {
System.out.printf("Error creating template: %s", e.getMessage());
}
}
Aggregations