(projectId, gcsPath)
| 19 | // description: Uses the Data Loss Prevention API to Create a Dlp Job with GCS Data and send its findings to Scc |
| 20 | // usage: node inspectGcsSendToScc.js my-project gcsPath |
| 21 | async function main(projectId, gcsPath) { |
| 22 | // [START dlp_inspect_gcs_send_to_scc] |
| 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 = 'your-project-id'; |
| 31 | |
| 32 | // The name of the file in the bucket |
| 33 | // const gcsPath = 'gcs-file-path'; |
| 34 | |
| 35 | async function inspectGCSSendToScc() { |
| 36 | // Specify the storage configuration object with GCS URL. |
| 37 | const storageConfig = { |
| 38 | cloudStorageOptions: { |
| 39 | fileSet: { |
| 40 | url: gcsPath, |
| 41 | }, |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | // Construct the info types to look for in the GCS file. |
| 46 | const infoTypes = [ |
| 47 | {name: 'EMAIL_ADDRESS'}, |
| 48 | {name: 'PERSON_NAME'}, |
| 49 | {name: 'LOCATION'}, |
| 50 | {name: 'PHONE_NUMBER'}, |
| 51 | ]; |
| 52 | |
| 53 | // Construct the inspection configuration. |
| 54 | const inspectConfig = { |
| 55 | infoTypes, |
| 56 | minLikelihood: DLP.protos.google.privacy.dlp.v2.Likelihood.UNLIKELY, |
| 57 | limits: { |
| 58 | maxFindingsPerItem: 100, |
| 59 | }, |
| 60 | }; |
| 61 | |
| 62 | // Specify the action that is triggered when the job completes. |
| 63 | const action = { |
| 64 | publishSummaryToCscc: {}, |
| 65 | }; |
| 66 | |
| 67 | // Configure the inspection job we want the service to perform. |
| 68 | const jobConfig = { |
| 69 | inspectConfig, |
| 70 | storageConfig, |
| 71 | actions: [action], |
| 72 | }; |
| 73 | |
| 74 | // Construct the job creation request to be sent by the client. |
| 75 | const request = { |
| 76 | parent: `projects/${projectId}/locations/global`, |
| 77 | inspectJob: jobConfig, |
| 78 | }; |
nothing calls this directly
no test coverage detected