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

Function listTriggers

dlp/listTriggers.js:33–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 // const projectId = 'my-project'
32
33 async function listTriggers() {
34 // Construct trigger listing request
35 const request = {
36 parent: `projects/${projectId}/locations/global`,
37 };
38
39 // Helper function to pretty-print dates
40 const formatDate = date => {
41 const msSinceEpoch = parseInt(date.seconds, 10) * 1000;
42 return new Date(msSinceEpoch).toLocaleString('en-US');
43 };
44
45 // Run trigger listing request
46 const [triggers] = await dlp.listJobTriggers(request);
47 triggers.forEach(trigger => {
48 // Log trigger details
49 console.log(`Trigger ${trigger.name}:`);
50 console.log(` Created: ${formatDate(trigger.createTime)}`);
51 console.log(` Updated: ${formatDate(trigger.updateTime)}`);
52 if (trigger.displayName) {
53 console.log(` Display Name: ${trigger.displayName}`);
54 }
55 if (trigger.description) {
56 console.log(` Description: ${trigger.description}`);
57 }
58 console.log(` Status: ${trigger.status}`);
59 console.log(` Error count: ${trigger.errors.length}`);
60 });
61 }
62
63 listTriggers();
64 // [END dlp_list_triggers]

Callers 1

mainFunction · 0.85

Calls 1

formatDateFunction · 0.70

Tested by

no test coverage detected