Skip to content

Commit 0f1b30d

Browse files
author
Ace Nassri
authored
* First draft of DLP samples * Fix DLP tests * Add README * Fix README bugs
1 parent 1981d82 commit 0f1b30d

12 files changed

+1077
-0
lines changed

dlp/README.md

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
2+
3+
# Data Loss Prevention API Node.js Samples
4+
5+
The [Data Loss Prevention][dlp_docs] (DLP) API provides programmatic access to a powerful detection engine for personally identifiable information and other privacy-sensitive data in unstructured data streams.
6+
7+
This code provides a demonstration of the DLP API's functionality via REST in Node.js. It is intended for developers who want to be early adopters of the API.
8+
9+
[gRPC](https://grpc.io)-based samples/client libraries for [several languages](https://cloud.google.com/docs/) are under active development, and will be released shortly.
10+
11+
## Table of Contents
12+
13+
* [Setup](#setup)
14+
* [Samples](#samples)
15+
* [Getting started with the Data Loss Prevention API](#getting-started-with-data-loss-prevention-api)
16+
17+
## Setup
18+
19+
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
20+
1. Install dependencies:
21+
22+
npm install
23+
24+
[prereq]: ../README.md#prerequisities
25+
[run]: ../README.md#how-to-run-a-sample
26+
27+
## Samples
28+
29+
### Getting started with the Data Loss Prevention API
30+
31+
View the [DLP documentation][dlp_docs] or the [samples][dlp_samples].
32+
33+
__Run the samples:__
34+
35+
```sh
36+
node inspect.js --help
37+
```
38+
39+
```
40+
Commands:
41+
Commands:
42+
string <string> Inspect a string using the Data Loss Prevention API.
43+
file <filepath> Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API.
44+
gcsFile <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data Loss Prevention
45+
API.
46+
datastore <kind> Inspect a Datastore instance using the Data Loss Prevention API.
47+
48+
Options:
49+
--help Show help [boolean]
50+
-m, --minLikelihood
51+
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"]
52+
[default: "LIKELIHOOD_UNSPECIFIED"]
53+
-f, --maxFindings [default: 0]
54+
-q, --includeQuote [boolean] [default: true]
55+
-a, --authToken [string] [default:
56+
"ab97.XXX..."]
57+
-t, --infoTypes [array] [default: []]
58+
59+
Examples:
60+
node inspect.js string "My phone number is (123) 456-7890
61+
and my email address is [email protected]"
62+
node inspect.js file resources/test.txt
63+
node inspect.js gcsFile my-bucket my-file.txt
64+
65+
For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at
66+
https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#InspectConfig
67+
```
68+
69+
```sh
70+
node metadata.js --help
71+
```
72+
73+
```
74+
Commands:
75+
infoTypes <category> List types of sensitive information within a category.
76+
categories List root categories of sensitive information.
77+
78+
Options:
79+
--help Show help [boolean]
80+
-a, --authToken [string] [default:
81+
"ab97.XXX..."]
82+
oz0146E86Lk"]
83+
84+
Examples:
85+
node metadata.js infoTypes GOVERNMENT
86+
node metadata.js categories
87+
88+
For more information, see https://cloud.google.com/dlp/docs
89+
```
90+
91+
```sh
92+
node redact.js --help
93+
```
94+
95+
```
96+
Commands:
97+
string <string> <replaceString> Redact sensitive data from a string using the Data Loss Prevention API.
98+
99+
Options:
100+
--help Show help [boolean]
101+
-t, --infoTypes [array] [required]
102+
-m, --minLikelihood
103+
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"]
104+
[default: "LIKELIHOOD_UNSPECIFIED"]
105+
-a, --authToken [string] [default:
106+
"ab97.XXX..."]
107+
htPfG_eIy04"]
108+
109+
Examples:
110+
node redact.js string "My name is Gary" "REDACTED" -t
111+
US_MALE_NAME
112+
113+
For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at
114+
https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#InspectConfig
115+
```
116+
117+
For more information, see [the docs][dlp_docs].
118+
119+
[dlp_samples]: ../dlp
120+
[dlp_docs]: https://cloud.google.com/dlp/docs/

0 commit comments

Comments
 (0)