(projectId, jobTriggerName)
| 19 | // description: Uses the Data Loss Prevention API to update job trigger with suitable configuration and mask. |
| 20 | // usage: node updateTrigger.js projectId, jobTriggerName |
| 21 | function main(projectId, jobTriggerName) { |
| 22 | // [START dlp_update_trigger] |
| 23 | // Imports the Google Cloud Data Loss Prevention library |
| 24 | const DLP = require('@google-cloud/dlp'); |
| 25 | |
| 26 | // Instantiates a client |
| 27 | const dlpClient = new DLP.DlpServiceClient(); |
| 28 | |
| 29 | // The project ID to run the API call under |
| 30 | // const projectId = 'my-project'; |
| 31 | |
| 32 | // The job trigger ID to run the API call under |
| 33 | // const jobTriggerName = 'your-job-trigger-name'; |
| 34 | |
| 35 | async function updateTrigger() { |
| 36 | // Construct inspect configuration to match PERSON_NAME infotype |
| 37 | const inspectConfig = { |
| 38 | infoTypes: [{name: 'PERSON_NAME'}], |
| 39 | minLikelihood: 'LIKELY', |
| 40 | }; |
| 41 | |
| 42 | // Configure the job trigger we want to update. |
| 43 | const jobTrigger = {inspectJob: {inspectConfig}}; |
| 44 | |
| 45 | const updateMask = { |
| 46 | paths: [ |
| 47 | 'inspect_job.inspect_config.info_types', |
| 48 | 'inspect_job.inspect_config.min_likelihood', |
| 49 | ], |
| 50 | }; |
| 51 | |
| 52 | // Combine configurations into a request for the service. |
| 53 | const request = { |
| 54 | name: `projects/${projectId}/jobTriggers/${jobTriggerName}`, |
| 55 | jobTrigger, |
| 56 | updateMask, |
| 57 | }; |
| 58 | |
| 59 | // Send the request and receive response from the service |
| 60 | const [updatedJobTrigger] = await dlpClient.updateJobTrigger(request); |
| 61 | |
| 62 | // Print the results |
| 63 | console.log(`Updated Trigger: ${JSON.stringify(updatedJobTrigger)}`); |
| 64 | } |
| 65 | updateTrigger(projectId, jobTriggerName); |
| 66 | // [END dlp_update_trigger] |
| 67 | } |
| 68 | |
| 69 | process.on('unhandledRejection', err => { |
| 70 | console.error(err.message); |
no test coverage detected