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

Function main

dlp/inspectPhoneNumber.js:22–100  ·  view source on GitHub ↗
(
  projectId,
  string,
  minLikelihood,
  maxFindings,
  infoTypes,
  customInfoTypes,
  includeQuote
)

Source from the content-addressed store, hash-verified

20// usage: node inspectPhoneNumber.js my-project string minLikelihood maxFindings infoTypes customInfoTypes includeQuote
21
22function main(
23 projectId,
24 string,
25 minLikelihood,
26 maxFindings,
27 infoTypes,
28 customInfoTypes,
29 includeQuote
30) {
31 [infoTypes, customInfoTypes] = transformCLI(infoTypes, customInfoTypes);
32 // [START dlp_inspect_phone_number]
33 // Imports the Google Cloud Data Loss Prevention library
34 const DLP = require('@google-cloud/dlp');
35
36 // Instantiates a client
37 const dlp = new DLP.DlpServiceClient();
38
39 // The project ID to run the API call under
40 // const projectId = 'my-project';
41
42 // The string to inspect
43 // const string = 'My email is gary@example.com and my phone number is (223) 456-7890.';
44
45 // The minimum likelihood required before returning a match
46 // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';
47
48 // The maximum number of findings to report per request (0 = server maximum)
49 // const maxFindings = 0;
50
51 // The infoTypes of information to match
52 // See https://cloud.google.com/dlp/docs/concepts-infotypes for more information
53 // about supported infoTypes.
54 // const infoTypes = [{ name: 'PHONE_NUMBER' }];
55
56 // The customInfoTypes of information to match
57 // const customInfoTypes = [{ infoType: { name: 'DICT_TYPE' }, dictionary: { wordList: { words: ['foo', 'bar', 'baz']}}},
58 // { infoType: { name: 'REGEX_TYPE' }, regex: {pattern: '\\(\\d{3}\\) \\d{3}-\\d{4}'}}];
59
60 // Whether to include the matching string
61 // const includeQuote = true;
62
63 async function inspectPhoneNumber() {
64 // Construct item to inspect
65 const item = {value: string};
66
67 // Construct request
68 const request = {
69 parent: `projects/${projectId}/locations/global`,
70 inspectConfig: {
71 infoTypes: infoTypes,
72 customInfoTypes: customInfoTypes,
73 minLikelihood: minLikelihood,
74 includeQuote: includeQuote,
75 limits: {
76 maxFindingsPerRequest: maxFindings,
77 },
78 },
79 item: item,

Callers 1

Calls 2

inspectPhoneNumberFunction · 0.85
transformCLIFunction · 0.70

Tested by

no test coverage detected