Skip to content

Commit b0231a1

Browse files
committed
Update dlp v2beta1 client
1 parent ae33610 commit b0231a1

7 files changed

Lines changed: 159 additions & 32 deletions

File tree

packages/dlp/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,39 @@ In order to use this library, you first need to go through the following steps:
1616
$ npm install --save @google-cloud/dlp
1717
```
1818

19+
### Preview
20+
#### DlpServiceClient
21+
```js
22+
var dlp = require('@google-cloud/dlp');
23+
24+
var client = dlp({
25+
// optional auth parameters.
26+
});
27+
28+
var minLikelihood = dlp.v2beta1.types.Likelihood.POSSIBLE;
29+
var inspectConfig = {
30+
minLikelihood : minLikelihood
31+
};
32+
var type = 'text/plain';
33+
var value = 'my phone number is 215-512-1212';
34+
var itemsElement = {
35+
type : type,
36+
value : value
37+
};
38+
var items = [itemsElement];
39+
var request = {
40+
inspectConfig: inspectConfig,
41+
items: items
42+
};
43+
client.inspectContent(request).then(function(responses) {
44+
var response = responses[0];
45+
// doThingsWith(response)
46+
})
47+
.catch(function(err) {
48+
console.error(err);
49+
});
50+
```
51+
1952
### Next Steps
2053
- Read the [Client Library Documentation][] for DLP API to see other available methods on the client.
2154
- Read the [DLP API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.

packages/dlp/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"files": [
99
"src",
1010
"AUTHORS",
11-
"CONTRIBUTING",
1211
"COPYING"
1312
],
1413
"keywords": [
@@ -25,16 +24,18 @@
2524
"DLP API"
2625
],
2726
"dependencies": {
28-
"google-proto-files": "^0.12.0",
27+
"extend": "^3.0",
2928
"google-gax": "^0.13.2",
30-
"extend": "^3.0.0"
29+
"google-proto-files": "^0.12.0"
3130
},
3231
"devDependencies": {
33-
"mocha": "^3.2.0"
32+
"mocha": "^3.2.0",
33+
"through2": "^2.0.3"
3434
},
3535
"scripts": {
36-
"test": "mocha",
37-
"publish-module": "node ../../scripts/publish.js dlp"
36+
"publish-module": "node ../../scripts/publish.js dlp",
37+
"smoke-test": "mocha smoke-test/*.js --timeout 5000",
38+
"test": "mocha test/*.js"
3839
},
3940
"license": "Apache-2.0",
4041
"engines": {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2017, Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
'use strict';
17+
18+
describe('DlpServiceSmokeTest', function() {
19+
20+
it('successfully makes a call to the service', function(done) {
21+
var dlp = require('../src');
22+
23+
var client = dlp.v2beta1({
24+
// optional auth parameters.
25+
});
26+
27+
var minLikelihood = dlp.v2beta1.types.Likelihood.POSSIBLE;
28+
var inspectConfig = {
29+
minLikelihood : minLikelihood
30+
};
31+
var type = 'text/plain';
32+
var value = 'my phone number is 215-512-1212';
33+
var itemsElement = {
34+
type : type,
35+
value : value
36+
};
37+
var items = [itemsElement];
38+
var request = {
39+
inspectConfig: inspectConfig,
40+
items: items
41+
};
42+
client.inspectContent(request).then(function(responses) {
43+
var response = responses[0];
44+
console.log(response);
45+
})
46+
.then(done)
47+
.catch(done);
48+
});
49+
});

packages/dlp/src/index.js

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,41 @@ var extend = require('extend');
2525
var gapic = {
2626
v2beta1: require('./v2beta1')
2727
};
28+
var gaxGrpc = require('google-gax').grpc();
2829

2930
const VERSION = require('../package.json').version;
3031

3132
/**
32-
* The [Data Loss Prevention (DLP) API](https://cloud.google.com/dlp) allows
33-
* clients to detect the presence of Personally Identifiable Information (PII)
34-
* and other privacy-sensitive data in user-supplied, unstructured data streams,
35-
* like text blocks or images.
33+
* Create a dlpServiceClient with additional helpers for common
34+
* tasks.
3635
*
37-
* The service also includes methods for sensitive data redaction and scheduling
38-
* of data scans on Google Cloud Platform based data sets.
36+
* The DLP API is a service that allows clients
37+
* to detect the presence of Personally Identifiable Information (PII) and other
38+
* privacy-sensitive data in user-supplied, unstructured data streams, like text
39+
* blocks or images.
40+
* The service also includes methods for sensitive data redaction and
41+
* scheduling of data scans on Google Cloud Platform based data sets.
3942
*
4043
* @param {object=} options - [Configuration object](#/docs).
44+
* @param {object=} options.credentials - Credentials object.
45+
* @param {string=} options.credentials.client_email
46+
* @param {string=} options.credentials.private_key
47+
* @param {string=} options.email - Account email address. Required when using a
48+
* .pem or .p12 keyFilename.
49+
* @param {string=} options.keyFilename - Full path to the a .json, .pem, or
50+
* .p12 key downloaded from the Google Developers Console. If you provide
51+
* a path to a JSON file, the projectId option above is not necessary.
52+
* NOTE: .pem and .p12 require you to specify options.email as well.
4153
* @param {number=} options.port - The port on which to connect to
4254
* the remote host.
55+
* @param {string=} options.projectId - The project ID from the Google
56+
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
57+
* the environment variable GCLOUD_PROJECT for your project ID. If your
58+
* app is running in an environment which supports
59+
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
60+
* your project ID will be detected automatically.
61+
* @param {function=} options.promise - Custom promise module to use instead
62+
* of native Promises.
4363
* @param {string=} options.servicePath - The domain name of the
4464
* API remote host.
4565
*/
@@ -50,10 +70,19 @@ function dlpV2beta1(options) {
5070
libVersion: VERSION
5171
});
5272

53-
// Create the image annotator client with the provided options.
73+
// Create the client with the provided options.
5474
var client = gapic.v2beta1(options).dlpServiceClient(options);
5575
return client;
5676
}
5777

78+
var v2beta1Protos = {};
79+
80+
extend(v2beta1Protos, gaxGrpc.load([{
81+
root: require('google-proto-files')('..'),
82+
file: 'google/privacy/dlp/v2beta1/dlp.proto'
83+
}]).google.privacy.dlp.v2beta1);
84+
5885
module.exports = dlpV2beta1;
59-
module.exports.v2beta1 = dlpV2beta1;
86+
module.exports.types = v2beta1Protos;
87+
module.exports.v2beta1 = dlpV2beta1;
88+
module.exports.v2beta1.types = v2beta1Protos;

packages/dlp/src/v2beta1/dlp_service_client.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'dlp.googleapis.com';
3535

3636
var DEFAULT_SERVICE_PORT = 443;
3737

38-
var CODE_GEN_NAME_VERSION = 'gapic/0.0.0';
38+
var CODE_GEN_NAME_VERSION = 'gapic/0.0.5';
3939

4040
/**
4141
* The scopes needed to make gRPC calls to all of the methods defined in
@@ -312,11 +312,13 @@ DlpServiceClient.prototype.redactContent = function(request, options, callback)
312312
* identifier for the Operation, and the `count` is a counter used for
313313
* tracking the number of files written. <p>The CSV file(s) contain the
314314
* following columns regardless of storage type scanned: <li>id <li>info_type
315-
* <li>likelihood <li>byte size of finding <li>quote <li>time_stamp<br/>
315+
* <li>likelihood <li>byte size of finding <li>quote <li>timestamp<br/>
316316
* <p>For Cloud Storage the next columns are: <li>file_path
317317
* <li>start_offset<br/>
318318
* <p>For Cloud Datastore the next columns are: <li>project_id
319-
* <li>namespace_id <li>path <li>column_name <li>offset
319+
* <li>namespace_id <li>path <li>column_name <li>offset<br/>
320+
* <p>For BigQuery the next columns are: <li>row_number <li>project_id
321+
* <li>dataset_id <li>table_id
320322
*
321323
* This object should have the same structure as [OutputStorageConfig]{@link OutputStorageConfig}
322324
* @param {Object=} options
@@ -423,7 +425,7 @@ DlpServiceClient.prototype.createInspectOperation = function(request, options, c
423425
* @param {string} request.name
424426
* Identifier of the results set returned as metadata of
425427
* the longrunning operation created by a call to CreateInspectOperation.
426-
* Should be in the format of `inspect/results/{id}.
428+
* Should be in the format of `inspect/results/{id}`.
427429
* @param {number=} request.pageSize
428430
* Maximum number of results to return.
429431
* If 0, the implementation selects a reasonable value.

packages/dlp/src/v2beta1/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function v2beta1(options) {
2727
return dlpServiceClient(gaxGrpc);
2828
}
2929

30-
v2beta1.GAPIC_VERSION = '0.0.0';
30+
v2beta1.GAPIC_VERSION = '0.0.5';
3131
v2beta1.SERVICE_ADDRESS = dlpServiceClient.SERVICE_ADDRESS;
3232
v2beta1.ALL_SCOPES = dlpServiceClient.ALL_SCOPES;
3333

packages/dlp/test/gapic-v2beta1.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
'use strict';
1717

1818
var assert = require('assert');
19-
var dlpV2beta1 = require('../src/v2beta1')();
19+
var dlp = require('../src');
2020

2121
var FAKE_STATUS_CODE = 1;
2222
var error = new Error();
2323
error.code = FAKE_STATUS_CODE;
24+
2425
describe('DlpServiceClient', function() {
2526
describe('inspectContent', function() {
2627
it('invokes inspectContent without error', function(done) {
27-
var client = dlpV2beta1.dlpServiceClient();
28+
var client = dlp.v2beta1();
29+
2830
// Mock request
2931
var inspectConfig = {};
3032
var items = [];
@@ -47,7 +49,8 @@ describe('DlpServiceClient', function() {
4749
});
4850

4951
it('invokes inspectContent with error', function(done) {
50-
var client = dlpV2beta1.dlpServiceClient();
52+
var client = dlp.v2beta1();
53+
5154
// Mock request
5255
var inspectConfig = {};
5356
var items = [];
@@ -69,7 +72,8 @@ describe('DlpServiceClient', function() {
6972

7073
describe('redactContent', function() {
7174
it('invokes redactContent without error', function(done) {
72-
var client = dlpV2beta1.dlpServiceClient();
75+
var client = dlp.v2beta1();
76+
7377
// Mock request
7478
var inspectConfig = {};
7579
var items = [];
@@ -94,7 +98,8 @@ describe('DlpServiceClient', function() {
9498
});
9599

96100
it('invokes redactContent with error', function(done) {
97-
var client = dlpV2beta1.dlpServiceClient();
101+
var client = dlp.v2beta1();
102+
98103
// Mock request
99104
var inspectConfig = {};
100105
var items = [];
@@ -118,7 +123,8 @@ describe('DlpServiceClient', function() {
118123

119124
describe('createInspectOperation', function() {
120125
it('invokes createInspectOperation without error', function(done) {
121-
var client = dlpV2beta1.dlpServiceClient();
126+
var client = dlp.v2beta1();
127+
122128
// Mock request
123129
var inspectConfig = {};
124130
var storageConfig = {};
@@ -150,7 +156,8 @@ describe('DlpServiceClient', function() {
150156
});
151157

152158
it('invokes createInspectOperation with error', function(done) {
153-
var client = dlpV2beta1.dlpServiceClient();
159+
var client = dlp.v2beta1();
160+
154161
// Mock request
155162
var inspectConfig = {};
156163
var storageConfig = {};
@@ -179,7 +186,8 @@ describe('DlpServiceClient', function() {
179186

180187
describe('listInspectFindings', function() {
181188
it('invokes listInspectFindings without error', function(done) {
182-
var client = dlpV2beta1.dlpServiceClient();
189+
var client = dlp.v2beta1();
190+
183191
// Mock request
184192
var formattedName = client.resultPath("[RESULT]");
185193
var request = {
@@ -203,7 +211,8 @@ describe('DlpServiceClient', function() {
203211
});
204212

205213
it('invokes listInspectFindings with error', function(done) {
206-
var client = dlpV2beta1.dlpServiceClient();
214+
var client = dlp.v2beta1();
215+
207216
// Mock request
208217
var formattedName = client.resultPath("[RESULT]");
209218
var request = {
@@ -223,7 +232,8 @@ describe('DlpServiceClient', function() {
223232

224233
describe('listInfoTypes', function() {
225234
it('invokes listInfoTypes without error', function(done) {
226-
var client = dlpV2beta1.dlpServiceClient();
235+
var client = dlp.v2beta1();
236+
227237
// Mock request
228238
var category = 'category50511102';
229239
var languageCode = 'languageCode-412800396';
@@ -246,7 +256,8 @@ describe('DlpServiceClient', function() {
246256
});
247257

248258
it('invokes listInfoTypes with error', function(done) {
249-
var client = dlpV2beta1.dlpServiceClient();
259+
var client = dlp.v2beta1();
260+
250261
// Mock request
251262
var category = 'category50511102';
252263
var languageCode = 'languageCode-412800396';
@@ -268,7 +279,8 @@ describe('DlpServiceClient', function() {
268279

269280
describe('listRootCategories', function() {
270281
it('invokes listRootCategories without error', function(done) {
271-
var client = dlpV2beta1.dlpServiceClient();
282+
var client = dlp.v2beta1();
283+
272284
// Mock request
273285
var languageCode = 'languageCode-412800396';
274286
var request = {
@@ -289,7 +301,8 @@ describe('DlpServiceClient', function() {
289301
});
290302

291303
it('invokes listRootCategories with error', function(done) {
292-
var client = dlpV2beta1.dlpServiceClient();
304+
var client = dlp.v2beta1();
305+
293306
// Mock request
294307
var languageCode = 'languageCode-412800396';
295308
var request = {

0 commit comments

Comments
 (0)