( projectId, dataProjectId, datasetId, tableId, topicId, subscriptionId )
| 17 | // description: Inspects a BigQuery table using the Data Loss Prevention API to scan a 1000-row subset of a BigQuery table. |
| 18 | // usage: node inspectBigQueryTableWithSampling.js my-project dataProjectId datasetId tableId topicId subscriptionId |
| 19 | async function main( |
| 20 | projectId, |
| 21 | dataProjectId, |
| 22 | datasetId, |
| 23 | tableId, |
| 24 | topicId, |
| 25 | subscriptionId |
| 26 | ) { |
| 27 | // [START dlp_inspect_bigquery_with_sampling] |
| 28 | // Import the Google Cloud client libraries |
| 29 | const DLP = require('@google-cloud/dlp'); |
| 30 | const {PubSub} = require('@google-cloud/pubsub'); |
| 31 | |
| 32 | // Instantiates clients |
| 33 | const dlp = new DLP.DlpServiceClient(); |
| 34 | const pubsub = new PubSub(); |
| 35 | |
| 36 | // The project ID to run the API call under |
| 37 | // const projectId = 'my-project'; |
| 38 | |
| 39 | // The project ID the table is stored under |
| 40 | // This may or (for public datasets) may not equal the calling project ID |
| 41 | // const dataProjectId = 'my-project'; |
| 42 | |
| 43 | // The ID of the dataset to inspect, e.g. 'my_dataset' |
| 44 | // const datasetId = 'my_dataset'; |
| 45 | |
| 46 | // The ID of the table to inspect, e.g. 'my_table' |
| 47 | // const tableId = 'my_table'; |
| 48 | |
| 49 | // The name of the Pub/Sub topic to notify once the job completes |
| 50 | // TODO(developer): create a Pub/Sub topic to use for this |
| 51 | // const topicId = 'MY-PUBSUB-TOPIC' |
| 52 | |
| 53 | // The name of the Pub/Sub subscription to use when listening for job |
| 54 | // completion notifications |
| 55 | // TODO(developer): create a Pub/Sub subscription to use for this |
| 56 | // const subscriptionId = 'MY-PUBSUB-SUBSCRIPTION' |
| 57 | |
| 58 | // DLP Job max time (in milliseconds) |
| 59 | const DLP_JOB_WAIT_TIME = 15 * 1000 * 60; |
| 60 | |
| 61 | async function inspectBigqueryWithSampling() { |
| 62 | // Specify the type of info the inspection will look for. |
| 63 | // See https://cloud.google.com/dlp/docs/infotypes-reference for complete list of info types |
| 64 | const infoTypes = [{name: 'PERSON_NAME'}]; |
| 65 | |
| 66 | // Specify the BigQuery options required for inspection. |
| 67 | const storageItem = { |
| 68 | bigQueryOptions: { |
| 69 | tableReference: { |
| 70 | projectId: dataProjectId, |
| 71 | datasetId: datasetId, |
| 72 | tableId: tableId, |
| 73 | }, |
| 74 | rowsLimit: 1000, |
| 75 | sampleMethod: |
| 76 | DLP.protos.google.privacy.dlp.v2.BigQueryOptions.SampleMethod |
nothing calls this directly
no test coverage detected