-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ace Nassri
authored
Jun 30, 2017
1 parent
5b6f53c
commit b984fae
Showing
2 changed files
with
106 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,82 @@ | ||
<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"/> | ||
|
||
# Data Loss Prevention API Node.js Samples | ||
# Google Cloud Data Loss Prevention (DLP) API Node.js Samples | ||
|
||
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. | ||
[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/dlp-cli.svg)]() | ||
|
||
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. | ||
|
||
[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. | ||
The [Data Loss Prevention API](https://cloud.google.com/dlp/docs/) provides programmatic access to a powerful detection engine for personally identifiable information and other privacy-sensitive data in unstructured data streams. | ||
|
||
## Table of Contents | ||
|
||
* [Setup](#setup) | ||
* [Samples](#samples) | ||
* [Getting started with the Data Loss Prevention API](#getting-started-with-data-loss-prevention-api) | ||
* [Inspect](#inspect) | ||
* [Redact](#redact) | ||
* [Metadata](#metadata) | ||
* [Running the tests](#running-the-tests) | ||
|
||
## Setup | ||
|
||
1. Read [Prerequisites][prereq] and [How to run a sample][run] first. | ||
1. Install dependencies: | ||
1. Read [Prerequisites][prereq] and [How to run a sample][run] first. | ||
1. Install dependencies: | ||
|
||
With **npm**: | ||
|
||
npm install | ||
|
||
[prereq]: ../README.md#prerequisities | ||
With **yarn**: | ||
|
||
yarn install | ||
|
||
[prereq]: ../README.md#prerequisites | ||
[run]: ../README.md#how-to-run-a-sample | ||
|
||
## Samples | ||
|
||
### Getting started with the Data Loss Prevention API | ||
|
||
View the [DLP documentation][dlp_docs] or the [samples][dlp_samples]. | ||
### Inspect | ||
|
||
__Run the samples:__ | ||
View the [documentation][inspect_0_docs] or the [source code][inspect_0_code]. | ||
|
||
```sh | ||
node inspect.js --help | ||
``` | ||
__Usage:__ `node inspect.js --help` | ||
|
||
``` | ||
Commands: | ||
Commands: | ||
string <string> Inspect a string using the Data Loss Prevention API. | ||
file <filepath> Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API. | ||
gcsFile <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data Loss Prevention | ||
API. | ||
datastore <kind> Inspect a Datastore instance using the Data Loss Prevention API. | ||
string <string> Inspect a string using the Data Loss Prevention API. | ||
file <filepath> Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API. | ||
gcsFilePromise <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data Loss | ||
Prevention API and the promise pattern. | ||
gcsFileEvent <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data Loss | ||
Prevention API and the event-handler pattern. | ||
datastore <kind> Inspect a Datastore instance using the Data Loss Prevention API. | ||
Options: | ||
--help Show help [boolean] | ||
-m, --minLikelihood | ||
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"] | ||
[default: "LIKELIHOOD_UNSPECIFIED"] | ||
-f, --maxFindings [default: 0] | ||
-f, --maxFindings [number] [default: 0] | ||
-q, --includeQuote [boolean] [default: true] | ||
-a, --authToken [string] [default: | ||
"ab97.XXX..."] | ||
-l, --languageCode [string] [default: "en-US"] | ||
-t, --infoTypes [array] [default: []] | ||
Examples: | ||
node inspect.js string "My phone number is (123) 456-7890 | ||
and my email address is [email protected]" | ||
node inspect.js string "My phone number is (123) 456-7890 and my email address is [email protected]" | ||
node inspect.js file resources/test.txt | ||
node inspect.js gcsFile my-bucket my-file.txt | ||
node inspect.js gcsFilePromise my-bucket my-file.txt | ||
node inspect.js gcsFileEvent my-bucket my-file.txt | ||
For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at | ||
https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#InspectConfig | ||
``` | ||
|
||
```sh | ||
node metadata.js --help | ||
``` | ||
|
||
``` | ||
Commands: | ||
infoTypes <category> List types of sensitive information within a category. | ||
categories List root categories of sensitive information. | ||
Options: | ||
--help Show help [boolean] | ||
-a, --authToken [string] [default: | ||
"ab97.XXX..."] | ||
oz0146E86Lk"] | ||
[inspect_0_docs]: https://cloud.google.com/dlp/docs | ||
[inspect_0_code]: inspect.js | ||
|
||
Examples: | ||
node metadata.js infoTypes GOVERNMENT | ||
node metadata.js categories | ||
### Redact | ||
|
||
For more information, see https://cloud.google.com/dlp/docs | ||
``` | ||
View the [documentation][redact_1_docs] or the [source code][redact_1_code]. | ||
|
||
```sh | ||
node redact.js --help | ||
``` | ||
__Usage:__ `node redact.js --help` | ||
|
||
``` | ||
Commands: | ||
|
@@ -102,19 +88,52 @@ Options: | |
-m, --minLikelihood | ||
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"] | ||
[default: "LIKELIHOOD_UNSPECIFIED"] | ||
-a, --authToken [string] [default: | ||
"ab97.XXX..."] | ||
htPfG_eIy04"] | ||
Examples: | ||
node redact.js string "My name is Gary" "REDACTED" -t | ||
US_MALE_NAME | ||
node redact.js string "My name is Gary" "REDACTED" -t US_MALE_NAME | ||
For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at | ||
https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#InspectConfig | ||
``` | ||
|
||
For more information, see [the docs][dlp_docs]. | ||
[redact_1_docs]: https://cloud.google.com/dlp/docs | ||
[redact_1_code]: redact.js | ||
|
||
### Metadata | ||
|
||
View the [documentation][metadata_2_docs] or the [source code][metadata_2_code]. | ||
|
||
__Usage:__ `node metadata.js --help` | ||
|
||
``` | ||
Commands: | ||
infoTypes <category> List types of sensitive information within a category. | ||
categories List root categories of sensitive information. | ||
Options: | ||
--help Show help [boolean] | ||
-l, --languageCode [string] [default: "en-US"] | ||
Examples: | ||
node metadata.js infoTypes GOVERNMENT | ||
node metadata.js categories | ||
For more information, see https://cloud.google.com/dlp/docs | ||
``` | ||
|
||
[metadata_2_docs]: https://cloud.google.com/dlp/docs | ||
[metadata_2_code]: metadata.js | ||
|
||
## Running the tests | ||
|
||
1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. | ||
|
||
1. Run the tests: | ||
|
||
With **npm**: | ||
|
||
npm test | ||
|
||
With **yarn**: | ||
|
||
[dlp_samples]: ../dlp | ||
[dlp_docs]: https://cloud.google.com/dlp/docs/ | ||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters