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

Function quickStart

dlp/quickstart.js:37–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35 // const projectId = 'my-project';
36
37 async function quickStart() {
38 // The minimum likelihood required before returning a match
39 const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';
40
41 // The maximum number of findings to report (0 = server maximum)
42 const maxFindings = 0;
43
44 // The infoTypes of information to match
45 const infoTypes = [{name: 'PERSON_NAME'}, {name: 'US_STATE'}];
46
47 // Whether to include the matching string
48 const includeQuote = true;
49
50 // Construct item to inspect
51 const item = {value: string};
52
53 // Construct request
54 const request = {
55 parent: `projects/${projectId}/locations/global`,
56 inspectConfig: {
57 infoTypes: infoTypes,
58 minLikelihood: minLikelihood,
59 limits: {
60 maxFindingsPerRequest: maxFindings,
61 },
62 includeQuote: includeQuote,
63 },
64 item: item,
65 };
66
67 // Run request
68 const [response] = await dlp.inspectContent(request);
69 const findings = response.result.findings;
70 if (findings.length > 0) {
71 console.log('Findings:');
72 findings.forEach(finding => {
73 if (includeQuote) {
74 console.log(`\tQuote: ${finding.quote}`);
75 }
76 console.log(`\tInfo type: ${finding.infoType.name}`);
77 console.log(`\tLikelihood: ${finding.likelihood}`);
78 });
79 } else {
80 console.log('No findings.');
81 }
82 }
83 quickStart();
84 // [END dlp_quickstart]
85}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected