diff --git a/dlp/README.md b/dlp/README.md index 91ae4d9e27..de28fbbb71 100644 --- a/dlp/README.md +++ b/dlp/README.md @@ -1,96 +1,82 @@ Google Cloud Platform logo -# 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 Inspect a string using the Data Loss Prevention API. - file Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API. - gcsFile Inspects a text file stored on Google Cloud Storage using the Data Loss Prevention - API. - datastore Inspect a Datastore instance using the Data Loss Prevention API. + string Inspect a string using the Data Loss Prevention API. + file Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API. + gcsFilePromise Inspects a text file stored on Google Cloud Storage using the Data Loss + Prevention API and the promise pattern. + gcsFileEvent Inspects a text file stored on Google Cloud Storage using the Data Loss + Prevention API and the event-handler pattern. + datastore 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 me@somedomain.com" + node inspect.js string "My phone number is (123) 456-7890 and my email address is me@somedomain.com" 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 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 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/ \ No newline at end of file + yarn test diff --git a/dlp/package.json b/dlp/package.json index 519047d9af..14093b153e 100644 --- a/dlp/package.json +++ b/dlp/package.json @@ -18,6 +18,10 @@ "system-test": "ava -T 1m --verbose system-test/*.test.js", "test": "npm run system-test" }, + "cloud-repo-tools": { + "requiresKeyFile": true, + "requiresProjectId": true + }, "dependencies": { "@google-cloud/dlp": "^0.1.0", "google-auth-library": "0.10.0", @@ -35,6 +39,30 @@ }, "cloud-repo-tools": { "requiresKeyFile": true, - "requiresProjectId": true + "requiresProjectId": true, + "product": "dlp", + "samples": [ + { + "id": "inspect", + "name": "Inspect", + "file": "inspect.js", + "docs_link": "https://cloud.google.com/dlp/docs", + "usage": "node inspect.js --help" + }, + { + "id": "redact", + "name": "Redact", + "file": "redact.js", + "docs_link": "https://cloud.google.com/dlp/docs", + "usage": "node redact.js --help" + }, + { + "id": "metadata", + "name": "Metadata", + "file": "metadata.js", + "docs_link": "https://cloud.google.com/dlp/docs", + "usage": "node metadata.js --help" + } + ] } }