Skip to content

Commit

Permalink
Fix docs and regenerate scaffolding. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored and lukesneeringer committed Oct 30, 2017
1 parent 852188c commit 7940741
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 63 deletions.
45 changes: 23 additions & 22 deletions packages/google-privacy-dlp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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"/>

# Google Cloud Data Loss Prevention (DLP) API: Node.js Client
# [Google Cloud Data Loss Prevention (DLP) API: Node.js Client](https://github.com/googleapis/nodejs-dlp)

[![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style&#x3D;flat)](https://cloud.google.com/terms/launch-stages)
[![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-dlp.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-dlp)
Expand All @@ -11,7 +11,9 @@
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.


* [Data Loss Prevention (DLP) API Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-dlp](https://github.com/googleapis/nodejs-dlp)
* [Data Loss Prevention (DLP) API Documentation][product-docs]

Read more about the client libraries for Cloud APIs, including the older
Expand Down Expand Up @@ -77,35 +79,33 @@ const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';
const maxFindings = 0;

// The infoTypes of information to match
const infoTypes = [
{ name: 'US_MALE_NAME' },
{ name: 'US_FEMALE_NAME' }
];
const infoTypes = [{name: 'US_MALE_NAME'}, {name: 'US_FEMALE_NAME'}];

// Whether to include the matching string
const includeQuote = true;

// Construct items to inspect
const items = [{ type: 'text/plain', value: string }];
const items = [{type: 'text/plain', value: string}];

// Construct request
const request = {
inspectConfig: {
infoTypes: infoTypes,
minLikelihood: minLikelihood,
maxFindings: maxFindings,
includeQuote: includeQuote
includeQuote: includeQuote,
},
items: items
items: items,
};

// Run request
dlp.inspectContent(request)
.then((response) => {
dlp
.inspectContent(request)
.then(response => {
const findings = response[0].results[0].findings;
if (findings.length > 0) {
console.log(`Findings:`);
findings.forEach((finding) => {
findings.forEach(finding => {
if (includeQuote) {
console.log(`\tQuote: ${finding.quote}`);
}
Expand All @@ -116,23 +116,23 @@ dlp.inspectContent(request)
console.log(`No findings.`);
}
})
.catch((err) => {
.catch(err => {
console.error(`Error in inspectString: ${err.message || err}`);
});
```

## Samples

Samples are in the [`samples/`](https://github.com/googleapis/nodejs-dlp/blob/master/samples) directory. The samples' `README.md`
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-dlp/tree/master/samples) directory. The samples' `README.md`
has instructions for running the samples.

| Sample | Source Code |
| --------------------------- | --------------------------------- |
| Inspect | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/inspect.js) |
| Redact | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/redact.js) |
| Metadata | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/metadata.js) |
| DeID | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/deid.js) |
| Risk Analysis | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/risk.js) |
| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Inspect | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/inspect.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/inspect.js,samples/README.md) |
| Redact | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/redact.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/redact.js,samples/README.md) |
| Metadata | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/metadata.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/metadata.js,samples/README.md) |
| DeID | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/deid.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/deid.js,samples/README.md) |
| Risk Analysis | [source code](https://github.com/googleapis/nodejs-dlp/blob/master/samples/risk.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/risk.js,samples/README.md) |

The [Data Loss Prevention (DLP) API Node.js Client API Reference][client-docs] documentation
also contains samples.
Expand All @@ -152,13 +152,14 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages]

## Contributing

Contributions welcome! See the [Contributing Guide](.github/CONTRIBUTING.md).
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-dlp/blob/master/.github/CONTRIBUTING.md).

## License

Apache Version 2.0

See [LICENSE](LICENSE)
See [LICENSE](https://github.com/googleapis/nodejs-dlp/blob/master/LICENSE)

[client-docs]: https://cloud.google.com/nodejs/docs/reference/dlp/latest/
[product-docs]: https://cloud.google.com/dlp/docs/
[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
2 changes: 1 addition & 1 deletion packages/google-privacy-dlp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"protobufjs": "^6.8.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^2.0.11",
"@google-cloud/nodejs-repo-tools": "^2.1.0",
"async": "^2.5.0",
"codecov": "^3.0.0",
"eslint": "^4.9.0",
Expand Down
74 changes: 49 additions & 25 deletions packages/google-privacy-dlp/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Google Cloud Data Loss Prevention (DLP) API: Node.js Samples

[![Build](https://storage.googleapis.com/.svg)]()
[![Open in Cloud Shell][shell_img]][shell_link]

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.

Expand All @@ -28,28 +28,33 @@ library's README.

View the [source code][inspect_0_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/inspect.js,samples/README.md)

__Usage:__ `node inspect.js --help`

```
inspect.js <command>
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.
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.
bigquery <datasetName> <tableName> Inspects a BigQuery table using the Data Loss Prevention API.
datastore <kind> Inspect a Datastore instance using the Data Loss Prevention API.
inspect.js string <string> Inspect a string using the Data Loss Prevention API.
inspect.js file <filepath> Inspects a local text, PNG, or JPEG file using the Data Loss
Prevention API.
inspect.js gcsFilePromise <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data
Loss Prevention API and the promise pattern.
inspect.js gcsFileEvent <bucketName> <fileName> Inspects a text file stored on Google Cloud Storage using the Data
Loss Prevention API and the event-handler pattern.
inspect.js bigquery <datasetName> <tableName> Inspects a BigQuery table using the Data Loss Prevention API.
inspect.js datastore <kind> Inspect a Datastore instance using the Data Loss Prevention API.
Options:
--version Show version number [boolean]
--help Show help [boolean]
-m, --minLikelihood
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"]
[default: "LIKELIHOOD_UNSPECIFIED"]
-f, --maxFindings [number] [default: 0]
-q, --includeQuote [boolean] [default: true]
-t, --infoTypes [array] [default: ["PHONE_NUMBER","EMAIL_ADDRESS","CREDIT_CARD_NUMBER"]]
--help Show help [boolean]
Examples:
node inspect.js string "My phone number is (123) 456-7890 and my email address is me@somedomain.com"
Expand All @@ -70,20 +75,24 @@ https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#Inspect

View the [source code][redact_1_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/redact.js,samples/README.md)

__Usage:__ `node redact.js --help`

```
redact.js <command>
Commands:
string <string> <replaceString> Redact sensitive data from a string using the Data Loss Prevention API.
image <filepath> <outputPath> Redact sensitive data from an image using the Data Loss Prevention API.
redact.js string <string> <replaceString> Redact sensitive data from a string using the Data Loss Prevention API.
redact.js image <filepath> <outputPath> Redact sensitive data from an image using the Data Loss Prevention API.
Options:
--version Show version number [boolean]
--help Show help [boolean]
-t, --infoTypes [array] [required]
-m, --minLikelihood
[string] [choices: "LIKELIHOOD_UNSPECIFIED", "VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY", "VERY_LIKELY"]
[default: "LIKELIHOOD_UNSPECIFIED"]
-t, --infoTypes [array] [required]
--help Show help [boolean]
Examples:
node redact.js string "My name is Gary" "REDACTED" -t US_MALE_NAME
Expand All @@ -100,17 +109,21 @@ https://cloud.google.com/dlp/docs/reference/rest/v2beta1/content/inspect#Inspect

View the [source code][metadata_2_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/metadata.js,samples/README.md)

__Usage:__ `node metadata.js --help`

```
metadata.js <command>
Commands:
infoTypes <category> List types of sensitive information within a category.
categories List root categories of sensitive information.
metadata.js infoTypes <category> List types of sensitive information within a category.
metadata.js categories List root categories of sensitive information.
Options:
--version Show version number [boolean]
--help Show help [boolean]
-l, --languageCode [string] [default: "en-US"]
--help Show help [boolean]
Examples:
node metadata.js infoTypes GOVERNMENT
Expand All @@ -126,12 +139,16 @@ For more information, see https://cloud.google.com/dlp/docs

View the [source code][deid_3_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/deid.js,samples/README.md)

__Usage:__ `node deid.js --help`

```
deid.js <command>
Commands:
mask <string> Deidentify sensitive data by masking it with a character.
fpe <string> <wrappedKey> <keyName> Deidentify sensitive data using Format Preserving Encryption (FPE).
deid.js mask <string> Deidentify sensitive data by masking it with a character.
deid.js fpe <string> <wrappedKey> <keyName> Deidentify sensitive data using Format Preserving Encryption (FPE).
Options:
--version Show version number [boolean]
Expand All @@ -151,23 +168,27 @@ For more information, see https://cloud.google.com/dlp/docs.

View the [source code][risk_4_code].

[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/risk.js,samples/README.md)

__Usage:__ `node risk.js --help`

```
risk.js <command>
Commands:
numerical <datasetId> <tableId> <columnName> Computes risk metrics of a column of numbers in a Google
BigQuery table.
categorical <datasetId> <tableId> <columnName> Computes risk metrics of a column of data in a Google
risk.js numerical <datasetId> <tableId> <columnName> Computes risk metrics of a column of numbers in a Google
BigQuery table.
kAnonymity <datasetId> <tableId> [quasiIdColumnNames..] Computes the k-anonymity of a column set in a Google
risk.js categorical <datasetId> <tableId> <columnName> Computes risk metrics of a column of data in a Google
BigQuery table.
lDiversity <datasetId> <tableId> <sensitiveAttribute> Computes the l-diversity of a column set in a Google
risk.js kAnonymity <datasetId> <tableId> Computes the k-anonymity of a column set in a Google
[quasiIdColumnNames..] BigQuery table.
risk.js lDiversity <datasetId> <tableId> Computes the l-diversity of a column set in a Google
<sensitiveAttribute> [quasiIdColumnNames..] BigQuery table.
Options:
--version Show version number [boolean]
--help Show help [boolean]
-p, --projectId [string]
--help Show help [boolean]
Examples:
node risk.js numerical nhtsa_traffic_fatalities accident_2015 state_number -p bigquery-public-data
Expand All @@ -180,3 +201,6 @@ For more information, see https://cloud.google.com/dlp/docs.

[risk_4_docs]: https://cloud.google.com/dlp/docs
[risk_4_code]: risk.js

[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dlp&page=editor&open_in_editor=samples/README.md
4 changes: 2 additions & 2 deletions packages/google-privacy-dlp/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"author": "Google Inc.",
"repository": "googleapis/nodejs-dlp",
"engines": {
"node": ">=4.3.2"
"node": ">=4.0.0"
},
"scripts": {
"test": "samples test run --cmd ava -- -T 1m --verbose system-test/*.test.js"
"test": "repo-tools test run --cmd ava -- -T 1m --verbose system-test/*.test.js"
},
"dependencies": {
"@google-cloud/bigquery": "^0.10.0",
Expand Down
38 changes: 25 additions & 13 deletions packages/google-privacy-dlp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* DO NOT DELETE THE FOLLOWING NAMESPACE DEFINITIONS
*/
/**
* @namespace google
*/
/**
* @namespace google.cloud
* @namespace google.privacy
*/
/**
* @namespace google.privacy.dlp
*/
/**
* @namespace google.privacy.dlp.v2beta1
*/
/**
* @namespace google.protobuf
*/
/**
* @namespace google.cloud.dlp
* @namespace google.rpc
*/
/**
* @namespace google.cloud.dlp.v2beta1
* @namespace google.type
*/

'use strict';
Expand All @@ -45,24 +57,24 @@ const gapic = Object.freeze({
* @module {object} @google-cloud/dlp
* @alias nodejs-dlp
*
* @example <caption>Install the client library with
* <a href="https://www.npmjs.com/">npm</a>:</caption>
* @example <caption>Install the client library with <a href="https://www.npmjs.com/">npm</a>:</caption>
* npm install --save @google-cloud/dlp
*
* @example <caption>Import the client library:</caption>
* const dlp = require('@google-cloud/dlp');
* const DLP = require('@google-cloud/dlp');
*
* @example <caption>Create a client that uses
* <a href="https://goo.gl/64dyYX">Application Default Credentials
* (ADC)</a>:</caption>
* let client = new dlp.DlpServiceClient();
* @example <caption>Create a client that uses <a href="https://goo.gl/64dyYX">Application Default Credentials (ADC)</a>:</caption>
* const client = new DLP.DlpServiceClient();
*
* @example <caption>Create a client with
* <a href="https://goo.gl/RXp6VL">explicit credentials</a>:</caption>
* let client = new dlp.DlpServiceClient({
* @example <caption>Create a client with <a href="https://goo.gl/RXp6VL">explicit credentials</a>:</caption>
* const client = new DLP.DlpServiceClient({
* projectId: 'your-project-id',
* keyFilename: '/path/to/keyfile.json',
* });
*
* @example <caption>include:samples/quickstart.js</caption>
* region_tag:quickstart
* Full quickstart example:
*/

/**
Expand Down

0 comments on commit 7940741

Please sign in to comment.