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

Function main

dlp/kAnonymityWithEntityIds.js:21–141  ·  view source on GitHub ↗
(projectId, datasetId, sourceTableId, outputTableId)

Source from the content-addressed store, hash-verified

19// description: Uses the Data Loss Prevention API to visualize the k-anonymity re-identification risk analysis metric.
20// usage: node kAnonymityWithEntityIds.js projectId, datasetId, sourceTableId, outputTableId
21async function main(projectId, datasetId, sourceTableId, outputTableId) {
22 // [START dlp_k_anonymity_with_entity_id]
23 // Imports the Google Cloud Data Loss Prevention library
24 const DLP = require('@google-cloud/dlp');
25
26 // Instantiates a client
27 const dlp = new DLP.DlpServiceClient();
28
29 // The project ID to run the API call under.
30 // const projectId = "your-project-id";
31
32 // The ID of the dataset to inspect, e.g. 'my_dataset'
33 // const datasetId = 'my_dataset';
34
35 // The ID of the table to inspect, e.g. 'my_table'
36 // const sourceTableId = 'my_source_table';
37
38 // The ID of the table where outputs are stored
39 // const outputTableId = 'my_output_table';
40
41 async function kAnonymityWithEntityIds() {
42 // Specify the BigQuery table to analyze.
43 const sourceTable = {
44 projectId: projectId,
45 datasetId: datasetId,
46 tableId: sourceTableId,
47 };
48
49 // Specify the unique identifier in the source table for the k-anonymity analysis.
50 const uniqueIdField = {name: 'Name'};
51
52 // These values represent the column names of quasi-identifiers to analyze
53 const quasiIds = [{name: 'Age'}, {name: 'Mystery'}];
54
55 // Configure the privacy metric to compute for re-identification risk analysis.
56 const privacyMetric = {
57 kAnonymityConfig: {
58 entityId: {
59 field: uniqueIdField,
60 },
61 quasiIds: quasiIds,
62 },
63 };
64 // Create action to publish job status notifications to BigQuery table.
65 const action = [
66 {
67 saveFindings: {
68 outputConfig: {
69 table: {
70 projectId: projectId,
71 datasetId: datasetId,
72 tableId: outputTableId,
73 },
74 },
75 },
76 },
77 ];
78

Callers

nothing calls this directly

Calls 1

kAnonymityWithEntityIdsFunction · 0.85

Tested by

no test coverage detected