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

Function main

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

Source from the content-addressed store, hash-verified

20// usage: node numericalRiskAnalysis.js my-project tableProjectId datasetId tableId columnName topicId subscriptionId
21
22async function main(
23 projectId,
24 tableProjectId,
25 datasetId,
26 tableId,
27 columnName,
28 topicId,
29 subscriptionId
30) {
31 // [START dlp_numerical_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 column to compute risk metrics for, e.g. 'age'
54 // Note that this column must be a numeric data type
55 // const columnName = 'firstName';
56
57 // The name of the Pub/Sub topic to notify once the job completes
58 // TODO(developer): create a Pub/Sub topic to use for this
59 // const topicId = 'MY-PUBSUB-TOPIC'
60
61 // The name of the Pub/Sub subscription to use when listening for job
62 // completion notifications
63 // TODO(developer): create a Pub/Sub subscription to use for this
64 // const subscriptionId = 'MY-PUBSUB-SUBSCRIPTION'
65
66 async function numericalRiskAnalysis() {
67 const sourceTable = {
68 projectId: tableProjectId,
69 datasetId: datasetId,
70 tableId: tableId,
71 };
72
73 // Construct request for creating a risk analysis job
74 const request = {
75 parent: `projects/${projectId}/locations/global`,
76 riskJob: {
77 privacyMetric: {
78 numericalStatsConfig: {
79 field: {

Callers

nothing calls this directly

Calls 1

numericalRiskAnalysisFunction · 0.85

Tested by

no test coverage detected