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

Function main

dlp/inspectDataToHybridJobTrigger.js:22–127  ·  view source on GitHub ↗
(projectId, string, jobTriggerId)

Source from the content-addressed store, hash-verified

20// usage: node inspectDataToHybridJobTrigger.js my-project string jobTriggerId
21
22async function main(projectId, string, jobTriggerId) {
23 // [START dlp_inspect_send_data_to_hybrid_job_trigger]
24 // Imports the Google Cloud Data Loss Prevention library
25 const DLP = require('@google-cloud/dlp');
26
27 // Instantiates a client
28 const dlpClient = new DLP.DlpServiceClient();
29
30 // The project ID to run the API call under.
31 // const projectId = "your-project-id";
32
33 // The string to de-identify
34 // const string = 'My email is test@example.org';
35
36 // Job Trigger ID
37 // const jobTriggerId = 'your-job-trigger-id';
38
39 async function inspectDataToHybridJobTrigger() {
40 // Contains metadata to associate with the content.
41 const container = {
42 full_path: '10.0.0.2:logs1:app1',
43 relative_path: 'app1',
44 root_path: '10.0.0.2:logs1',
45 type: 'logging_sys',
46 version: '1.2',
47 };
48
49 const labels = {env: 'prod', 'appointment-bookings-comments': ''};
50
51 // Build the hybrid content item.
52 const hybridContentItem = {
53 item: {value: string},
54 findingDetails: {
55 containerDetails: container,
56 labels,
57 },
58 };
59 let jobName;
60 const fullTriggerName = `projects/${projectId}/jobTriggers/${jobTriggerId}`;
61 // Activate the job trigger.
62 try {
63 const response = await dlpClient.activateJobTrigger({
64 name: fullTriggerName,
65 });
66 jobName = response[0].name;
67 } catch (err) {
68 console.log(err);
69 if (err.code === 3) {
70 const response = await dlpClient.listDlpJobs({
71 parent: fullTriggerName,
72 filter: `trigger_name=${fullTriggerName}`,
73 });
74 jobName = response[0][0].name;
75 }
76 // Ignore error related to job trigger already active
77 if (err.code !== 3) {
78 console.log(err.message);
79 return;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected