From 6c2ba498cbc93290bcdb09774a1d8da4be87a81b Mon Sep 17 00:00:00 2001 From: dinesh-crest Date: Thu, 10 Aug 2023 15:42:50 +0530 Subject: [PATCH] Improved comments as per PR suggestions --- dlp/deIdentifyCloudStorage.js | 4 ++-- dlp/kAnonymityWithEntityIds.js | 29 +++++++++++++---------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/dlp/deIdentifyCloudStorage.js b/dlp/deIdentifyCloudStorage.js index cb600da2a3..a876ce18c8 100644 --- a/dlp/deIdentifyCloudStorage.js +++ b/dlp/deIdentifyCloudStorage.js @@ -118,12 +118,12 @@ async function main( }; // Construct the job creation request to be sent by the client. - const request = { + const createDlpJobRequest = { parent: `projects/${projectId}/locations/global`, inspectJob: inspectJobConfig, }; // Send the job creation request and process the response. - const [response] = await dlp.createDlpJob(request); + const [response] = await dlp.createDlpJob(createDlpJobRequest); const jobName = response.name; // Waiting for a maximum of 15 minutes for the job to get complete. diff --git a/dlp/kAnonymityWithEntityIds.js b/dlp/kAnonymityWithEntityIds.js index e51584c3de..bb5abd3af7 100644 --- a/dlp/kAnonymityWithEntityIds.js +++ b/dlp/kAnonymityWithEntityIds.js @@ -46,22 +46,19 @@ async function main(projectId, datasetId, sourceTableId, outputTableId) { tableId: sourceTableId, }; - // Specify quasi-identifiers to analyze + // Specify the unique identifier in the source table for the k-anonymity analysis. + const uniqueIdField = {name: 'Name'}; + + // These values represent the column names of quasi-identifiers to analyze + const quasiIds = [{name: 'Age'}, {name: 'Mystery'}]; + + // Configure the privacy metric to compute for re-identification risk analysis. const privacyMetric = { kAnonymityConfig: { entityId: { - field: { - name: 'Name', - }, + field: uniqueIdField, }, - quasiIds: [ - { - name: 'Age', - }, - { - name: 'Mystery', - }, - ], + quasiIds: quasiIds, }, }; // Create action to publish job status notifications to BigQuery table. @@ -80,19 +77,19 @@ async function main(projectId, datasetId, sourceTableId, outputTableId) { ]; // Configure the risk analysis job to perform. - const riskJob = { + const riskAnalysisJob = { sourceTable: sourceTable, privacyMetric: privacyMetric, actions: action, }; // Combine configurations into a request for the service. - const request = { + const createDlpJobRequest = { parent: `projects/${projectId}/locations/global`, - riskJob: riskJob, + riskJob: riskAnalysisJob, }; // Send the request and receive response from the service - const [createdDlpJob] = await dlp.createDlpJob(request); + const [createdDlpJob] = await dlp.createDlpJob(createDlpJobRequest); const jobName = createdDlpJob.name; // Waiting for a maximum of 15 minutes for the job to get complete.