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

Function main

dlp/categoricalRiskAnalysis.js:22–155  ·  view source on GitHub ↗
(
  projectId,
  tableProjectId,
  datasetId,
  tableId,
  columnName,
  topicId,
  subscriptionId
)

Source from the content-addressed store, hash-verified

20// usage: node categoricalRiskAnalysis.js my-project nhtsa_traffic_fatalities accident_2015 state_name my-topic my-subscription bigquery-public-data
21
22async function main(
23 projectId,
24 tableProjectId,
25 datasetId,
26 tableId,
27 columnName,
28 topicId,
29 subscriptionId
30) {
31 // [START dlp_categorical_stats]
32 // Import the Google Cloud client libraries
33 const DLP = require('@google-cloud/dlp');
34 const {PubSub} = require('@google-cloud/pubsub');
35
36 // Instantiates clients
37 const dlp = new DLP.DlpServiceClient();
38 const pubsub = new PubSub();
39
40 // The project ID to run the API call under
41 // const projectId = 'my-project';
42
43 // The project ID the table is stored under
44 // This may or (for public datasets) may not equal the calling project ID
45 // const tableProjectId = 'my-project';
46
47 // The ID of the dataset to inspect, e.g. 'my_dataset'
48 // const datasetId = 'my_dataset';
49
50 // The ID of the table to inspect, e.g. 'my_table'
51 // const tableId = 'my_table';
52
53 // The name of the Pub/Sub topic to notify once the job completes
54 // TODO(developer): create a Pub/Sub topic to use for this
55 // const topicId = 'MY-PUBSUB-TOPIC'
56
57 // The name of the Pub/Sub subscription to use when listening for job
58 // completion notifications
59 // TODO(developer): create a Pub/Sub subscription to use for this
60 // const subscriptionId = 'MY-PUBSUB-SUBSCRIPTION'
61
62 // The name of the column to compute risk metrics for, e.g. 'firstName'
63 // const columnName = 'firstName';
64 async function categoricalRiskAnalysis() {
65 const sourceTable = {
66 projectId: tableProjectId,
67 datasetId: datasetId,
68 tableId: tableId,
69 };
70
71 // Construct request for creating a risk analysis job
72 const request = {
73 parent: `projects/${projectId}/locations/global`,
74 riskJob: {
75 privacyMetric: {
76 categoricalStatsConfig: {
77 field: {
78 name: columnName,
79 },

Callers

nothing calls this directly

Calls 1

categoricalRiskAnalysisFunction · 0.85

Tested by

no test coverage detected