| 19 | // description: Get DLP inspection job using job name. |
| 20 | // usage: node getJob.js jobName |
| 21 | function main(jobName) { |
| 22 | // [START dlp_get_job] |
| 23 | // Imports the Google Cloud Data Loss Prevention library |
| 24 | const DLP = require('@google-cloud/dlp'); |
| 25 | |
| 26 | // Instantiates a client |
| 27 | const dlp = new DLP.DlpServiceClient(); |
| 28 | |
| 29 | // Job name to look for |
| 30 | // const jobName = 'your-job-name'; |
| 31 | |
| 32 | async function getJob() { |
| 33 | // Construct request for finding job using job name. |
| 34 | const request = { |
| 35 | name: jobName, |
| 36 | }; |
| 37 | |
| 38 | // Send the request and receive response from the service |
| 39 | const [job] = await dlp.getDlpJob(request); |
| 40 | |
| 41 | // Print results. |
| 42 | console.log(`Job ${job.name} status: ${job.state}`); |
| 43 | } |
| 44 | |
| 45 | getJob(); |
| 46 | // [END dlp_get_job] |
| 47 | } |
| 48 | |
| 49 | process.on('unhandledRejection', err => { |
| 50 | console.error(err.message); |