( projectId, inputDirectory, tableId, datasetId, outputDirectory, deidentifyTemplateId, structuredDeidentifyTemplateId, imageRedactTemplateId )
| 19 | // description: Uses the Data Loss Prevention API To de-identify sensitive data in a Cloud Storage directory. |
| 20 | // usage: node deIdentifyCloudStorage.js projectId, inputDirectory, tableId, datasetId, outputDirectory, deidentifyTemplateId, structuredDeidentifyTemplateId, imageRedactTemplateId |
| 21 | async function main( |
| 22 | projectId, |
| 23 | inputDirectory, |
| 24 | tableId, |
| 25 | datasetId, |
| 26 | outputDirectory, |
| 27 | deidentifyTemplateId, |
| 28 | structuredDeidentifyTemplateId, |
| 29 | imageRedactTemplateId |
| 30 | ) { |
| 31 | // [START dlp_deidentify_cloud_storage] |
| 32 | // Imports the Google Cloud client library |
| 33 | const DLP = require('@google-cloud/dlp'); |
| 34 | // Instantiates a client |
| 35 | const dlp = new DLP.DlpServiceClient(); |
| 36 | |
| 37 | // The project ID to run the API call under |
| 38 | // const projectId = 'my-project'; |
| 39 | |
| 40 | // The Cloud Storage directory that needs to be inspected |
| 41 | // const inputDirectory = 'your-google-cloud-storage-path'; |
| 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 Cloud Storage directory that will be used to store the de-identified files |
| 50 | // const outputDirectory = 'your-output-directory'; |
| 51 | |
| 52 | // The full resource name of the default de-identify template |
| 53 | // const deidentifyTemplateId = 'your-deidentify-template-id'; |
| 54 | |
| 55 | // The full resource name of the de-identify template for structured files |
| 56 | // const structuredDeidentifyTemplateId = 'your-structured-deidentify-template-id'; |
| 57 | |
| 58 | // The full resource name of the image redaction template for images |
| 59 | // const imageRedactTemplateId = 'your-image-redact-template-id'; |
| 60 | |
| 61 | async function deidentifyCloudStorage() { |
| 62 | // Specify storage configuration that uses file set. |
| 63 | const storageConfig = { |
| 64 | cloudStorageOptions: { |
| 65 | fileSet: { |
| 66 | url: inputDirectory, |
| 67 | }, |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | // Specify the type of info the inspection will look for. |
| 72 | const infoTypes = [{name: 'PERSON_NAME'}, {name: 'EMAIL_ADDRESS'}]; |
| 73 | |
| 74 | // Construct inspect configuration |
| 75 | const inspectConfig = { |
| 76 | infoTypes: infoTypes, |
| 77 | includeQuote: true, |
| 78 | }; |
nothing calls this directly
no test coverage detected