( projectId, bucketName, fileName, topicId, subscriptionId, minLikelihood, maxFindings, infoTypes, customInfoTypes )
| 18 | // usage: node inspectGCSFile.js my-project filepath minLikelihood maxFindings infoTypes customInfoTypes includeQuote |
| 19 | |
| 20 | async function main( |
| 21 | projectId, |
| 22 | bucketName, |
| 23 | fileName, |
| 24 | topicId, |
| 25 | subscriptionId, |
| 26 | minLikelihood, |
| 27 | maxFindings, |
| 28 | infoTypes, |
| 29 | customInfoTypes |
| 30 | ) { |
| 31 | [infoTypes, customInfoTypes] = transformCLI(infoTypes, customInfoTypes); |
| 32 | |
| 33 | // [START dlp_inspect_gcs] |
| 34 | // Import the Google Cloud client libraries |
| 35 | const DLP = require('@google-cloud/dlp'); |
| 36 | const {PubSub} = require('@google-cloud/pubsub'); |
| 37 | |
| 38 | // Instantiates clients |
| 39 | const dlp = new DLP.DlpServiceClient(); |
| 40 | const pubsub = new PubSub(); |
| 41 | |
| 42 | // The project ID to run the API call under |
| 43 | // const projectId = 'my-project'; |
| 44 | |
| 45 | // The name of the bucket where the file resides. |
| 46 | // const bucketName = 'YOUR-BUCKET'; |
| 47 | |
| 48 | // The path to the file within the bucket to inspect. |
| 49 | // Can contain wildcards, e.g. "my-image.*" |
| 50 | // const fileName = 'my-image.png'; |
| 51 | |
| 52 | // The minimum likelihood required before returning a match |
| 53 | // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED'; |
| 54 | |
| 55 | // The maximum number of findings to report per request (0 = server maximum) |
| 56 | // const maxFindings = 0; |
| 57 | |
| 58 | // The infoTypes of information to match |
| 59 | // const infoTypes = [{ name: 'PHONE_NUMBER' }, { name: 'EMAIL_ADDRESS' }, { name: 'CREDIT_CARD_NUMBER' }]; |
| 60 | |
| 61 | // The customInfoTypes of information to match |
| 62 | // const customInfoTypes = [{ infoType: { name: 'DICT_TYPE' }, dictionary: { wordList: { words: ['foo', 'bar', 'baz']}}}, |
| 63 | // { infoType: { name: 'REGEX_TYPE' }, regex: {pattern: '\\(\\d{3}\\) \\d{3}-\\d{4}'}}]; |
| 64 | |
| 65 | // The name of the Pub/Sub topic to notify once the job completes |
| 66 | // TODO(developer): create a Pub/Sub topic to use for this |
| 67 | // const topicId = 'MY-PUBSUB-TOPIC' |
| 68 | |
| 69 | // The name of the Pub/Sub subscription to use when listening for job |
| 70 | // completion notifications |
| 71 | // TODO(developer): create a Pub/Sub subscription to use for this |
| 72 | // const subscriptionId = 'MY-PUBSUB-SUBSCRIPTION' |
| 73 | |
| 74 | async function inspectGCSFile() { |
| 75 | // Get reference to the file to be inspected |
| 76 | const storageItem = { |
| 77 | cloudStorageOptions: { |
nothing calls this directly
no test coverage detected