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

Function createTrigger

dlp/createTrigger.js:72–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70 // const maxFindings = 0;
71
72 async function createTrigger() {
73 // Get reference to the bucket to be inspected
74 const storageItem = {
75 cloudStorageOptions: {
76 fileSet: {url: `gs://${bucketName}/*`},
77 },
78 timeSpanConfig: {
79 enableAutoPopulationOfTimespanConfig: autoPopulateTimespan,
80 },
81 };
82
83 // Construct job to be triggered
84 const job = {
85 inspectConfig: {
86 infoTypes: infoTypes,
87 minLikelihood: minLikelihood,
88 limits: {
89 maxFindingsPerRequest: maxFindings,
90 },
91 },
92 storageConfig: storageItem,
93 };
94
95 // Construct trigger creation request
96 const request = {
97 parent: `projects/${projectId}/locations/global`,
98 jobTrigger: {
99 inspectJob: job,
100 displayName: displayName,
101 description: description,
102 triggers: [
103 {
104 schedule: {
105 recurrencePeriodDuration: {
106 seconds: scanPeriod * 60 * 60 * 24, // Trigger the scan daily
107 },
108 },
109 },
110 ],
111 status: 'HEALTHY',
112 },
113 triggerId: triggerId,
114 };
115
116 // Run trigger creation request
117 const [trigger] = await dlp.createJobTrigger(request);
118 console.log(`Successfully created trigger ${trigger.name}.`);
119 }
120
121 createTrigger();
122 // [END dlp_create_trigger]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected