( projectId, triggerId, displayName, description, bucketName, autoPopulateTimespan, scanPeriod, infoTypes, minLikelihood, maxFindings )
| 20 | // usage: node createTrigger.js my-project triggerId displayName description bucketName autoPopulateTimespan scanPeriod infoTypes minLikelihood maxFindings |
| 21 | |
| 22 | function main( |
| 23 | projectId, |
| 24 | triggerId, |
| 25 | displayName, |
| 26 | description, |
| 27 | bucketName, |
| 28 | autoPopulateTimespan, |
| 29 | scanPeriod, |
| 30 | infoTypes, |
| 31 | minLikelihood, |
| 32 | maxFindings |
| 33 | ) { |
| 34 | infoTypes = transformCLI(infoTypes); |
| 35 | // [START dlp_create_trigger] |
| 36 | // Imports the Google Cloud Data Loss Prevention library |
| 37 | const DLP = require('@google-cloud/dlp'); |
| 38 | |
| 39 | // Instantiates a client |
| 40 | const dlp = new DLP.DlpServiceClient(); |
| 41 | |
| 42 | // The project ID to run the API call under |
| 43 | // const projectId = 'my-project'; |
| 44 | |
| 45 | // (Optional) The name of the trigger to be created. |
| 46 | // const triggerId = 'my-trigger'; |
| 47 | |
| 48 | // (Optional) A display name for the trigger to be created |
| 49 | // const displayName = 'My Trigger'; |
| 50 | |
| 51 | // (Optional) A description for the trigger to be created |
| 52 | // const description = "This is a sample trigger."; |
| 53 | |
| 54 | // The name of the bucket to scan. |
| 55 | // const bucketName = 'YOUR-BUCKET'; |
| 56 | |
| 57 | // Limit scan to new content only. |
| 58 | // const autoPopulateTimespan = true; |
| 59 | |
| 60 | // How often to wait between scans, in days (minimum = 1 day) |
| 61 | // const scanPeriod = 1; |
| 62 | |
| 63 | // The infoTypes of information to match |
| 64 | // const infoTypes = [{ name: 'PHONE_NUMBER' }, { name: 'EMAIL_ADDRESS' }, { name: 'CREDIT_CARD_NUMBER' }]; |
| 65 | |
| 66 | // The minimum likelihood required before returning a match |
| 67 | // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED'; |
| 68 | |
| 69 | // The maximum number of findings to report per request (0 = server maximum) |
| 70 | // const maxFindings = 0; |
| 71 | |
| 72 | async function createTrigger() { |
| 73 | // Get reference to the bucket to be inspected |
| 74 | const storageItem = { |
| 75 | cloudStorageOptions: { |
| 76 | fileSet: {url: `gs://${bucketName}/*`}, |
| 77 | }, |
| 78 | timeSpanConfig: { |
| 79 | enableAutoPopulationOfTimespanConfig: autoPopulateTimespan, |
no test coverage detected