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

Function main

dlp/deIdentifyWithRedaction.js:23–86  ·  view source on GitHub ↗
(projectId, string, infoTypes)

Source from the content-addressed store, hash-verified

21// usage: node deIdentifyWithRedaction.js my-project string infoTypes
22
23function main(projectId, string, infoTypes) {
24 infoTypes = transformCLI(infoTypes);
25 // [START dlp_deidentify_redact]
26 // Imports the Google Cloud Data Loss Prevention library
27 const DLP = require('@google-cloud/dlp');
28
29 // Instantiates a client
30 const dlp = new DLP.DlpServiceClient();
31
32 // TODO(developer): Replace these variables before running the sample.
33 // const projectId = "your-project-id";
34
35 // The string to deidentify
36 // const string =
37 // 'My name is Alicia Abernathy, and my email address is aabernathy@example.com.';
38
39 // The infoTypes of information to match
40 // See https://cloud.google.com/dlp/docs/concepts-infotypes for more information
41 // about supported infoTypes.
42 // const infoTypes = [{name: 'EMAIL_ADDRESS'}];
43
44 async function deIdentifyRedaction() {
45 // Construct deidentify configuration
46 const deidentifyConfig = {
47 infoTypeTransformations: {
48 transformations: [
49 {
50 infoTypes: infoTypes,
51 primitiveTransformation: {
52 redactConfig: {},
53 },
54 },
55 ],
56 },
57 };
58
59 // Construct inspect configuration
60 const inspectConfig = {
61 infoTypes: infoTypes,
62 };
63
64 // Construct Item
65 const item = {
66 value: string,
67 };
68
69 // Combine configurations into a request for the service.
70 const request = {
71 parent: `projects/${projectId}/locations/global`,
72 item,
73 deidentifyConfig,
74 inspectConfig,
75 };
76
77 // Send the request and receive response from the service
78 const [response] = await dlp.deidentifyContent(request);
79
80 // Print the results

Callers 1

Calls 2

deIdentifyRedactionFunction · 0.85
transformCLIFunction · 0.70

Tested by

no test coverage detected