MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

dlp/deIdentifyTableConditionMasking.js:21–118  ·  view source on GitHub ↗
(projectId)

Source from the content-addressed store, hash-verified

19// description: Transform findings when specific conditions are met in a table with character masking.
20// usage: node deIdentifyTableConditionMasking.js my-project
21function main(projectId) {
22 // [START dlp_deidentify_table_condition_masking]
23 // Imports the Google Cloud Data Loss Prevention library
24 const DLP = require('@google-cloud/dlp');
25
26 // Initialize google DLP Client
27 const dlp = new DLP.DlpServiceClient();
28
29 // The project ID to run the API call under
30 // const projectId = 'my-project';
31
32 // Construct the tabular data
33 const tablularData = {
34 headers: [{name: 'AGE'}, {name: 'PATIENT'}, {name: 'HAPPINESS SCORE'}],
35 rows: [
36 {
37 values: [
38 {integerValue: 101},
39 {stringValue: 'Charles Dickens'},
40 {integerValue: 95},
41 ],
42 },
43 {
44 values: [
45 {integerValue: 22},
46 {stringValue: 'Jane Austen'},
47 {integerValue: 21},
48 ],
49 },
50 {
51 values: [
52 {integerValue: 55},
53 {stringValue: 'Mark Twain'},
54 {integerValue: 75},
55 ],
56 },
57 ],
58 };
59
60 async function deIdentifyTableConditionalCharMasking() {
61 // Column that needs to be transformed
62 const fieldIds = [{name: 'HAPPINESS SCORE'}];
63
64 // Construct PrimitiveTransformation configuration
65 const primitiveTransformation = {
66 characterMaskConfig: {
67 maskingCharacter: '*',
68 },
69 };
70
71 // Construct condition
72 const condition = {
73 expressions: {
74 conditions: {
75 conditions: [
76 {
77 field: {name: 'AGE'},
78 operator: 'GREATER_THAN',

Tested by

no test coverage detected