MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

dlp/listInspectTemplates.js:20–68  ·  view source on GitHub ↗
(projectId)

Source from the content-addressed store, hash-verified

18// usage: node listInspectTemplates.js my-project
19
20function main(projectId) {
21 // [START dlp_list_inspect_templates]
22 // Imports the Google Cloud Data Loss Prevention library
23 const DLP = require('@google-cloud/dlp');
24
25 // Instantiates a client
26 const dlp = new DLP.DlpServiceClient();
27
28 // The project ID to run the API call under
29 // const projectId = 'my-project';
30
31 // Helper function to pretty-print dates
32 const formatDate = date => {
33 const msSinceEpoch = parseInt(date.seconds, 10) * 1000;
34 return new Date(msSinceEpoch).toLocaleString('en-US');
35 };
36
37 async function listInspectTemplates() {
38 // Construct template-listing request
39 const request = {
40 parent: `projects/${projectId}/locations/global`,
41 };
42
43 // Run template-deletion request
44 const [templates] = await dlp.listInspectTemplates(request);
45
46 templates.forEach(template => {
47 console.log(`Template ${template.name}`);
48 if (template.displayName) {
49 console.log(` Display name: ${template.displayName}`);
50 }
51
52 console.log(` Created: ${formatDate(template.createTime)}`);
53 console.log(` Updated: ${formatDate(template.updateTime)}`);
54
55 const inspectConfig = template.inspectConfig;
56 const infoTypes = inspectConfig.infoTypes.map(x => x.name);
57 console.log(' InfoTypes:', infoTypes.join(' '));
58 console.log(' Minimum likelihood:', inspectConfig.minLikelihood);
59 console.log(' Include quotes:', inspectConfig.includeQuote);
60
61 const limits = inspectConfig.limits;
62 console.log(' Max findings per request:', limits.maxFindingsPerRequest);
63 });
64 }
65
66 listInspectTemplates();
67 // [END dlp_list_inspect_templates]
68}
69
70main(...process.argv.slice(2));
71process.on('unhandledRejection', err => {

Callers 1

Calls 1

listInspectTemplatesFunction · 0.85

Tested by

no test coverage detected