(projectId)
| 19 | // description: Uses the Data Loss Prevention API to De-identifying the table using bucketing transformations. |
| 20 | // usage: node deIdentifyTableWithBucketingConfig.js my-project |
| 21 | function main(projectId) { |
| 22 | // [START dlp_deidentify_table_primitive_bucketing] |
| 23 | // Imports the Google Cloud client library |
| 24 | const DLP = require('@google-cloud/dlp'); |
| 25 | // Instantiates a client |
| 26 | const dlp = new DLP.DlpServiceClient(); |
| 27 | |
| 28 | // The project ID to run the API call under |
| 29 | // const projectId = 'your-project-id'; |
| 30 | |
| 31 | // Construct the tabular data |
| 32 | const tablularData = { |
| 33 | headers: [{name: 'AGE'}, {name: 'PATIENT'}, {name: 'HAPPINESS SCORE'}], |
| 34 | rows: [ |
| 35 | { |
| 36 | values: [ |
| 37 | {stringValue: '101'}, |
| 38 | {stringValue: 'Charles Dickens'}, |
| 39 | {integerValue: 95}, |
| 40 | ], |
| 41 | }, |
| 42 | { |
| 43 | values: [ |
| 44 | {stringValue: '22'}, |
| 45 | {stringValue: 'Jane Austen'}, |
| 46 | {integerValue: 21}, |
| 47 | ], |
| 48 | }, |
| 49 | { |
| 50 | values: [ |
| 51 | {stringValue: '55'}, |
| 52 | {stringValue: 'Mark Twain'}, |
| 53 | {integerValue: 75}, |
| 54 | ], |
| 55 | }, |
| 56 | ], |
| 57 | }; |
| 58 | |
| 59 | async function deIdentifyTableBucketing() { |
| 60 | // Construct bucket confiugrations |
| 61 | const buckets = [ |
| 62 | { |
| 63 | min: {integerValue: 0}, |
| 64 | max: {integerValue: 25}, |
| 65 | replacementValue: {stringValue: 'Low'}, |
| 66 | }, |
| 67 | { |
| 68 | min: {integerValue: 25}, |
| 69 | max: {integerValue: 75}, |
| 70 | replacementValue: {stringValue: 'Medium'}, |
| 71 | }, |
| 72 | { |
| 73 | min: {integerValue: 75}, |
| 74 | max: {integerValue: 100}, |
| 75 | replacementValue: {stringValue: 'High'}, |
| 76 | }, |
| 77 | ]; |
| 78 |
no test coverage detected