(projectId, datastoreNamespace, datastoreKind)
| 19 | // description: Uses the Data Loss Prevention API to Create a Dlp Job with Datastore Data and send its findings to Scc |
| 20 | // usage: node inspectDatastoreSendToScc.js my-project datastoreNamespace, datastoreKind |
| 21 | async function main(projectId, datastoreNamespace, datastoreKind) { |
| 22 | // [START dlp_inspect_datastore_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 dlp = new DLP.DlpServiceClient(); |
| 28 | |
| 29 | // The project ID to run the API call under. |
| 30 | // const projectId = "your-project-id"; |
| 31 | |
| 32 | // Datastore namespace |
| 33 | // const datastoreNamespace = 'datastore-namespace'; |
| 34 | |
| 35 | // Datastore kind |
| 36 | // const datastoreKind = 'datastore-kind'; |
| 37 | |
| 38 | async function inspectDatastoreSendToScc() { |
| 39 | // Specify the storage configuration object with datastore. |
| 40 | const storageConfig = { |
| 41 | datastoreOptions: { |
| 42 | kind: { |
| 43 | name: datastoreKind, |
| 44 | }, |
| 45 | partitionId: { |
| 46 | projectId: projectId, |
| 47 | namespaceId: datastoreNamespace, |
| 48 | }, |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | // Construct the info types to look for in the datastore. |
| 53 | const infoTypes = [ |
| 54 | {name: 'EMAIL_ADDRESS'}, |
| 55 | {name: 'PERSON_NAME'}, |
| 56 | {name: 'LOCATION'}, |
| 57 | {name: 'PHONE_NUMBER'}, |
| 58 | ]; |
| 59 | |
| 60 | // Construct the inspection configuration. |
| 61 | const inspectConfig = { |
| 62 | infoTypes: infoTypes, |
| 63 | minLikelihood: DLP.protos.google.privacy.dlp.v2.Likelihood.UNLIKELY, |
| 64 | limits: { |
| 65 | maxFindingsPerItem: 100, |
| 66 | }, |
| 67 | includeQuote: true, |
| 68 | }; |
| 69 | |
| 70 | // Specify the action that is triggered when the job completes |
| 71 | const action = { |
| 72 | publishSummaryToCscc: {enable: true}, |
| 73 | }; |
| 74 | |
| 75 | // Configure the inspection job we want the service to perform. |
| 76 | const inspectJobConfig = { |
| 77 | inspectConfig: inspectConfig, |
| 78 | storageConfig: storageConfig, |
nothing calls this directly
no test coverage detected