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

Function main

dlp/createInspectTemplate.js:22–87  ·  view source on GitHub ↗
(
  projectId,
  templateId,
  displayName,
  infoTypes,
  includeQuote,
  minLikelihood,
  maxFindings
)

Source from the content-addressed store, hash-verified

20// usage: node createInspectTemplate.js my-project VERY_LIKELY PERSON_NAME 5 false my-template-id
21
22function main(
23 projectId,
24 templateId,
25 displayName,
26 infoTypes,
27 includeQuote,
28 minLikelihood,
29 maxFindings
30) {
31 infoTypes = transformCLI(infoTypes);
32 // [START dlp_create_inspect_template]
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 minimum likelihood required before returning a match
43 // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';
44
45 // The maximum number of findings to report per request (0 = server maximum)
46 // const maxFindings = 0;
47
48 // The infoTypes of information to match
49 // const infoTypes = [{ name: 'PHONE_NUMBER' }, { name: 'EMAIL_ADDRESS' }, { name: 'CREDIT_CARD_NUMBER' }];
50
51 // Whether to include the matching string
52 // const includeQuote = true;
53
54 // (Optional) The name of the template to be created.
55 // const templateId = 'my-template';
56
57 // (Optional) The human-readable name to give the template
58 // const displayName = 'My template';
59
60 async function createInspectTemplate() {
61 // Construct the inspection configuration for the template
62 const inspectConfig = {
63 infoTypes: infoTypes,
64 minLikelihood: minLikelihood,
65 includeQuote: includeQuote,
66 limits: {
67 maxFindingsPerRequest: maxFindings,
68 },
69 };
70
71 // Construct template-creation request
72 const request = {
73 parent: `projects/${projectId}/locations/global`,
74 inspectTemplate: {
75 inspectConfig: inspectConfig,
76 displayName: displayName,
77 },
78 templateId: templateId,
79 };

Callers 1

Calls 2

createInspectTemplateFunction · 0.85
transformCLIFunction · 0.70

Tested by

no test coverage detected