From 7121b38bebbcfc27c8bf1bd71170e7e1023019b5 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Sun, 21 May 2017 11:34:13 -0700 Subject: [PATCH 01/12] DLP library (GAPIC-only) --- packages/dlp/package.json | 40 ++ packages/dlp/src/index.js | 51 ++ .../dlp/src/v2beta1/dlp_service_client.js | 513 ++++++++++++++++++ .../v2beta1/dlp_service_client_config.json | 58 ++ packages/dlp/src/v2beta1/index.js | 34 ++ packages/dlp/test/gapic-v2beta1.js | 316 +++++++++++ 6 files changed, 1012 insertions(+) create mode 100644 packages/dlp/package.json create mode 100644 packages/dlp/src/index.js create mode 100644 packages/dlp/src/v2beta1/dlp_service_client.js create mode 100644 packages/dlp/src/v2beta1/dlp_service_client_config.json create mode 100644 packages/dlp/src/v2beta1/index.js create mode 100644 packages/dlp/test/gapic-v2beta1.js diff --git a/packages/dlp/package.json b/packages/dlp/package.json new file mode 100644 index 00000000000..806cfe4af2f --- /dev/null +++ b/packages/dlp/package.json @@ -0,0 +1,40 @@ +{ + "repository": "GoogleCloudPlatform/google-cloud-node", + "name": "dlp", + "version": "0.0.0", + "author": "Google Inc", + "description": "DLP API client for Node.js", + "main": "src/index.js", + "files": [ + "src" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google dlp", + "dlp", + "DLP API" + ], + "dependencies": { + "google-proto-files": "^0.12.0", + "google-gax": "^0.12.2", + "extend": "^3.0.0" + }, + "devDependencies": { + "mocha": "3.2.0", + "through2": "2.0.3" + }, + "scripts": { + "test": "mocha" + }, + "license": "Apache-2.0", + "engines": { + "node": ">=4.0.0" + } +} diff --git a/packages/dlp/src/index.js b/packages/dlp/src/index.js new file mode 100644 index 00000000000..cefaec99ce1 --- /dev/null +++ b/packages/dlp/src/index.js @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var gapic = { + v2beta1: require('./v2beta1'), +}; + +const VERSION = require('../package.json').version; + +/** + * Create an dlpServiceClient with additional helpers for common + * tasks. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + */ +function dlp_v2beta1(opts) { + // Define the header options. + opts = opts || {}; + opts.libName = 'gccl'; + opts.libVersion = VERSION; + + // Create the image annotator client with the provided options. + var client = gapic.v2beta1(opts).dlpServiceClient(opts); + return client; +} + +module.exports = dlp_v2beta1; +module.exports.v2beta1 = dlp_v2beta1; \ No newline at end of file diff --git a/packages/dlp/src/v2beta1/dlp_service_client.js b/packages/dlp/src/v2beta1/dlp_service_client.js new file mode 100644 index 00000000000..afdf83445cf --- /dev/null +++ b/packages/dlp/src/v2beta1/dlp_service_client.js @@ -0,0 +1,513 @@ +/* + * Copyright 2017, Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/googleapis/googleapis/blob/master/google/privacy/dlp/v2beta1/dlp.proto, + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google + * engineers. + * + * The only allowed edits are to method and file documentation. A 3-way + * merge preserves those additions if the generated source changes. + */ +/* TODO: introduce line-wrapping so that it never exceeds the limit. */ +/* jscs: disable maximumLineLength */ +'use strict'; + +var configData = require('./dlp_service_client_config'); +var extend = require('extend'); +var gax = require('google-gax'); + +var SERVICE_ADDRESS = 'dlp.googleapis.com'; + +var DEFAULT_SERVICE_PORT = 443; + +var CODE_GEN_NAME_VERSION = 'gapic/0.7.1'; + +/** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ +var ALL_SCOPES = [ + 'https://www.googleapis.com/auth/cloud-platform' +]; + +/** + * The DLP API is a service that allows clients + * to detect the presence of Personally Identifiable Information (PII) and other + * privacy-sensitive data in user-supplied, unstructured data streams, like text + * blocks or images. + * The service also includes methods for sensitive data redaction and + * scheduling of data scans on Google Cloud Platform based data sets. + * + * This will be created through a builder function which can be obtained by the module. + * See the following example of how to initialize the module and how to access to the builder. + * @see {@link dlpServiceClient} + * + * @example + * var dlpV2beta1 = require('dlp.v2beta1').v2beta1({ + * // optional auth parameters. + * }); + * var client = dlpV2beta1.dlpServiceClient(); + * + * @class + */ +function DlpServiceClient(gaxGrpc, grpcClients, opts) { + opts = extend({ + servicePath: SERVICE_ADDRESS, + port: DEFAULT_SERVICE_PORT, + clientConfig: {} + }, opts); + + var googleApiClient = [ + 'gl-node/' + process.versions.node + ]; + if (opts.libName && opts.libVersion) { + googleApiClient.push(opts.libName + '/' + opts.libVersion); + } + googleApiClient.push( + CODE_GEN_NAME_VERSION, + 'gax/' + gax.version, + 'grpc/' + gaxGrpc.grpcVersion + ); + + var defaults = gaxGrpc.constructSettings( + 'google.privacy.dlp.v2beta1.DlpService', + configData, + opts.clientConfig, + {'x-goog-api-client': googleApiClient.join(' ')}); + + var self = this; + + this.auth = gaxGrpc.auth; + var dlpServiceStub = gaxGrpc.createStub( + grpcClients.google.privacy.dlp.v2beta1.DlpService, + opts); + var dlpServiceStubMethods = [ + 'inspectContent', + 'redactContent', + 'createInspectOperation', + 'listInspectFindings', + 'listInfoTypes', + 'listRootCategories' + ]; + dlpServiceStubMethods.forEach(function(methodName) { + self['_' + methodName] = gax.createApiCall( + dlpServiceStub.then(function(dlpServiceStub) { + return function() { + var args = Array.prototype.slice.call(arguments, 0); + return dlpServiceStub[methodName].apply(dlpServiceStub, args); + }; + }), + defaults[methodName], + null); + }); +} + +// Path templates + +var RESULT_PATH_TEMPLATE = new gax.PathTemplate( + 'inspect/results/{result}'); + +/** + * Returns a fully-qualified result resource name string. + * @param {String} result + * @returns {String} + */ +DlpServiceClient.prototype.resultPath = function(result) { + return RESULT_PATH_TEMPLATE.render({ + result: result + }); +}; + +/** + * Parses the resultName from a result resource. + * @param {String} resultName + * A fully-qualified path representing a result resources. + * @returns {String} - A string representing the result. + */ +DlpServiceClient.prototype.matchResultFromResultName = function(resultName) { + return RESULT_PATH_TEMPLATE.match(resultName).result; +}; + +/** + * Get the project ID used by this class. + * @param {function(Error, string)} callback - the callback to be called with + * the current project Id. + */ +DlpServiceClient.prototype.getProjectId = function(callback) { + return this.auth.getProjectId(callback); +}; + +// Service calls + +/** + * Find potentially sensitive info in a list of strings. + * This method has limits on input size, processing time, and output size. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object} request.inspectConfig + * Configuration for the inspector. + * + * This object should have the same structure as [InspectConfig]{@link InspectConfig} + * @param {Object[]} request.items + * The list of items to inspect. Items in a single request are + * considered "related" unless inspect_config.independent_inputs is true. + * Up to 100 are allowed per request. + * + * This object should have the same structure as [ContentItem]{@link ContentItem} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [InspectContentResponse]{@link InspectContentResponse}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [InspectContentResponse]{@link InspectContentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var inspectConfig = {}; + * var items = []; + * var request = { + * inspectConfig: inspectConfig, + * items: items + * }; + * client.inspectContent(request).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.inspectContent = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._inspectContent(request, options, callback); +}; + +/** + * Redact potentially sensitive info from a list of strings. + * This method has limits on input size, processing time, and output size. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object} request.inspectConfig + * Configuration for the inspector. + * + * This object should have the same structure as [InspectConfig]{@link InspectConfig} + * @param {Object[]} request.items + * The list of items to inspect. Up to 100 are allowed per request. + * + * This object should have the same structure as [ContentItem]{@link ContentItem} + * @param {Object[]} request.replaceConfigs + * The strings to replace findings with. Must specify at least one. + * + * This object should have the same structure as [ReplaceConfig]{@link ReplaceConfig} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [RedactContentResponse]{@link RedactContentResponse}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RedactContentResponse]{@link RedactContentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var inspectConfig = {}; + * var items = []; + * var replaceConfigs = []; + * var request = { + * inspectConfig: inspectConfig, + * items: items, + * replaceConfigs: replaceConfigs + * }; + * client.redactContent(request).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.redactContent = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._redactContent(request, options, callback); +}; + +/** + * Schedule a job scanning content in a Google Cloud Platform data repository. + * + * @param {Object} request + * The request object that will be sent. + * @param {Object} request.inspectConfig + * Configuration for the inspector. + * + * This object should have the same structure as [InspectConfig]{@link InspectConfig} + * @param {Object} request.storageConfig + * Specification of the data set to process. + * + * This object should have the same structure as [StorageConfig]{@link StorageConfig} + * @param {Object} request.outputConfig + * Optional location to store findings. The bucket must already exist and + * the Google APIs service account for DLP must have write permission to + * write to the given bucket. + * Results will be split over multiple csv files with each file name matching + * the pattern "[operation_id] + [count].csv". + * The operation_id will match the identifier for the Operation, + * and the [count] is a counter used for tracking the number of files written. + * The CSV file(s) contain the following columns regardless of storage type + * scanned: id, info_type, likelihood, byte size of finding, quote, time_stamp + * For cloud storage the next two columns are: file_path, start_offset + * For datastore the next two columns are: project_id, namespace_id, path, + * column_name, offset. + * + * This object should have the same structure as [OutputStorageConfig]{@link OutputStorageConfig} + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var inspectConfig = {}; + * var storageConfig = {}; + * var outputConfig = {}; + * var request = { + * inspectConfig: inspectConfig, + * storageConfig: storageConfig, + * outputConfig: outputConfig + * }; + * client.createInspectOperation(request).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.createInspectOperation = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._createInspectOperation(request, options, callback); +}; + +/** + * Returns list of results for given inspect operation result set id. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Identifier of the results set returned as metadata of + * the longrunning operation created by a call to CreateInspectOperation. + * Should be in the format of `inspect/results/{id}. + * @param {number=} request.pageSize + * Maximum number of results to return. + * If 0, the implementation will select a reasonable value. + * @param {string=} request.pageToken + * The value returned by the last `ListInspectFindingsResponse`; indicates + * that this is a continuation of a prior `ListInspectFindings` call, and that + * the system should return the next page of data. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [ListInspectFindingsResponse]{@link ListInspectFindingsResponse}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListInspectFindingsResponse]{@link ListInspectFindingsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var formattedName = client.resultPath("[RESULT]"); + * client.listInspectFindings({name: formattedName}).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.listInspectFindings = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._listInspectFindings(request, options, callback); +}; + +/** + * Returns sensitive information types for given category. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.category + * Category name as returned by ListRootCategories. + * @param {string} request.languageCode + * Optional BCP-47 language code for localized info type friendly + * names. If omitted, or if localized strings are not available, + * en-US strings will be returned. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [ListInfoTypesResponse]{@link ListInfoTypesResponse}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListInfoTypesResponse]{@link ListInfoTypesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var category = ''; + * var languageCode = ''; + * var request = { + * category: category, + * languageCode: languageCode + * }; + * client.listInfoTypes(request).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.listInfoTypes = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._listInfoTypes(request, options, callback); +}; + +/** + * Returns the list of root categories of sensitive information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.languageCode + * Optional language code for localized friendly category names. + * If omitted or if localized strings are not available, + * en-US strings will be returned. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [ListRootCategoriesResponse]{@link ListRootCategoriesResponse}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListRootCategoriesResponse]{@link ListRootCategoriesResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * var client = dlpV2beta1.dlpServiceClient(); + * var languageCode = ''; + * client.listRootCategories({languageCode: languageCode}).then(function(responses) { + * var response = responses[0]; + * // doThingsWith(response) + * }).catch(function(err) { + * console.error(err); + * }); + */ +DlpServiceClient.prototype.listRootCategories = function(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + return this._listRootCategories(request, options, callback); +}; + +function DlpServiceClientBuilder(gaxGrpc) { + if (!(this instanceof DlpServiceClientBuilder)) { + return new DlpServiceClientBuilder(gaxGrpc); + } + + var dlpServiceClient = require('grpc-google-privacy-dlp-v2beta1').client; + extend(this, dlpServiceClient.google.privacy.dlp.v2beta1); + + + /** + * Build a new instance of {@link DlpServiceClient}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath + * The domain name of the API remote host. + * @param {number=} opts.port + * The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds + * A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig + * The customized config to build the call settings. See + * {@link gax.constructSettings} for the format. + */ + this.dlpServiceClient = function(opts) { + return new DlpServiceClient(gaxGrpc, dlpServiceClient, opts); + }; + extend(this.dlpServiceClient, DlpServiceClient); +} +module.exports = DlpServiceClientBuilder; +module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; +module.exports.ALL_SCOPES = ALL_SCOPES; \ No newline at end of file diff --git a/packages/dlp/src/v2beta1/dlp_service_client_config.json b/packages/dlp/src/v2beta1/dlp_service_client_config.json new file mode 100644 index 00000000000..0e7d58accfe --- /dev/null +++ b/packages/dlp/src/v2beta1/dlp_service_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.privacy.dlp.v2beta1.DlpService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "InspectContent": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RedactContent": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateInspectOperation": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListInspectFindings": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListInfoTypes": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListRootCategories": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/dlp/src/v2beta1/index.js b/packages/dlp/src/v2beta1/index.js new file mode 100644 index 00000000000..351aa995307 --- /dev/null +++ b/packages/dlp/src/v2beta1/index.js @@ -0,0 +1,34 @@ +/* + * Copyright 2016 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var dlpServiceClient = require('./dlp_service_client'); +var gax = require('google-gax'); +var extend = require('extend'); + +function v2beta1(options) { + options = extend({ + scopes: v2beta1.ALL_SCOPES + }, options); + var gaxGrpc = gax.grpc(options); + return dlpServiceClient(gaxGrpc); +} + +v2beta1.GAPIC_VERSION = '0.7.1'; +v2beta1.SERVICE_ADDRESS = dlpServiceClient.SERVICE_ADDRESS; +v2beta1.ALL_SCOPES = dlpServiceClient.ALL_SCOPES; + +module.exports = v2beta1; diff --git a/packages/dlp/test/gapic-v2beta1.js b/packages/dlp/test/gapic-v2beta1.js new file mode 100644 index 00000000000..c87cdf15597 --- /dev/null +++ b/packages/dlp/test/gapic-v2beta1.js @@ -0,0 +1,316 @@ +/* + * Copyright 2016 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var assert = require('assert'); +var dlpV2beta1 = require('../src/v2beta1')(); + +var FAKE_STATUS_CODE = 1; +var error = new Error(); +error.code = FAKE_STATUS_CODE; + +describe('DlpServiceClient', function() { + describe('inspectContent', function() { + it('invokes inspectContent without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var request = { + inspectConfig : inspectConfig, + items : items + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._inspectContent = mockSimpleGrpcMethod(request, expectedResponse); + + client.inspectContent(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes inspectContent with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var request = { + inspectConfig : inspectConfig, + items : items + }; + + // Mock Grpc layer + client._inspectContent = mockSimpleGrpcMethod(request, null, error); + + client.inspectContent(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('redactContent', function() { + it('invokes redactContent without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var replaceConfigs = []; + var request = { + inspectConfig : inspectConfig, + items : items, + replaceConfigs : replaceConfigs + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._redactContent = mockSimpleGrpcMethod(request, expectedResponse); + + client.redactContent(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes redactContent with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var replaceConfigs = []; + var request = { + inspectConfig : inspectConfig, + items : items, + replaceConfigs : replaceConfigs + }; + + // Mock Grpc layer + client._redactContent = mockSimpleGrpcMethod(request, null, error); + + client.redactContent(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('createInspectOperation', function() { + it('invokes createInspectOperation without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var storageConfig = {}; + var outputConfig = {}; + var request = { + inspectConfig : inspectConfig, + storageConfig : storageConfig, + outputConfig : outputConfig + }; + + // Mock response + var name = 'name3373707'; + var done = true; + var expectedResponse = { + name : name, + done : done + }; + + // Mock Grpc layer + client._createInspectOperation = mockSimpleGrpcMethod(request, expectedResponse); + + client.createInspectOperation(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes createInspectOperation with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var storageConfig = {}; + var outputConfig = {}; + var request = { + inspectConfig : inspectConfig, + storageConfig : storageConfig, + outputConfig : outputConfig + }; + + // Mock Grpc layer + client._createInspectOperation = mockSimpleGrpcMethod(request, null, error); + + client.createInspectOperation(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listInspectFindings', function() { + it('invokes listInspectFindings without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var formattedName = client.resultPath("[RESULT]"); + var request = { + name : formattedName + }; + + // Mock response + var nextPageToken = 'nextPageToken-1530815211'; + var expectedResponse = { + nextPageToken : nextPageToken + }; + + // Mock Grpc layer + client._listInspectFindings = mockSimpleGrpcMethod(request, expectedResponse); + + client.listInspectFindings(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listInspectFindings with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var formattedName = client.resultPath("[RESULT]"); + var request = { + name : formattedName + }; + + // Mock Grpc layer + client._listInspectFindings = mockSimpleGrpcMethod(request, null, error); + + client.listInspectFindings(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listInfoTypes', function() { + it('invokes listInfoTypes without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var category = 'category50511102'; + var languageCode = 'languageCode-412800396'; + var request = { + category : category, + languageCode : languageCode + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._listInfoTypes = mockSimpleGrpcMethod(request, expectedResponse); + + client.listInfoTypes(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listInfoTypes with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var category = 'category50511102'; + var languageCode = 'languageCode-412800396'; + var request = { + category : category, + languageCode : languageCode + }; + + // Mock Grpc layer + client._listInfoTypes = mockSimpleGrpcMethod(request, null, error); + + client.listInfoTypes(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listRootCategories', function() { + it('invokes listRootCategories without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var languageCode = 'languageCode-412800396'; + var request = { + languageCode : languageCode + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._listRootCategories = mockSimpleGrpcMethod(request, expectedResponse); + + client.listRootCategories(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listRootCategories with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var languageCode = 'languageCode-412800396'; + var request = { + languageCode : languageCode + }; + + // Mock Grpc layer + client._listRootCategories = mockSimpleGrpcMethod(request, null, error); + + client.listRootCategories(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + +}); + +function mockSimpleGrpcMethod(expectedRequest, response, error) { + return function(actualRequest, options, callback) { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} From 8b6f34a32c4d6681d701d0e61d95ff30d2b76643 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Tue, 23 May 2017 13:57:29 -0700 Subject: [PATCH 02/12] New autogen. --- packages/dlp/src/v2beta1/dlp_service_client.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/dlp/src/v2beta1/dlp_service_client.js b/packages/dlp/src/v2beta1/dlp_service_client.js index afdf83445cf..4a6bcf1bcbd 100644 --- a/packages/dlp/src/v2beta1/dlp_service_client.js +++ b/packages/dlp/src/v2beta1/dlp_service_client.js @@ -58,7 +58,7 @@ var ALL_SCOPES = [ * @see {@link dlpServiceClient} * * @example - * var dlpV2beta1 = require('dlp.v2beta1').v2beta1({ + * var dlpV2beta1 = require('@google-cloud/dlp').v2beta1({ * // optional auth parameters. * }); * var client = dlpV2beta1.dlpServiceClient(); @@ -485,7 +485,10 @@ function DlpServiceClientBuilder(gaxGrpc) { return new DlpServiceClientBuilder(gaxGrpc); } - var dlpServiceClient = require('grpc-google-privacy-dlp-v2beta1').client; + var dlpServiceClient = gaxGrpc.load([{ + root: require('google-proto-files')('..'), + file: 'google/privacy/dlp/v2beta1/dlp.proto' + }]); extend(this, dlpServiceClient.google.privacy.dlp.v2beta1); From 950d332476f40c93f7157ea469af60d4236d1712 Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Thu, 25 May 2017 13:32:34 -0700 Subject: [PATCH 03/12] Regen --- packages/dlp/README.md | 25 ++++++++++++++++++ packages/dlp/package.json | 21 +++++++++------ packages/dlp/src/index.js | 42 ++++++++++++++++-------------- packages/dlp/src/v2beta1/index.js | 6 ++--- packages/dlp/test/gapic-v2beta1.js | 4 +-- 5 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 packages/dlp/README.md diff --git a/packages/dlp/README.md b/packages/dlp/README.md new file mode 100644 index 00000000000..e9956f1cddb --- /dev/null +++ b/packages/dlp/README.md @@ -0,0 +1,25 @@ +# Node.js Client for DLP API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning)) + +Idiomatic Node.js client for [DLP API][Product Documentation] +- [Client Library Documentation][] +- [Product Documentation][] + +## Quick Start +In order to use this library, you first need to go through the following steps: + +1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) +2. [Enable the dlp api.](https://console.cloud.google.com/apis/api/dlp) +3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication) + +### Installation +``` +$ npm install @google-cloud/dlp +``` + +### Next Steps +- Read the [Client Library Documentation][] for DLP API to see other available methods on the client. +- Read the [DLP API Product documentation][Product Documentation] to learn more about the product and see How-to Guides. +- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover. + +[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/dlp +[Product Documentation]: https://cloud.google.com/dlp \ No newline at end of file diff --git a/packages/dlp/package.json b/packages/dlp/package.json index 806cfe4af2f..b4d420ff41d 100644 --- a/packages/dlp/package.json +++ b/packages/dlp/package.json @@ -1,12 +1,16 @@ { "repository": "GoogleCloudPlatform/google-cloud-node", - "name": "dlp", - "version": "0.0.0", + "name": "@google-cloud/dlp", + "version": "0.7.1", "author": "Google Inc", "description": "DLP API client for Node.js", + "url": "https://github.com/googleapis/googleapis", "main": "src/index.js", "files": [ - "src" + "src", + "AUTHORS", + "CONTRIBUTING", + "COPYING" ], "keywords": [ "google apis client", @@ -22,16 +26,17 @@ "DLP API" ], "dependencies": { - "google-proto-files": "^0.12.0", - "google-gax": "^0.12.2", + "google-proto-files": "^0.8.6", + "google-gax": "^0.13.2", "extend": "^3.0.0" }, "devDependencies": { - "mocha": "3.2.0", - "through2": "2.0.3" + "mocha": "^3.2.0", + "through2": "^2.0.3" }, "scripts": { - "test": "mocha" + "test": "mocha", + "publish-module": "node ../../scripts/publish.js dlp" }, "license": "Apache-2.0", "engines": { diff --git a/packages/dlp/src/index.js b/packages/dlp/src/index.js index cefaec99ce1..86c9ad94e07 100644 --- a/packages/dlp/src/index.js +++ b/packages/dlp/src/index.js @@ -1,11 +1,11 @@ /* - * Copyright 2016 Google Inc. All rights reserved. + * Copyright 2017, Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,8 +15,9 @@ */ 'use strict'; +var extend = require('extend'); var gapic = { - v2beta1: require('./v2beta1'), + v2beta1: require('./v2beta1') }; const VERSION = require('../package.json').version; @@ -25,27 +26,28 @@ const VERSION = require('../package.json').version; * Create an dlpServiceClient with additional helpers for common * tasks. * - * @param {Object=} opts - The optional parameters. - * @param {String=} opts.servicePath - * The domain name of the API remote host. - * @param {number=} opts.port - * The port on which to connect to the remote host. - * @param {grpc.ClientCredentials=} opts.sslCreds - * A ClientCredentials for use with an SSL-enabled channel. - * @param {Object=} opts.clientConfig - * The customized config to build the call settings. See - * {@link gax.constructSettings} for the format. + * The DLP API is a service that allows clients + * to detect the presence of Personally Identifiable Information (PII) and other + * privacy-sensitive data in user-supplied, unstructured data streams, like text + * blocks or images. + * The service also includes methods for sensitive data redaction and + * scheduling of data scans on Google Cloud Platform based data sets. + * + * @param {object=} options - [Configuration object](#/docs). + * @param {number=} options.port - The port on which to connect to the remote host. + * @param {string=} options.servicePath - The domain name of the API remote host. */ -function dlp_v2beta1(opts) { +function dlpV2beta1(options) { // Define the header options. - opts = opts || {}; - opts.libName = 'gccl'; - opts.libVersion = VERSION; + options = extend({}, options, { + libName: 'gccl', + libVersion: VERSION + }); // Create the image annotator client with the provided options. - var client = gapic.v2beta1(opts).dlpServiceClient(opts); + var client = gapic.v2beta1(options).dlpServiceClient(options); return client; } -module.exports = dlp_v2beta1; -module.exports.v2beta1 = dlp_v2beta1; \ No newline at end of file +module.exports = dlpV2beta1; +module.exports.v2beta1 = dlpV2beta1; \ No newline at end of file diff --git a/packages/dlp/src/v2beta1/index.js b/packages/dlp/src/v2beta1/index.js index 351aa995307..8419badba4f 100644 --- a/packages/dlp/src/v2beta1/index.js +++ b/packages/dlp/src/v2beta1/index.js @@ -1,11 +1,11 @@ /* - * Copyright 2016 Google Inc. All rights reserved. + * Copyright 2017, Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -31,4 +31,4 @@ v2beta1.GAPIC_VERSION = '0.7.1'; v2beta1.SERVICE_ADDRESS = dlpServiceClient.SERVICE_ADDRESS; v2beta1.ALL_SCOPES = dlpServiceClient.ALL_SCOPES; -module.exports = v2beta1; +module.exports = v2beta1; \ No newline at end of file diff --git a/packages/dlp/test/gapic-v2beta1.js b/packages/dlp/test/gapic-v2beta1.js index c87cdf15597..d5db5a66008 100644 --- a/packages/dlp/test/gapic-v2beta1.js +++ b/packages/dlp/test/gapic-v2beta1.js @@ -1,11 +1,11 @@ /* - * Copyright 2016 Google Inc. All rights reserved. + * Copyright 2017, Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, From 8549ad999fbe160e8a38a9107ebd967cac461061 Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Thu, 25 May 2017 13:32:34 -0700 Subject: [PATCH 04/12] Regen --- packages/dlp/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dlp/package.json b/packages/dlp/package.json index b4d420ff41d..0cfff858bdf 100644 --- a/packages/dlp/package.json +++ b/packages/dlp/package.json @@ -1,7 +1,7 @@ { "repository": "GoogleCloudPlatform/google-cloud-node", "name": "@google-cloud/dlp", - "version": "0.7.1", + "version": "0.0.0", "author": "Google Inc", "description": "DLP API client for Node.js", "url": "https://github.com/googleapis/googleapis", From c051b4ba4d39272dda245222e3e1da75142d335f Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Thu, 25 May 2017 21:21:27 -0700 Subject: [PATCH 05/12] Regen --- packages/dlp/README.md | 4 ++-- packages/dlp/package.json | 3 +-- packages/dlp/src/index.js | 6 ++++-- packages/dlp/src/v2beta1/dlp_service_client.js | 2 +- packages/dlp/src/v2beta1/index.js | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/dlp/README.md b/packages/dlp/README.md index e9956f1cddb..d701359bbb9 100644 --- a/packages/dlp/README.md +++ b/packages/dlp/README.md @@ -8,12 +8,12 @@ Idiomatic Node.js client for [DLP API][Product Documentation] In order to use this library, you first need to go through the following steps: 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) -2. [Enable the dlp api.](https://console.cloud.google.com/apis/api/dlp) +2. [Enable the DLP API.](https://console.cloud.google.com/apis/api/dlp) 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication) ### Installation ``` -$ npm install @google-cloud/dlp +$ npm install --save @google-cloud/dlp ``` ### Next Steps diff --git a/packages/dlp/package.json b/packages/dlp/package.json index 0cfff858bdf..ce503ca9581 100644 --- a/packages/dlp/package.json +++ b/packages/dlp/package.json @@ -4,7 +4,6 @@ "version": "0.0.0", "author": "Google Inc", "description": "DLP API client for Node.js", - "url": "https://github.com/googleapis/googleapis", "main": "src/index.js", "files": [ "src", @@ -26,7 +25,7 @@ "DLP API" ], "dependencies": { - "google-proto-files": "^0.8.6", + "google-proto-files": "^0.12.0", "google-gax": "^0.13.2", "extend": "^3.0.0" }, diff --git a/packages/dlp/src/index.js b/packages/dlp/src/index.js index 86c9ad94e07..922d1d7e10b 100644 --- a/packages/dlp/src/index.js +++ b/packages/dlp/src/index.js @@ -34,8 +34,10 @@ const VERSION = require('../package.json').version; * scheduling of data scans on Google Cloud Platform based data sets. * * @param {object=} options - [Configuration object](#/docs). - * @param {number=} options.port - The port on which to connect to the remote host. - * @param {string=} options.servicePath - The domain name of the API remote host. + * @param {number=} options.port - The port on which to connect to + * the remote host. + * @param {string=} options.servicePath - The domain name of the + * API remote host. */ function dlpV2beta1(options) { // Define the header options. diff --git a/packages/dlp/src/v2beta1/dlp_service_client.js b/packages/dlp/src/v2beta1/dlp_service_client.js index 4a6bcf1bcbd..e2ca8350a34 100644 --- a/packages/dlp/src/v2beta1/dlp_service_client.js +++ b/packages/dlp/src/v2beta1/dlp_service_client.js @@ -35,7 +35,7 @@ var SERVICE_ADDRESS = 'dlp.googleapis.com'; var DEFAULT_SERVICE_PORT = 443; -var CODE_GEN_NAME_VERSION = 'gapic/0.7.1'; +var CODE_GEN_NAME_VERSION = 'gapic/0.0.0'; /** * The scopes needed to make gRPC calls to all of the methods defined in diff --git a/packages/dlp/src/v2beta1/index.js b/packages/dlp/src/v2beta1/index.js index 8419badba4f..f81ac094648 100644 --- a/packages/dlp/src/v2beta1/index.js +++ b/packages/dlp/src/v2beta1/index.js @@ -27,7 +27,7 @@ function v2beta1(options) { return dlpServiceClient(gaxGrpc); } -v2beta1.GAPIC_VERSION = '0.7.1'; +v2beta1.GAPIC_VERSION = '0.0.0'; v2beta1.SERVICE_ADDRESS = dlpServiceClient.SERVICE_ADDRESS; v2beta1.ALL_SCOPES = dlpServiceClient.ALL_SCOPES; From 772ac4853e9d4094cee5f1c5cf10b0915941a5ca Mon Sep 17 00:00:00 2001 From: Ernest Landrito Date: Fri, 26 May 2017 01:45:17 -0700 Subject: [PATCH 06/12] Regeneration --- packages/dlp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dlp/README.md b/packages/dlp/README.md index d701359bbb9..e6de4d11497 100644 --- a/packages/dlp/README.md +++ b/packages/dlp/README.md @@ -1,6 +1,6 @@ # Node.js Client for DLP API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning)) -Idiomatic Node.js client for [DLP API][Product Documentation] +[DLP API][Product Documentation]: The Google Data Loss Prevention API provides methods for detection of privacy-sensitive fragments in text, images, and Google Cloud Platform storage repositories. - [Client Library Documentation][] - [Product Documentation][] From 9790bcb90e2a61e30ddf6f546c49aa05368fbbd4 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Fri, 26 May 2017 08:41:36 -0400 Subject: [PATCH 07/12] add docs config --- scripts/docs/config.js | 3 +++ scripts/helpers.js | 1 + 2 files changed, 4 insertions(+) diff --git a/scripts/docs/config.js b/scripts/docs/config.js index 674daf0a350..0f70f676fe7 100644 --- a/scripts/docs/config.js +++ b/scripts/docs/config.js @@ -63,6 +63,9 @@ module.exports = { datastore: { title: 'Cloud Datastore' }, + dlp: { + title: 'DLP API' + }, dns: { title: 'Cloud DNS' }, diff --git a/scripts/helpers.js b/scripts/helpers.js index c1ac5c90c3a..ba1cb63a9c2 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -239,6 +239,7 @@ Module.prototype.runSystemTests = function() { var modulesExcludedFromSystemTests = [ 'common', 'common-grpc', + 'dlp', 'error-reporting', 'google-cloud', 'monitoring', From 9c2a6ad6cce8b32730e4bb5f8e672a0acd9dad19 Mon Sep 17 00:00:00 2001 From: Song Wang Date: Wed, 31 May 2017 15:10:08 -0700 Subject: [PATCH 08/12] Fix the long running operation method (#2346) --- .../dlp/src/v2beta1/dlp_service_client.js | 61 +++++++++++++++++-- .../{gapic-v2beta1.js => test-v2beta1.js} | 45 +++++++++++--- 2 files changed, 91 insertions(+), 15 deletions(-) rename packages/dlp/test/{gapic-v2beta1.js => test-v2beta1.js} (88%) diff --git a/packages/dlp/src/v2beta1/dlp_service_client.js b/packages/dlp/src/v2beta1/dlp_service_client.js index e2ca8350a34..d9225aaf614 100644 --- a/packages/dlp/src/v2beta1/dlp_service_client.js +++ b/packages/dlp/src/v2beta1/dlp_service_client.js @@ -84,6 +84,18 @@ function DlpServiceClient(gaxGrpc, grpcClients, opts) { 'grpc/' + gaxGrpc.grpcVersion ); + this.operationsClient = new gax.lro({ + auth: gaxGrpc.auth, + grpc: gaxGrpc.grpc + }).operationsClient(opts); + + this.longrunningDescriptors = { + createInspectOperation: new gax.LongrunningDescriptor( + this.operationsClient, + grpcClients.google.privacy.dlp.v2beta1.InspectOperationResult.decode, + grpcClients.google.privacy.dlp.v2beta1.InspectOperationMetadata.decode) + }; + var defaults = gaxGrpc.constructSettings( 'google.privacy.dlp.v2beta1.DlpService', configData, @@ -113,7 +125,7 @@ function DlpServiceClient(gaxGrpc, grpcClients, opts) { }; }), defaults[methodName], - null); + self.longrunningDescriptors[methodName]); }); } @@ -302,9 +314,9 @@ DlpServiceClient.prototype.redactContent = function(request, options, callback) * @param {function(?Error, ?Object)=} callback * The function which will be called with the result of the API call. * - * The second parameter to the callback is an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"}. + * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"}. + * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example @@ -318,9 +330,48 @@ DlpServiceClient.prototype.redactContent = function(request, options, callback) * storageConfig: storageConfig, * outputConfig: outputConfig * }; + * + * // Handle the operation using the promise pattern. * client.createInspectOperation(request).then(function(responses) { - * var response = responses[0]; - * // doThingsWith(response) + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Operation#promise starts polling for the completion of the LRO. + * return operation.promise(); + * }).then(function(responses) { + * // The final result of the operation. + * var result = responses[0]; + * + * // The metadata value of the completed operation. + * var metadata = responses[1]; + * + * // The response of the api call returning the complete operation. + * var finalApiResponse = responses[2]; + * }).catch(function(err) { + * console.error(err); + * }); + * + * // Handle the operation using the event emitter pattern. + * client.createInspectOperation(request).then(function(responses) { + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Adding a listener for the "complete" event starts polling for the + * // completion of the operation. + * operation.on('complete', function(result, metadata, finalApiResponse) { + * // doSomethingWith(result); + * }); + * + * // Adding a listener for the "progress" event causes the callback to be + * // called on any change in metadata when the operation is polled. + * operation.on('progress', function(metadata, apiResponse) { + * // doSomethingWith(metadata) + * }) + * + * // Adding a listener for the "error" event handles any errors found during polling. + * operation.on('error', function(err) { + * // throw(err); + * }) * }).catch(function(err) { * console.error(err); * }); diff --git a/packages/dlp/test/gapic-v2beta1.js b/packages/dlp/test/test-v2beta1.js similarity index 88% rename from packages/dlp/test/gapic-v2beta1.js rename to packages/dlp/test/test-v2beta1.js index d5db5a66008..37a9540293c 100644 --- a/packages/dlp/test/gapic-v2beta1.js +++ b/packages/dlp/test/test-v2beta1.js @@ -131,19 +131,21 @@ describe('DlpServiceClient', function() { // Mock response var name = 'name3373707'; - var done = true; var expectedResponse = { - name : name, - done : done + name : name }; // Mock Grpc layer - client._createInspectOperation = mockSimpleGrpcMethod(request, expectedResponse); + client._createInspectOperation = mockLongRunningGrpcMethod(request, expectedResponse); - client.createInspectOperation(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); + client.createInspectOperation(request).then(function(responses) { + var operation = responses[0]; + return operation.promise(); + }).then(function(responses) { + assert.deepStrictEqual(responses[0], expectedResponse); done(); + }).catch(function(err) { + done(err); }); }); @@ -160,9 +162,14 @@ describe('DlpServiceClient', function() { }; // Mock Grpc layer - client._createInspectOperation = mockSimpleGrpcMethod(request, null, error); - - client.createInspectOperation(request, function(err, response) { + client._createInspectOperation = mockLongRunningGrpcMethod(request, null, error); + + client.createInspectOperation(request).then(function(responses) { + var operation = responses[0]; + return operation.promise(); + }).then(function(responses) { + assert.fail(); + }).catch(function(err) { assert(err instanceof Error); assert.equal(err.code, FAKE_STATUS_CODE); done(); @@ -314,3 +321,21 @@ function mockSimpleGrpcMethod(expectedRequest, response, error) { } }; } + +function mockLongRunningGrpcMethod(expectedRequest, response, error) { + return function(request) { + assert.deepStrictEqual(request, expectedRequest); + var mockOperation = { + promise: function() { + return new Promise(function(resolve, reject) { + if (error) { + reject(error) + } else { + resolve([response]); + } + }); + } + }; + return Promise.resolve([mockOperation]); + }; +} From 321317548953b980fe193202c83981a275a7581a Mon Sep 17 00:00:00 2001 From: Song Wang Date: Thu, 1 Jun 2017 18:05:17 -0700 Subject: [PATCH 09/12] Dlp (#2347) * Fix the long running operation method * fix lint error --- packages/dlp/test/gapic_v2beta1.js | 341 +++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 packages/dlp/test/gapic_v2beta1.js diff --git a/packages/dlp/test/gapic_v2beta1.js b/packages/dlp/test/gapic_v2beta1.js new file mode 100644 index 00000000000..af2b9a0e078 --- /dev/null +++ b/packages/dlp/test/gapic_v2beta1.js @@ -0,0 +1,341 @@ +/* + * Copyright 2017, Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +var assert = require('assert'); +var dlpV2beta1 = require('../src/v2beta1')(); + +var FAKE_STATUS_CODE = 1; +var error = new Error(); +error.code = FAKE_STATUS_CODE; +describe('DlpServiceClient', function() { + describe('inspectContent', function() { + it('invokes inspectContent without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var request = { + inspectConfig : inspectConfig, + items : items + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._inspectContent = mockSimpleGrpcMethod(request, expectedResponse); + + client.inspectContent(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes inspectContent with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var request = { + inspectConfig : inspectConfig, + items : items + }; + + // Mock Grpc layer + client._inspectContent = mockSimpleGrpcMethod(request, null, error); + + client.inspectContent(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('redactContent', function() { + it('invokes redactContent without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var replaceConfigs = []; + var request = { + inspectConfig : inspectConfig, + items : items, + replaceConfigs : replaceConfigs + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._redactContent = mockSimpleGrpcMethod(request, expectedResponse); + + client.redactContent(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes redactContent with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var items = []; + var replaceConfigs = []; + var request = { + inspectConfig : inspectConfig, + items : items, + replaceConfigs : replaceConfigs + }; + + // Mock Grpc layer + client._redactContent = mockSimpleGrpcMethod(request, null, error); + + client.redactContent(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('createInspectOperation', function() { + it('invokes createInspectOperation without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var storageConfig = {}; + var outputConfig = {}; + var request = { + inspectConfig : inspectConfig, + storageConfig : storageConfig, + outputConfig : outputConfig + }; + + // Mock response + var name = 'name3373707'; + var expectedResponse = { + name : name + }; + + // Mock Grpc layer + client._createInspectOperation = mockLongRunningGrpcMethod(request, expectedResponse); + + client.createInspectOperation(request).then(function(responses) { + var operation = responses[0]; + return operation.promise(); + }).then(function(responses) { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }).catch(function(err) { + done(err); + }); + }); + + it('invokes createInspectOperation with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var inspectConfig = {}; + var storageConfig = {}; + var outputConfig = {}; + var request = { + inspectConfig : inspectConfig, + storageConfig : storageConfig, + outputConfig : outputConfig + }; + + // Mock Grpc layer + client._createInspectOperation = mockLongRunningGrpcMethod(request, null, error); + + client.createInspectOperation(request).then(function(responses) { + var operation = responses[0]; + return operation.promise(); + }).then(function(responses) { + assert.fail(); + }).catch(function(err) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listInspectFindings', function() { + it('invokes listInspectFindings without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var formattedName = client.resultPath("[RESULT]"); + var request = { + name : formattedName + }; + + // Mock response + var nextPageToken = 'nextPageToken-1530815211'; + var expectedResponse = { + nextPageToken : nextPageToken + }; + + // Mock Grpc layer + client._listInspectFindings = mockSimpleGrpcMethod(request, expectedResponse); + + client.listInspectFindings(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listInspectFindings with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var formattedName = client.resultPath("[RESULT]"); + var request = { + name : formattedName + }; + + // Mock Grpc layer + client._listInspectFindings = mockSimpleGrpcMethod(request, null, error); + + client.listInspectFindings(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listInfoTypes', function() { + it('invokes listInfoTypes without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var category = 'category50511102'; + var languageCode = 'languageCode-412800396'; + var request = { + category : category, + languageCode : languageCode + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._listInfoTypes = mockSimpleGrpcMethod(request, expectedResponse); + + client.listInfoTypes(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listInfoTypes with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var category = 'category50511102'; + var languageCode = 'languageCode-412800396'; + var request = { + category : category, + languageCode : languageCode + }; + + // Mock Grpc layer + client._listInfoTypes = mockSimpleGrpcMethod(request, null, error); + + client.listInfoTypes(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + + describe('listRootCategories', function() { + it('invokes listRootCategories without error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var languageCode = 'languageCode-412800396'; + var request = { + languageCode : languageCode + }; + + // Mock response + var expectedResponse = {}; + + // Mock Grpc layer + client._listRootCategories = mockSimpleGrpcMethod(request, expectedResponse); + + client.listRootCategories(request, function(err, response) { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes listRootCategories with error', function(done) { + var client = dlpV2beta1.dlpServiceClient(); + // Mock request + var languageCode = 'languageCode-412800396'; + var request = { + languageCode : languageCode + }; + + // Mock Grpc layer + client._listRootCategories = mockSimpleGrpcMethod(request, null, error); + + client.listRootCategories(request, function(err, response) { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + +}); + +function mockSimpleGrpcMethod(expectedRequest, response, error) { + return function(actualRequest, options, callback) { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} + +function mockLongRunningGrpcMethod(expectedRequest, response, error) { + return function(request) { + assert.deepStrictEqual(request, expectedRequest); + var mockOperation = { + promise: function() { + return new Promise(function(resolve, reject) { + if (error) { + reject(error); + } else { + resolve([response]); + } + }); + } + }; + return Promise.resolve([mockOperation]); + }; +} From 5d442597d7fa7a2849c675998c0a298ad3da6f49 Mon Sep 17 00:00:00 2001 From: Song Wang Date: Thu, 1 Jun 2017 18:21:49 -0700 Subject: [PATCH 10/12] Revert "Dlp (#2347)" (#2348) This reverts commit 321317548953b980fe193202c83981a275a7581a. --- packages/dlp/test/gapic_v2beta1.js | 341 ----------------------------- 1 file changed, 341 deletions(-) delete mode 100644 packages/dlp/test/gapic_v2beta1.js diff --git a/packages/dlp/test/gapic_v2beta1.js b/packages/dlp/test/gapic_v2beta1.js deleted file mode 100644 index af2b9a0e078..00000000000 --- a/packages/dlp/test/gapic_v2beta1.js +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright 2017, Google Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -var assert = require('assert'); -var dlpV2beta1 = require('../src/v2beta1')(); - -var FAKE_STATUS_CODE = 1; -var error = new Error(); -error.code = FAKE_STATUS_CODE; -describe('DlpServiceClient', function() { - describe('inspectContent', function() { - it('invokes inspectContent without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var items = []; - var request = { - inspectConfig : inspectConfig, - items : items - }; - - // Mock response - var expectedResponse = {}; - - // Mock Grpc layer - client._inspectContent = mockSimpleGrpcMethod(request, expectedResponse); - - client.inspectContent(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes inspectContent with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var items = []; - var request = { - inspectConfig : inspectConfig, - items : items - }; - - // Mock Grpc layer - client._inspectContent = mockSimpleGrpcMethod(request, null, error); - - client.inspectContent(request, function(err, response) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - - describe('redactContent', function() { - it('invokes redactContent without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var items = []; - var replaceConfigs = []; - var request = { - inspectConfig : inspectConfig, - items : items, - replaceConfigs : replaceConfigs - }; - - // Mock response - var expectedResponse = {}; - - // Mock Grpc layer - client._redactContent = mockSimpleGrpcMethod(request, expectedResponse); - - client.redactContent(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes redactContent with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var items = []; - var replaceConfigs = []; - var request = { - inspectConfig : inspectConfig, - items : items, - replaceConfigs : replaceConfigs - }; - - // Mock Grpc layer - client._redactContent = mockSimpleGrpcMethod(request, null, error); - - client.redactContent(request, function(err, response) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - - describe('createInspectOperation', function() { - it('invokes createInspectOperation without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var storageConfig = {}; - var outputConfig = {}; - var request = { - inspectConfig : inspectConfig, - storageConfig : storageConfig, - outputConfig : outputConfig - }; - - // Mock response - var name = 'name3373707'; - var expectedResponse = { - name : name - }; - - // Mock Grpc layer - client._createInspectOperation = mockLongRunningGrpcMethod(request, expectedResponse); - - client.createInspectOperation(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }).catch(function(err) { - done(err); - }); - }); - - it('invokes createInspectOperation with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var inspectConfig = {}; - var storageConfig = {}; - var outputConfig = {}; - var request = { - inspectConfig : inspectConfig, - storageConfig : storageConfig, - outputConfig : outputConfig - }; - - // Mock Grpc layer - client._createInspectOperation = mockLongRunningGrpcMethod(request, null, error); - - client.createInspectOperation(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.fail(); - }).catch(function(err) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - - describe('listInspectFindings', function() { - it('invokes listInspectFindings without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var formattedName = client.resultPath("[RESULT]"); - var request = { - name : formattedName - }; - - // Mock response - var nextPageToken = 'nextPageToken-1530815211'; - var expectedResponse = { - nextPageToken : nextPageToken - }; - - // Mock Grpc layer - client._listInspectFindings = mockSimpleGrpcMethod(request, expectedResponse); - - client.listInspectFindings(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes listInspectFindings with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var formattedName = client.resultPath("[RESULT]"); - var request = { - name : formattedName - }; - - // Mock Grpc layer - client._listInspectFindings = mockSimpleGrpcMethod(request, null, error); - - client.listInspectFindings(request, function(err, response) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - - describe('listInfoTypes', function() { - it('invokes listInfoTypes without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var category = 'category50511102'; - var languageCode = 'languageCode-412800396'; - var request = { - category : category, - languageCode : languageCode - }; - - // Mock response - var expectedResponse = {}; - - // Mock Grpc layer - client._listInfoTypes = mockSimpleGrpcMethod(request, expectedResponse); - - client.listInfoTypes(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes listInfoTypes with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var category = 'category50511102'; - var languageCode = 'languageCode-412800396'; - var request = { - category : category, - languageCode : languageCode - }; - - // Mock Grpc layer - client._listInfoTypes = mockSimpleGrpcMethod(request, null, error); - - client.listInfoTypes(request, function(err, response) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - - describe('listRootCategories', function() { - it('invokes listRootCategories without error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var languageCode = 'languageCode-412800396'; - var request = { - languageCode : languageCode - }; - - // Mock response - var expectedResponse = {}; - - // Mock Grpc layer - client._listRootCategories = mockSimpleGrpcMethod(request, expectedResponse); - - client.listRootCategories(request, function(err, response) { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes listRootCategories with error', function(done) { - var client = dlpV2beta1.dlpServiceClient(); - // Mock request - var languageCode = 'languageCode-412800396'; - var request = { - languageCode : languageCode - }; - - // Mock Grpc layer - client._listRootCategories = mockSimpleGrpcMethod(request, null, error); - - client.listRootCategories(request, function(err, response) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - -}); - -function mockSimpleGrpcMethod(expectedRequest, response, error) { - return function(actualRequest, options, callback) { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} - -function mockLongRunningGrpcMethod(expectedRequest, response, error) { - return function(request) { - assert.deepStrictEqual(request, expectedRequest); - var mockOperation = { - promise: function() { - return new Promise(function(resolve, reject) { - if (error) { - reject(error); - } else { - resolve([response]); - } - }); - } - }; - return Promise.resolve([mockOperation]); - }; -} From d880a56b01363cac2f9f58c4819d187ae66e53aa Mon Sep 17 00:00:00 2001 From: Song Wang Date: Thu, 1 Jun 2017 18:29:58 -0700 Subject: [PATCH 11/12] fix git mistake --- packages/dlp/test/{test-v2beta1.js => gapic_v2beta1.js} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename packages/dlp/test/{test-v2beta1.js => gapic_v2beta1.js} (99%) diff --git a/packages/dlp/test/test-v2beta1.js b/packages/dlp/test/gapic_v2beta1.js similarity index 99% rename from packages/dlp/test/test-v2beta1.js rename to packages/dlp/test/gapic_v2beta1.js index 37a9540293c..af2b9a0e078 100644 --- a/packages/dlp/test/test-v2beta1.js +++ b/packages/dlp/test/gapic_v2beta1.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +'use strict'; var assert = require('assert'); var dlpV2beta1 = require('../src/v2beta1')(); @@ -20,7 +21,6 @@ var dlpV2beta1 = require('../src/v2beta1')(); var FAKE_STATUS_CODE = 1; var error = new Error(); error.code = FAKE_STATUS_CODE; - describe('DlpServiceClient', function() { describe('inspectContent', function() { it('invokes inspectContent without error', function(done) { @@ -329,7 +329,7 @@ function mockLongRunningGrpcMethod(expectedRequest, response, error) { promise: function() { return new Promise(function(resolve, reject) { if (error) { - reject(error) + reject(error); } else { resolve([response]); } From 554e3618c0973a0913f6fdcd484f89f484e46017 Mon Sep 17 00:00:00 2001 From: Song Wang Date: Fri, 2 Jun 2017 15:36:38 -0700 Subject: [PATCH 12/12] rename gapic_v2beta1.js to gapic-v2beta1.js --- packages/dlp/test/{gapic_v2beta1.js => gapic-v2beta1.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/dlp/test/{gapic_v2beta1.js => gapic-v2beta1.js} (100%) diff --git a/packages/dlp/test/gapic_v2beta1.js b/packages/dlp/test/gapic-v2beta1.js similarity index 100% rename from packages/dlp/test/gapic_v2beta1.js rename to packages/dlp/test/gapic-v2beta1.js