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

Function inspectString

dlp/inspectString.js:62–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60 // const includeQuote = true;
61
62 async function inspectString() {
63 // Construct item to inspect
64 const item = {value: string};
65
66 // Construct request
67 const request = {
68 parent: `projects/${projectId}/locations/global`,
69 inspectConfig: {
70 infoTypes: infoTypes,
71 customInfoTypes: customInfoTypes,
72 minLikelihood: minLikelihood,
73 includeQuote: includeQuote,
74 limits: {
75 maxFindingsPerRequest: maxFindings,
76 },
77 },
78 item: item,
79 };
80
81 // Run request
82 const [response] = await dlp.inspectContent(request);
83 const findings = response.result.findings;
84 if (findings.length > 0) {
85 console.log('Findings:');
86 findings.forEach(finding => {
87 if (includeQuote) {
88 console.log(`\tQuote: ${finding.quote}`);
89 }
90 console.log(`\tInfo type: ${finding.infoType.name}`);
91 console.log(`\tLikelihood: ${finding.likelihood}`);
92 });
93 } else {
94 console.log('No findings.');
95 }
96 }
97 inspectString();
98 // [END dlp_inspect_string]
99}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected