From 1614a8cd2b3d54e486ea52b17a90512ffecffbd3 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Fri, 20 Dec 2019 11:35:19 -0800 Subject: [PATCH 1/5] move code to typescript --- .jsdoc.js | 2 +- package.json | 43 +- src/index.js | 82 -- src/index.ts | 24 + src/{browser.js => v1beta1/index.ts} | 12 +- ...tcha_enterprise_service_v1_beta1_client.js | 861 ----------------- ...tcha_enterprise_service_v1_beta1_client.ts | 864 ++++++++++++++++++ ...rprise_service_v1_beta1_client_config.json | 28 +- synth.metadata | 216 ++++- system-test/.eslintrc.yml | 4 + .../{test.js => fixtures/sample/src/index.js} | 21 +- .../fixtures/sample/src/index.ts | 12 +- system-test/install.ts | 48 + ...cha_enterprise_service_v1_beta1-v1beta1.ts | 406 ++++++++ test/gapic-v1beta1.js | 525 ----------- tsconfig.json | 19 + tslint.json | 3 + webpack.config.js | 38 +- 18 files changed, 1677 insertions(+), 1531 deletions(-) delete mode 100644 src/index.js create mode 100644 src/index.ts rename src/{browser.js => v1beta1/index.ts} (65%) delete mode 100644 src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js create mode 100644 src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts create mode 100644 system-test/.eslintrc.yml rename system-test/{test.js => fixtures/sample/src/index.js} (50%) rename src/v1beta1/index.js => system-test/fixtures/sample/src/index.ts (58%) create mode 100644 system-test/install.ts create mode 100644 test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts delete mode 100644 test/gapic-v1beta1.js create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/.jsdoc.js b/.jsdoc.js index 51be5a4..78c206f 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -32,7 +32,7 @@ module.exports = { source: { excludePattern: '(^|\\/|\\\\)[._]', include: [ - 'src' + 'build/src' ], includePattern: '\\.js$' }, diff --git a/package.json b/package.json index 3f9efc3..bfbe7ec 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "version": "1.4.0", "author": "Google LLC", "description": "reCAPTCHA Enterprise API client for Node.js", - "main": "src/index.js", + "main": "build/src/index.js", "files": [ - "protos", - "src", + "build/protos", + "build/src", "AUTHORS", "COPYING" ], @@ -25,32 +25,45 @@ "reCAPTCHA Enterprise API" ], "dependencies": { - "google-gax": "^1.7.5" + "google-gax": "^1.9.0" }, "devDependencies": { + "@types/mocha": "^5.2.5", + "@types/node": "^12.0.0", + "c8": "^6.0.0", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", "eslint-plugin-node": "^10.0.0", "eslint-plugin-prettier": "^3.0.0", + "gts": "^1.0.0", + "intelli-espower-loader": "^1.0.1", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.1", "jsdoc-region-tag": "^1.0.2", "linkinator": "^1.5.0", - "mocha": "^6.0.0", - "nyc": "^14.1.1", - "prettier": "^1.17.1" + "mocha": "^6.1.4", + "null-loader": "^3.0.0", + "pack-n-play": "^1.0.0-2", + "power-assert": "^1.4.4", + "prettier": "^1.17.1", + "ts-loader": "^6.2.1", + "typescript": "^3.7.0", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" }, "scripts": { - "cover": "nyc --reporter=lcov mocha test/*.js && nyc report", + "lint": "gts fix && eslint --fix samples/*.js", + "fix": "gts fix", + "samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../", + "system-test": "mocha build/system-test", "docs": "jsdoc -c .jsdoc.js", - "lint": "eslint '**/*.js'", - "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", - "system-test": "mocha system-test/*.js --timeout 600000", - "test-no-cover": "mocha test/*.js", - "test": "npm run cover", - "fix": "eslint --fix '**/*.js'", + "test": "c8 mocha build/test", "docs-test": "linkinator docs", - "predocs-test": "npm run docs" + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "predocs-test": "npm run docs", + "prepare": "npm run compile" }, "license": "Apache-2.0", "engines": { diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 41b6dd0..0000000 --- a/src/index.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -/** - * @namespace google - */ -/** - * @namespace google.cloud - */ -/** - * @namespace google.protobuf - */ -/** - * @namespace google.cloud.recaptchaenterprise - */ -/** - * @namespace google.cloud.recaptchaenterprise.v1beta1 - */ - -'use strict'; - -// Import the clients for each version supported by this package. -const gapic = Object.freeze({ - v1beta1: require('./v1beta1'), -}); - -/** - * The `recaptchaenterprise` package has the following named exports: - * - * - `RecaptchaEnterpriseServiceV1Beta1Client` - Reference to - * {@link v1beta1.RecaptchaEnterpriseServiceV1Beta1Client} - * - `v1beta1` - This is used for selecting or pinning a - * particular backend service version. It exports: - * - `RecaptchaEnterpriseServiceV1Beta1Client` - Reference to - * {@link v1beta1.RecaptchaEnterpriseServiceV1Beta1Client} - * - * @module {object} recaptchaenterprise - * @alias nodejs-recaptchaenterprise - * - * @example Install the client library with npm: - * npm install --save recaptchaenterprise - * - * @example Import the client library: - * const recaptchaenterprise = require('recaptchaenterprise'); - * - * @example Create a client that uses Application Default Credentials (ADC): - * const client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); - * - * @example Create a client with explicit credentials: - * const client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client({ - * projectId: 'your-project-id', - * keyFilename: '/path/to/keyfile.json', - * }); - */ - -/** - * @type {object} - * @property {constructor} RecaptchaEnterpriseServiceV1Beta1Client - * Reference to {@link v1beta1.RecaptchaEnterpriseServiceV1Beta1Client} - */ -module.exports = gapic.v1beta1; - -/** - * @type {object} - * @property {constructor} RecaptchaEnterpriseServiceV1Beta1Client - * Reference to {@link v1beta1.RecaptchaEnterpriseServiceV1Beta1Client} - */ -module.exports.v1beta1 = gapic.v1beta1; - -// Alias `module.exports` as `module.exports.default`, for future-proofing. -module.exports.default = Object.assign({}, module.exports); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..cfe8daf --- /dev/null +++ b/src/index.ts @@ -0,0 +1,24 @@ +// Copyright 2019 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +// For compatibility with JavaScript libraries we need to provide this default export: +// tslint:disable-next-line no-default-export +export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; diff --git a/src/browser.js b/src/v1beta1/index.ts similarity index 65% rename from src/browser.js rename to src/v1beta1/index.ts index ddbcd7e..879b003 100644 --- a/src/browser.js +++ b/src/v1beta1/index.ts @@ -11,11 +11,9 @@ // 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** -'use strict'; - -// Set a flag that we are running in a browser bundle. -global.isBrowser = true; - -// Re-export all exports from ./index.js. -module.exports = require('./index'); +export {RecaptchaEnterpriseServiceV1Beta1Client} from './recaptcha_enterprise_service_v1_beta1_client'; diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js deleted file mode 100644 index 6b2bb5b..0000000 --- a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js +++ /dev/null @@ -1,861 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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'; - -const gapicConfig = require('./recaptcha_enterprise_service_v1_beta1_client_config.json'); -const gax = require('google-gax'); -const path = require('path'); - -const VERSION = require('../../package.json').version; - -/** - * Service to determine the likelihood an event is legitimate. - * - * @class - * @memberof v1beta1 - */ -class RecaptchaEnterpriseServiceV1Beta1Client { - /** - * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - constructor(opts) { - opts = opts || {}; - this._descriptors = {}; - - if (global.isBrowser) { - // If we're in browser, we use gRPC fallback. - opts.fallback = true; - } - - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !global.isBrowser && opts.fallback ? gax.fallback : gax; - - const servicePath = - opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; - - // Ensure that options include the service address and port. - opts = Object.assign( - { - clientConfig: {}, - port: this.constructor.port, - servicePath, - }, - opts - ); - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = this.constructor.scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; - - // Determine the client header string. - const clientHeader = []; - - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } - clientHeader.push(`gax/${gaxModule.version}`); - if (opts.fallback) { - clientHeader.push(`gl-web/${gaxModule.version}`); - } else { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - clientHeader.push(`gapic/${VERSION}`); - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - const protos = gaxGrpc.loadProto( - opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath - ); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this._pathTemplates = { - assessmentPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/assessments/{assessment}' - ), - keyPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/keys/{key}' - ), - projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this._descriptors.page = { - listKeys: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'keys' - ), - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', - gapicConfig, - opts.clientConfig, - {'x-goog-api-client': clientHeader.join(' ')} - ); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. - const recaptchaEnterpriseServiceV1Beta1Stub = gaxGrpc.createStub( - opts.fallback - ? protos.lookupService( - 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1' - ) - : protos.google.cloud.recaptchaenterprise.v1beta1 - .RecaptchaEnterpriseServiceV1Beta1, - opts - ); - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const recaptchaEnterpriseServiceV1Beta1StubMethods = [ - 'createAssessment', - 'annotateAssessment', - 'createKey', - 'listKeys', - 'getKey', - 'updateKey', - 'deleteKey', - ]; - for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { - const innerCallPromise = recaptchaEnterpriseServiceV1Beta1Stub.then( - stub => (...args) => { - return stub[methodName].apply(stub, args); - }, - err => () => { - throw err; - } - ); - this._innerApiCalls[methodName] = gaxModule.createApiCall( - innerCallPromise, - defaults[methodName], - this._descriptors.page[methodName] - ); - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return ['https://www.googleapis.com/auth/cloud-platform']; - } - - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback) { - return this.auth.getProjectId(callback); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Creates an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - * @param {Object} request.assessment - * Required. The assessment details. - * - * This object should have the same structure as [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment} - * @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/interfaces/CallOptions.html} 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 [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.projectPath('[PROJECT]'); - * const assessment = {}; - * const request = { - * parent: formattedParent, - * assessment: assessment, - * }; - * client.createAssessment(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - createAssessment(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent, - }); - - return this._innerApiCalls.createAssessment(request, options, callback); - } - - /** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fradulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - * @param {number} request.annotation - * Required. The annotation that will be assigned to the Event. - * - * The number should be among the values of [Annotation]{@link google.cloud.recaptchaenterprise.v1beta1.Annotation} - * @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/interfaces/CallOptions.html} 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 [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedName = client.assessmentPath('[PROJECT]', '[ASSESSMENT]'); - * const annotation = 'ANNOTATION_UNSPECIFIED'; - * const request = { - * name: formattedName, - * annotation: annotation, - * }; - * client.annotateAssessment(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - annotateAssessment(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name, - }); - - return this._innerApiCalls.annotateAssessment(request, options, callback); - } - - /** - * Creates a new reCAPTCHA Enterprise key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project_number}". - * @param {Object} request.key - * Required. Information to create a reCAPTCHA Enterprise key. - * - * This object should have the same structure as [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} - * @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/interfaces/CallOptions.html} 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 [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.projectPath('[PROJECT]'); - * const key = {}; - * const request = { - * parent: formattedParent, - * key: key, - * }; - * client.createKey(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - createKey(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent, - }); - - return this._innerApiCalls.createKey(request, options, callback); - } - - /** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @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/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.projectPath('[PROJECT]'); - * - * client.listKeys({parent: formattedParent}) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.projectPath('[PROJECT]'); - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listKeys(nextRequest, options).then(callback); - * } - * } - * client.listKeys({parent: formattedParent}, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listKeys(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent, - }); - - return this._innerApiCalls.listKeys(request, options, callback); - } - - /** - * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listKeys} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @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/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.projectPath('[PROJECT]'); - * client.listKeysStream({parent: formattedParent}) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listKeysStream(request, options) { - options = options || {}; - - return this._descriptors.page.listKeys.createStream( - this._innerApiCalls.listKeys, - request, - options - ); - } - - /** - * Returns the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested key, in the format - * "projects/{project_number}/keys/{key_id}". - * @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/interfaces/CallOptions.html} 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 [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - * client.getKey({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getKey(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name, - }); - - return this._innerApiCalls.getKey(request, options, callback); - } - - /** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {Object} request.key - * Required. The key to update. - * - * This object should have the same structure as [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} - * @param {Object} [request.updateMask] - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - * - * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} - * @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/interfaces/CallOptions.html} 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 [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const key = {}; - * client.updateKey({key: key}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - updateKey(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'key.name': request.key.name, - }); - - return this._innerApiCalls.updateKey(request, options, callback); - } - - /** - * Deletes the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be deleted, in the format - * "projects/{project_number}/keys/{key_id}". - * @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/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const recaptchaenterprise = require('@google-cloud/recaptchaenterprise'); - * - * const client = new recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - * // optional auth parameters. - * }); - * - * const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - * client.deleteKey({name: formattedName}).catch(err => { - * console.error(err); - * }); - */ - deleteKey(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name, - }); - - return this._innerApiCalls.deleteKey(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified assessment resource name string. - * - * @param {String} project - * @param {String} assessment - * @returns {String} - */ - assessmentPath(project, assessment) { - return this._pathTemplates.assessmentPathTemplate.render({ - project: project, - assessment: assessment, - }); - } - - /** - * Return a fully-qualified key resource name string. - * - * @param {String} project - * @param {String} key - * @returns {String} - */ - keyPath(project, key) { - return this._pathTemplates.keyPathTemplate.render({ - project: project, - key: key, - }); - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {String} project - * @returns {String} - */ - projectPath(project) { - return this._pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the assessmentName from a assessment resource. - * - * @param {String} assessmentName - * A fully-qualified path representing a assessment resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromAssessmentName(assessmentName) { - return this._pathTemplates.assessmentPathTemplate.match(assessmentName) - .project; - } - - /** - * Parse the assessmentName from a assessment resource. - * - * @param {String} assessmentName - * A fully-qualified path representing a assessment resources. - * @returns {String} - A string representing the assessment. - */ - matchAssessmentFromAssessmentName(assessmentName) { - return this._pathTemplates.assessmentPathTemplate.match(assessmentName) - .assessment; - } - - /** - * Parse the keyName from a key resource. - * - * @param {String} keyName - * A fully-qualified path representing a key resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromKeyName(keyName) { - return this._pathTemplates.keyPathTemplate.match(keyName).project; - } - - /** - * Parse the keyName from a key resource. - * - * @param {String} keyName - * A fully-qualified path representing a key resources. - * @returns {String} - A string representing the key. - */ - matchKeyFromKeyName(keyName) { - return this._pathTemplates.keyPathTemplate.match(keyName).key; - } - - /** - * Parse the projectName from a project resource. - * - * @param {String} projectName - * A fully-qualified path representing a project resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromProjectName(projectName) { - return this._pathTemplates.projectPathTemplate.match(projectName).project; - } -} - -module.exports = RecaptchaEnterpriseServiceV1Beta1Client; diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts new file mode 100644 index 0000000..40e2707 --- /dev/null +++ b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -0,0 +1,864 @@ +// Copyright 2019 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import * as path from 'path'; + +import { Transform } from 'stream'; +import * as protosTypes from '../../protos/protos'; +import * as gapicConfig from './recaptcha_enterprise_service_v1_beta1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service to determine the likelihood an event is legitimate. + * @class + * @memberof v1beta1 + */ +export class RecaptchaEnterpriseServiceV1Beta1Client { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + recaptchaEnterpriseServiceV1Beta1Stub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + opts.clientConfig = opts.clientConfig || {}; + + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ + opts.fallback = true; + } + // If we are in browser, we are already using fallback because of the + // "browser" field in package.json. + // But if we were explicitly requested to use fallback, let's do it now. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = (gaxGrpc.auth as gax.GoogleAuth); + + // Determine the client header string. + const clientHeader = [ + `gax/${gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const protos = gaxGrpc.loadProto( + opts.fallback ? + require("../../protos/protos.json") : + nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + projectPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}' + ), + assessmentPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/assessments/{assessment}' + ), + keyPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/keys/{key}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this._descriptors.page = { + listKeys: + new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. + this.recaptchaEnterpriseServiceV1Beta1Stub = gaxGrpc.createStub( + opts.fallback ? + (protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : + // tslint:disable-next-line no-any + (protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, + opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const recaptchaEnterpriseServiceV1Beta1StubMethods = + ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; + + for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { + const innerCallPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.then( + stub => (...args: Array<{}>) => { + return stub[methodName].apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>; + createAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, + {}|undefined>): void; +/** + * Creates an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment + * Required. The assessment details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + return this._innerApiCalls.createAssessment(request, options, callback); + } + annotateAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>; + annotateAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, + {}|undefined>): void; +/** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fradulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} request.annotation + * Required. The annotation that will be assigned to the Event. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + annotateAssessment( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.annotateAssessment(request, options, callback); + } + createKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined + ]>; + createKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, + {}|undefined>): void; +/** + * Creates a new reCAPTCHA Enterprise key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the key will be created, in the + * format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. Information to create a reCAPTCHA Enterprise key. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + return this._innerApiCalls.createKey(request, options, callback); + } + getKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined + ]>; + getKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, + {}|undefined>): void; +/** + * Returns the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested key, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.getKey(request, options, callback); + } + updateKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined + ]>; + updateKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, + {}|undefined>): void; +/** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. The key to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The mask to control which field of the key get updated. If the mask is not + * present, all fields will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'key_name': request.key!.name || '', + }); + return this._innerApiCalls.updateKey(request, options, callback); + } + deleteKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined + ]>; + deleteKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, + {}|undefined>): void; +/** + * Deletes the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be deleted, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteKey( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined>, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, + {}|undefined>): + Promise<[ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + return this._innerApiCalls.deleteKey(request, options, callback); + } + + listKeys( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ]>; + listKeys( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>): void; +/** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listKeys( + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>): + Promise<[ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ]>|void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + return this._innerApiCalls.listKeys(request, options, callback); + } + +/** + * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listKeys} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. + */ + listKeysStream( + request?: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions | {}): + Transform{ + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listKeys.createStream( + this._innerApiCalls.listKeys as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this._pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this._pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified assessment resource name string. + * + * @param {string} project + * @param {string} assessment + * @returns {string} Resource name string. + */ + assessmentPath(project:string,assessment:string) { + return this._pathTemplates.assessmentPathTemplate.render({ + project: project, + assessment: assessment, + }); + } + + /** + * Parse the project from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAssessmentName(assessmentName: string) { + return this._pathTemplates.assessmentPathTemplate.match(assessmentName).project; + } + + /** + * Parse the assessment from Assessment resource. + * + * @param {string} assessmentName + * A fully-qualified path representing Assessment resource. + * @returns {string} A string representing the assessment. + */ + matchAssessmentFromAssessmentName(assessmentName: string) { + return this._pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + } + + /** + * Return a fully-qualified key resource name string. + * + * @param {string} project + * @param {string} key + * @returns {string} Resource name string. + */ + keyPath(project:string,key:string) { + return this._pathTemplates.keyPathTemplate.render({ + project: project, + key: key, + }); + } + + /** + * Parse the project from Key resource. + * + * @param {string} keyName + * A fully-qualified path representing Key resource. + * @returns {string} A string representing the project. + */ + matchProjectFromKeyName(keyName: string) { + return this._pathTemplates.keyPathTemplate.match(keyName).project; + } + + /** + * Parse the key from Key resource. + * + * @param {string} keyName + * A fully-qualified path representing Key resource. + * @returns {string} A string representing the key. + */ + matchKeyFromKeyName(keyName: string) { + return this._pathTemplates.keyPathTemplate.match(keyName).key; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.recaptchaEnterpriseServiceV1Beta1Stub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json index 3aa1afa..726aae1 100644 --- a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json +++ b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json @@ -2,56 +2,56 @@ "interfaces": { "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1": { "retry_codes": { + "non_idempotent": [], "idempotent": [ "DEADLINE_EXCEEDED", "UNAVAILABLE" - ], - "non_idempotent": [] + ] }, "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, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, "total_timeout_millis": 600000 } }, "methods": { "CreateAssessment": { - "timeout_millis": 60000, + "timeout_millis": 600000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "AnnotateAssessment": { - "timeout_millis": 60000, + "timeout_millis": 600000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "CreateKey": { - "timeout_millis": 60000, + "timeout_millis": 600000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "ListKeys": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "GetKey": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "UpdateKey": { - "timeout_millis": 60000, + "timeout_millis": 600000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "DeleteKey": { - "timeout_millis": 60000, + "timeout_millis": 600000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" } diff --git a/synth.metadata b/synth.metadata index 2f9c267..7b86102 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-12-03T12:19:56.567157Z", + "updateTime": "2019-12-20T18:52:38.278342Z", "sources": [ { "generator": { "name": "artman", - "version": "0.42.1", - "dockerImage": "googleapis/artman@sha256:c773192618c608a7a0415dd95282f841f8e6bcdef7dd760a988c93b77a64bd57" + "version": "0.42.3", + "dockerImage": "googleapis/artman@sha256:feed210b5723c6f524b52ef6d7740a030f2d1a8f7c29a71c5e5b4481ceaad7f5" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "38dc36a2a43cbab4a2a9183a43dd0441670098a9", - "internalRef": "283384331" + "sha": "5f3f1d0f1c06b6475a17d995e4f7a436ca67ec9e", + "internalRef": "286598440" } }, { @@ -35,5 +35,211 @@ "config": "google/cloud/recaptchaenterprise/artman_recaptchaenterprise_v1beta1.yaml" } } + ], + "newFiles": [ + { + "path": "CODE_OF_CONDUCT.md" + }, + { + "path": ".eslintrc.yml" + }, + { + "path": "LICENSE" + }, + { + "path": "codecov.yaml" + }, + { + "path": "renovate.json" + }, + { + "path": "webpack.config.js" + }, + { + "path": ".jsdoc.js" + }, + { + "path": ".prettierignore" + }, + { + "path": "README.md" + }, + { + "path": "CONTRIBUTING.md" + }, + { + "path": ".prettierrc" + }, + { + "path": ".eslintignore" + }, + { + "path": ".nycrc" + }, + { + "path": "protos/protos.d.ts" + }, + { + "path": "protos/protos.json" + }, + { + "path": "protos/protos.js" + }, + { + "path": "protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" + }, + { + "path": "test/gapic-v1beta1.js" + }, + { + "path": "__pycache__/synth.cpython-36.pyc" + }, + { + "path": "samples/README.md" + }, + { + "path": ".github/PULL_REQUEST_TEMPLATE.md" + }, + { + "path": ".github/release-please.yml" + }, + { + "path": ".github/ISSUE_TEMPLATE/feature_request.md" + }, + { + "path": ".github/ISSUE_TEMPLATE/bug_report.md" + }, + { + "path": ".github/ISSUE_TEMPLATE/support_request.md" + }, + { + "path": ".kokoro/test.bat" + }, + { + "path": ".kokoro/system-test.sh" + }, + { + "path": ".kokoro/trampoline.sh" + }, + { + "path": ".kokoro/samples-test.sh" + }, + { + "path": ".kokoro/publish.sh" + }, + { + "path": ".kokoro/lint.sh" + }, + { + "path": ".kokoro/common.cfg" + }, + { + "path": ".kokoro/test.sh" + }, + { + "path": ".kokoro/docs.sh" + }, + { + "path": ".kokoro/release/docs.cfg" + }, + { + "path": ".kokoro/release/publish.cfg" + }, + { + "path": ".kokoro/release/docs.sh" + }, + { + "path": ".kokoro/presubmit/node10/system-test.cfg" + }, + { + "path": ".kokoro/presubmit/node10/samples-test.cfg" + }, + { + "path": ".kokoro/presubmit/node10/test.cfg" + }, + { + "path": ".kokoro/presubmit/node10/docs.cfg" + }, + { + "path": ".kokoro/presubmit/node10/common.cfg" + }, + { + "path": ".kokoro/presubmit/node10/lint.cfg" + }, + { + "path": ".kokoro/presubmit/node8/test.cfg" + }, + { + "path": ".kokoro/presubmit/node8/common.cfg" + }, + { + "path": ".kokoro/presubmit/node12/test.cfg" + }, + { + "path": ".kokoro/presubmit/node12/common.cfg" + }, + { + "path": ".kokoro/presubmit/windows/test.cfg" + }, + { + "path": ".kokoro/presubmit/windows/common.cfg" + }, + { + "path": ".kokoro/continuous/node10/system-test.cfg" + }, + { + "path": ".kokoro/continuous/node10/samples-test.cfg" + }, + { + "path": ".kokoro/continuous/node10/test.cfg" + }, + { + "path": ".kokoro/continuous/node10/docs.cfg" + }, + { + "path": ".kokoro/continuous/node10/common.cfg" + }, + { + "path": ".kokoro/continuous/node10/lint.cfg" + }, + { + "path": ".kokoro/continuous/node8/test.cfg" + }, + { + "path": ".kokoro/continuous/node8/common.cfg" + }, + { + "path": ".kokoro/continuous/node12/test.cfg" + }, + { + "path": ".kokoro/continuous/node12/common.cfg" + }, + { + "path": "src/browser.js" + }, + { + "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json" + }, + { + "path": "src/v1beta1/index.js" + }, + { + "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js" + }, + { + "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json" + }, + { + "path": "src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js" + }, + { + "path": "src/v1beta1/doc/google/protobuf/doc_empty.js" + }, + { + "path": "src/v1beta1/doc/google/protobuf/doc_field_mask.js" + }, + { + "path": "src/v1beta1/doc/google/protobuf/doc_timestamp.js" + } ] } \ No newline at end of file diff --git a/system-test/.eslintrc.yml b/system-test/.eslintrc.yml new file mode 100644 index 0000000..dc5d9b0 --- /dev/null +++ b/system-test/.eslintrc.yml @@ -0,0 +1,4 @@ +--- +env: + mocha: true + diff --git a/system-test/test.js b/system-test/fixtures/sample/src/index.js similarity index 50% rename from system-test/test.js rename to system-test/fixtures/sample/src/index.js index ddc5feb..3d40ab8 100644 --- a/system-test/test.js +++ b/system-test/fixtures/sample/src/index.js @@ -4,19 +4,24 @@ // 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 +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); -'use strict'; +function main() { + const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); +} -describe('RecaptchaEnterpriseSystemTest', () => { - it('creates a client', async () => { - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('../'); - new RecaptchaEnterpriseServiceV1Beta1Client(); - }); -}); +main(); diff --git a/src/v1beta1/index.js b/system-test/fixtures/sample/src/index.ts similarity index 58% rename from src/v1beta1/index.js rename to system-test/fixtures/sample/src/index.ts index 69dd8e4..3f81a94 100644 --- a/src/v1beta1/index.js +++ b/system-test/fixtures/sample/src/index.ts @@ -11,9 +11,15 @@ // 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** -'use strict'; +import {RecaptchaEnterpriseServiceV1Beta1Client} from '@google-cloud/recaptcha-enterprise'; -const RecaptchaEnterpriseServiceV1Beta1Client = require('./recaptcha_enterprise_service_v1_beta1_client'); +function main() { + const recaptchaEnterpriseServiceV1Beta1Client = new RecaptchaEnterpriseServiceV1Beta1Client(); +} -module.exports.RecaptchaEnterpriseServiceV1Beta1Client = RecaptchaEnterpriseServiceV1Beta1Client; +main(); diff --git a/system-test/install.ts b/system-test/install.ts new file mode 100644 index 0000000..51fd2b4 --- /dev/null +++ b/system-test/install.ts @@ -0,0 +1,48 @@ +// Copyright 2019 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; + +describe('typescript consumer tests', () => { + + it('should have correct type signature for typescript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + +}); diff --git a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts new file mode 100644 index 0000000..9557219 --- /dev/null +++ b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts @@ -0,0 +1,406 @@ +// Copyright 2019 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protosTypes from '../protos/protos'; +import * as assert from 'assert'; +const recaptchaenterpriseservicev1beta1Module = require('../src'); + + +const FAKE_STATUS_CODE = 1; +class FakeError{ + name: string; + message: string; + code: number; + constructor(n: number){ + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError|null, response?: {} | null): void; +} + +export class Operation{ + constructor(){}; + promise() {}; +} +function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { + it('has servicePath', () => { + const servicePath = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + describe('createAssessment', () => { + it('invokes createAssessment without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createAssessment(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createAssessment with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createAssessment(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.annotateAssessment(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes annotateAssessment with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( + request, + null, + error + ); + client.annotateAssessment(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('createKey', () => { + it('invokes createKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes createKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('getKey', () => { + it('invokes getKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes getKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('updateKey', () => { + it('invokes updateKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; + request.key = {}; + request.key.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes updateKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; + request.key = {}; + request.key.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('deleteKey', () => { + it('invokes deleteKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + }); + + it('invokes deleteKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }) + }); + }); + describe('listKeys', () => { + it('invokes listKeys without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listKeys = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listKeys(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listKeysStream', () => { + it('invokes listKeysStream without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listKeys = (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client.listKeysStream(request, {}).on('data', (response: {}) =>{ + assert.deepStrictEqual(response, expectedResponse); + done(); + }).on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); + }); + }); +}); diff --git a/test/gapic-v1beta1.js b/test/gapic-v1beta1.js deleted file mode 100644 index 7d5edb6..0000000 --- a/test/gapic-v1beta1.js +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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'; - -const assert = require('assert'); - -const recaptchaenterpriseModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -const error = new Error(); -error.code = FAKE_STATUS_CODE; - -describe('RecaptchaEnterpriseServiceV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = - recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client - .servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client - .apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = - recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client - .port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no options', () => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - {fallback: true} - ); - assert(client); - }); - - describe('createAssessment', () => { - it('invokes createAssessment without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const assessment = {}; - const request = { - parent: formattedParent, - assessment: assessment, - }; - - // Mock response - const name = 'name3373707'; - const score = 1.0926453e7; - const expectedResponse = { - name: name, - score: score, - }; - - // Mock Grpc layer - client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.createAssessment(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createAssessment with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const assessment = {}; - const request = { - parent: formattedParent, - assessment: assessment, - }; - - // Mock Grpc layer - client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.createAssessment(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.assessmentPath('[PROJECT]', '[ASSESSMENT]'); - const annotation = 'ANNOTATION_UNSPECIFIED'; - const request = { - name: formattedName, - annotation: annotation, - }; - - // Mock response - const expectedResponse = {}; - - // Mock Grpc layer - client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.annotateAssessment(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes annotateAssessment with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.assessmentPath('[PROJECT]', '[ASSESSMENT]'); - const annotation = 'ANNOTATION_UNSPECIFIED'; - const request = { - name: formattedName, - annotation: annotation, - }; - - // Mock Grpc layer - client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.annotateAssessment(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('createKey', () => { - it('invokes createKey without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const key = {}; - const request = { - parent: formattedParent, - key: key, - }; - - // Mock response - const name = 'name3373707'; - const displayName = 'displayName1615086568'; - const expectedResponse = { - name: name, - displayName: displayName, - }; - - // Mock Grpc layer - client._innerApiCalls.createKey = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.createKey(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createKey with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const key = {}; - const request = { - parent: formattedParent, - key: key, - }; - - // Mock Grpc layer - client._innerApiCalls.createKey = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.createKey(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('listKeys', () => { - it('invokes listKeys without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const request = { - parent: formattedParent, - }; - - // Mock response - const nextPageToken = ''; - const keysElement = {}; - const keys = [keysElement]; - const expectedResponse = { - nextPageToken: nextPageToken, - keys: keys, - }; - - // Mock Grpc layer - client._innerApiCalls.listKeys = (actualRequest, options, callback) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.keys); - }; - - client.listKeys(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.keys); - done(); - }); - }); - - it('invokes listKeys with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedParent = client.projectPath('[PROJECT]'); - const request = { - parent: formattedParent, - }; - - // Mock Grpc layer - client._innerApiCalls.listKeys = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.listKeys(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('getKey', () => { - it('invokes getKey without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - const request = { - name: formattedName, - }; - - // Mock response - const name2 = 'name2-1052831874'; - const displayName = 'displayName1615086568'; - const expectedResponse = { - name: name2, - displayName: displayName, - }; - - // Mock Grpc layer - client._innerApiCalls.getKey = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.getKey(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getKey with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.getKey = mockSimpleGrpcMethod(request, null, error); - - client.getKey(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('updateKey', () => { - it('invokes updateKey without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const key = {}; - const request = { - key: key, - }; - - // Mock response - const name = 'name3373707'; - const displayName = 'displayName1615086568'; - const expectedResponse = { - name: name, - displayName: displayName, - }; - - // Mock Grpc layer - client._innerApiCalls.updateKey = mockSimpleGrpcMethod( - request, - expectedResponse - ); - - client.updateKey(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateKey with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const key = {}; - const request = { - key: key, - }; - - // Mock Grpc layer - client._innerApiCalls.updateKey = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.updateKey(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('deleteKey', () => { - it('invokes deleteKey without error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.deleteKey = mockSimpleGrpcMethod(request); - - client.deleteKey(request, err => { - assert.ifError(err); - done(); - }); - }); - - it('invokes deleteKey with error', done => { - const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( - { - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - } - ); - - // Mock request - const formattedName = client.keyPath('[PROJECT]', '[KEY]'); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.deleteKey(request, err => { - assert(err instanceof Error); - assert.strictEqual(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); - } - }; -} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..613d355 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2016", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..617dc97 --- /dev/null +++ b/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "gts/tslint.json" +} diff --git a/webpack.config.js b/webpack.config.js index 3eb4643..d49627b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +const path = require('path'); + module.exports = { - entry: './src/browser.js', + entry: './src/index.ts', output: { - library: 'recaptchaenterprise', - filename: './recaptchaenterprise.js', + library: 'RecaptchaEnterpriseServiceV1Beta1', + filename: './recaptcha-enterprise-service-v1-beta1.js', }, node: { child_process: 'empty', @@ -24,21 +26,37 @@ module.exports = { crypto: 'empty', }, resolve: { - extensions: ['.js', '.json'], + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], }, module: { rules: [ { - test: /node_modules[\\/]retry-request[\\/]/, - use: 'null-loader', + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' }, { - test: /node_modules[\\/]https-proxy-agent[\\/]/, - use: 'null-loader', + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' }, { - test: /node_modules[\\/]gtoken[\\/]/, - use: 'null-loader', + test: /node_modules[\\/]gtoken/, + use: 'null-loader' }, ], }, From 8b849933867bebc29a503b6be932fadd6b16739e Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Fri, 20 Dec 2019 13:56:54 -0800 Subject: [PATCH 2/5] run synthtool --- protos/google/cloud/common_resources.proto | 52 + src/index.ts | 24 - .../v1beta1/doc_recaptchaenterprise.js | 550 ---------- src/v1beta1/doc/google/protobuf/doc_empty.js | 34 - .../doc/google/protobuf/doc_field_mask.js | 228 ----- .../doc/google/protobuf/doc_timestamp.js | 119 --- ...tcha_enterprise_service_v1_beta1_client.ts | 965 ++++++++++-------- synth.metadata | 143 ++- synth.py | 19 +- system-test/install.ts | 26 +- ...cha_enterprise_service_v1_beta1-v1beta1.ts | 760 +++++++------- 11 files changed, 1158 insertions(+), 1762 deletions(-) create mode 100644 protos/google/cloud/common_resources.proto delete mode 100644 src/index.ts delete mode 100644 src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js delete mode 100644 src/v1beta1/doc/google/protobuf/doc_empty.js delete mode 100644 src/v1beta1/doc/google/protobuf/doc_field_mask.js delete mode 100644 src/v1beta1/doc/google/protobuf/doc_timestamp.js diff --git a/protos/google/cloud/common_resources.proto b/protos/google/cloud/common_resources.proto new file mode 100644 index 0000000..56c9f80 --- /dev/null +++ b/protos/google/cloud/common_resources.proto @@ -0,0 +1,52 @@ +// Copyright 2019 Google LLC. +// +// 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. + +// This file contains stub messages for common resources in GCP. +// It is not intended to be directly generated, and is instead used by +// other tooling to be able to match common resource patterns. +syntax = "proto3"; + +package google.cloud; + +import "google/api/resource.proto"; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" +}; + + +option (google.api.resource_definition) = { + type: "cloudbilling.googleapis.com/BillingAccount" + pattern: "billingAccounts/{billing_account}" +}; + +option (google.api.resource_definition) = { + type: "locations.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index cfe8daf..0000000 --- a/src/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; -export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; -// For compatibility with JavaScript libraries we need to provide this default export: -// tslint:disable-next-line no-default-export -export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; diff --git a/src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js b/src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js deleted file mode 100644 index d91ccbb..0000000 --- a/src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js +++ /dev/null @@ -1,550 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The create assessment request message. - * - * @property {string} parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - * - * @property {Object} assessment - * Required. The assessment details. - * - * This object should have the same structure as [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment} - * - * @typedef CreateAssessmentRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const CreateAssessmentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request message to annotate an Assessment. - * - * @property {string} name - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - * - * @property {number} annotation - * Required. The annotation that will be assigned to the Event. - * - * The number should be among the values of [Annotation]{@link google.cloud.recaptchaenterprise.v1beta1.Annotation} - * - * @typedef AnnotateAssessmentRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const AnnotateAssessmentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * Enum that reprensents the types of annotations. - * - * @enum {number} - * @memberof google.cloud.recaptchaenterprise.v1beta1 - */ - Annotation: { - - /** - * Default unspecified type. - */ - ANNOTATION_UNSPECIFIED: 0, - - /** - * Provides information that the event turned out to be legitimate. - */ - LEGITIMATE: 1, - - /** - * Provides information that the event turned out to be fraudulent. - */ - FRAUDULENT: 2 - } -}; - -/** - * Empty response for AnnotateAssessment. - * @typedef AnnotateAssessmentResponse - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const AnnotateAssessmentResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A recaptcha assessment resource. - * - * @property {string} name - * Output only. The resource name for the Assessment in the format - * "projects/{project_number}/assessments/{assessment_id}". - * - * @property {Object} event - * The event being assessed. - * - * This object should have the same structure as [Event]{@link google.cloud.recaptchaenterprise.v1beta1.Event} - * - * @property {number} score - * Output only. Legitimate event score from 0.0 to 1.0. - * (1.0 means very likely legitimate traffic while 0.0 means very likely - * non-legitimate traffic). - * - * @property {Object} tokenProperties - * Output only. Properties of the provided event token. - * - * This object should have the same structure as [TokenProperties]{@link google.cloud.recaptchaenterprise.v1beta1.TokenProperties} - * - * @property {number[]} reasons - * Output only. Reasons contributing to the risk analysis verdict. - * - * The number should be among the values of [ClassificationReason]{@link google.cloud.recaptchaenterprise.v1beta1.ClassificationReason} - * - * @typedef Assessment - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.Assessment definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const Assessment = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * LINT.IfChange(classification_reason) - * Reasons contributing to the risk analysis verdict. - * - * @enum {number} - * @memberof google.cloud.recaptchaenterprise.v1beta1 - */ - ClassificationReason: { - - /** - * Default unspecified type. - */ - CLASSIFICATION_REASON_UNSPECIFIED: 0, - - /** - * Interactions matched the behavior of an automated agent. - */ - AUTOMATION: 1, - - /** - * The event originated from an illegitimate environment. - */ - UNEXPECTED_ENVIRONMENT: 2, - - /** - * Traffic volume from the event source is higher than normal. - */ - TOO_MUCH_TRAFFIC: 3, - - /** - * Interactions with the site were significantly different than expected - * patterns. - */ - UNEXPECTED_USAGE_PATTERNS: 4, - - /** - * Too little traffic has been received from this site thus far to generate - * quality risk analysis. - */ - LOW_CONFIDENCE_SCORE: 5 - } -}; - -/** - * @property {string} token - * Optional. The user response token provided by the reCAPTCHA client-side integration - * on your site. - * - * @property {string} siteKey - * Optional. The site key that was used to invoke reCAPTCHA on your site and generate - * the token. - * - * @property {string} userAgent - * Optional. The user agent present in the request from the user's device related to - * this event. - * - * @property {string} userIpAddress - * Optional. The IP address in the request from the user's device related to this event. - * - * @property {string} expectedAction - * Optional. The expected action for this type of event. This should be the same action - * provided at token generation time on client-side platforms already - * integrated with recaptcha enterprise. - * - * @typedef Event - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.Event definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const Event = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * @property {boolean} valid - * Whether the provided user response token is valid. - * - * @property {number} invalidReason - * Reason associated with the response when valid = false. - * - * The number should be among the values of [InvalidReason]{@link google.cloud.recaptchaenterprise.v1beta1.InvalidReason} - * - * @property {Object} createTime - * The timestamp corresponding to the generation of the token. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {string} hostname - * The hostname of the page on which the token was generated. - * - * @property {string} action - * Action name provided at token generation. - * - * @typedef TokenProperties - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.TokenProperties definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const TokenProperties = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * LINT.IfChange - * Enum that represents the types of invalid token reasons. - * - * @enum {number} - * @memberof google.cloud.recaptchaenterprise.v1beta1 - */ - InvalidReason: { - - /** - * Default unspecified type. - */ - INVALID_REASON_UNSPECIFIED: 0, - - /** - * If the failure reason was not accounted for. - */ - UNKNOWN_INVALID_REASON: 1, - - /** - * The provided user verification token was malformed. - */ - MALFORMED: 2, - - /** - * The user verification token had expired. - */ - EXPIRED: 3, - - /** - * The user verification had already been seen. - */ - DUPE: 4, - - /** - * The user verification token did not match the provided site key. - * This may be a configuration error (e.g. development keys used in - * production) or end users trying to use verification tokens from other - * sites. - */ - SITE_MISMATCH: 5, - - /** - * The user verification token was not present. It is a required input. - */ - MISSING: 6 - } -}; - -/** - * The create key request message. - * - * @property {string} parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project_number}". - * - * @property {Object} key - * Required. Information to create a reCAPTCHA Enterprise key. - * - * This object should have the same structure as [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} - * - * @typedef CreateKeyRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const CreateKeyRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The list keys request message. - * - * @property {string} parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * - * @property {number} pageSize - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * - * @property {string} pageToken - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * - * @typedef ListKeysRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const ListKeysRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * Response to request to list keys in a project. - * - * @property {Object[]} keys - * Key details. - * - * This object should have the same structure as [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} - * - * @property {string} nextPageToken - * Token to retrieve the next page of results. It is set to empty if no keys - * remain in results. - * - * @typedef ListKeysResponse - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const ListKeysResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The get key request message. - * - * @property {string} name - * Required. The name of the requested key, in the format - * "projects/{project_number}/keys/{key_id}". - * - * @typedef GetKeyRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const GetKeyRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The update key request message. - * - * @property {Object} key - * Required. The key to update. - * - * This object should have the same structure as [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} - * - * @property {Object} updateMask - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - * - * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} - * - * @typedef UpdateKeyRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const UpdateKeyRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The delete key request message. - * - * @property {string} name - * Required. The name of the key to be deleted, in the format - * "projects/{project_number}/keys/{key_id}". - * - * @typedef DeleteKeyRequest - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const DeleteKeyRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A key used to identify and configure applications (web and/or mobile) that - * use reCAPTCHA Enterprise. - * - * @property {string} name - * The resource name for the Key in the format - * "projects/{project_number}/keys/{key_id}". - * - * @property {string} displayName - * Human-readable display name of this key. Modifiable by user. - * - * @property {Object} webSettings - * Settings for keys that can be used by websites. - * - * This object should have the same structure as [WebKeySettings]{@link google.cloud.recaptchaenterprise.v1beta1.WebKeySettings} - * - * @property {Object} androidSettings - * Settings for keys that can be used by Android apps. - * - * This object should have the same structure as [AndroidKeySettings]{@link google.cloud.recaptchaenterprise.v1beta1.AndroidKeySettings} - * - * @property {Object} iosSettings - * Settings for keys that can be used by iOS apps. - * - * This object should have the same structure as [IOSKeySettings]{@link google.cloud.recaptchaenterprise.v1beta1.IOSKeySettings} - * - * @typedef Key - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.Key definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const Key = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * Settings specific to keys that can be used by websites. - * - * @property {boolean} enforceAllowedDomains - * Whether allowed_domains is enforced or not. - * - * @property {string[]} allowedDomains - * Domains or subdomains of websites allowed to use the key. All subdomains - * of an allowed domain are automatically allowed. A valid domain requires a - * host and must not include any path, port, query or fragment. - * Examples: 'example.com' or 'subdomain.example.com' - * - * @property {boolean} allowAmpTraffic - * Whether this key can be used on AMP (Accelerated Mobile Pages) websites. - * - * @property {number} integrationType - * Required. Describes how this key is integrated with the website. - * - * The number should be among the values of [IntegrationType]{@link google.cloud.recaptchaenterprise.v1beta1.IntegrationType} - * - * @property {number} challengeSecurityPreference - * Settings for the frequency and difficulty at which this key triggers - * captcha challenges. This should only be specified for IntegrationTypes - * CHECKBOX_CHALLENGE and INVISIBLE_CHALLENGE. - * - * The number should be among the values of [ChallengeSecurityPreference]{@link google.cloud.recaptchaenterprise.v1beta1.ChallengeSecurityPreference} - * - * @typedef WebKeySettings - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.WebKeySettings definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const WebKeySettings = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * Enum that represents the possible challenge frequency and difficulty - * configurations for a web key. - * - * @enum {number} - * @memberof google.cloud.recaptchaenterprise.v1beta1 - */ - ChallengeSecurityPreference: { - - /** - * Default type that indicates this enum hasn't been specified. - */ - CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED: 0, - - /** - * Key tends to show fewer and easier challenges. - */ - USABILITY: 1, - - /** - * Key tends to show balanced (in amount and difficulty) challenges. - */ - BALANCED: 2, - - /** - * Key tends to show more and harder challenges. - */ - SECURITY: 3 - }, - - /** - * Enum that represents the integration types for web keys. - * - * @enum {number} - * @memberof google.cloud.recaptchaenterprise.v1beta1 - */ - IntegrationType: { - - /** - * Default type that indicates this enum hasn't been specified. This is not - * a valid IntegrationType, one of the other types must be specified - * instead. - */ - INTEGRATION_TYPE_UNSPECIFIED: 0, - - /** - * Only used to produce scores. It doesn't display the "I'm not a robot" - * checkbox and never shows captcha challenges. - */ - SCORE_ONLY: 1, - - /** - * Displays the "I'm not a robot" checkbox and may show captcha challenges - * after it is checked. - */ - CHECKBOX_CHALLENGE: 2, - - /** - * Doesn't display the "I'm not a robot" checkbox, but may show captcha - * challenges after risk analysis. - */ - INVISIBLE_CHALLENGE: 3 - } -}; - -/** - * Settings specific to keys that can be used by Android apps. - * - * @property {string[]} allowedPackageNames - * Android package names of apps allowed to use the key. - * Example: 'com.companyname.appname' - * - * @typedef AndroidKeySettings - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.AndroidKeySettings definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const AndroidKeySettings = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * Settings specific to keys that can be used by iOS apps. - * - * @property {string[]} allowedBundleIds - * iOS bundle ids of apps allowed to use the key. - * Example: 'com.companyname.productname.appname' - * - * @typedef IOSKeySettings - * @memberof google.cloud.recaptchaenterprise.v1beta1 - * @see [google.cloud.recaptchaenterprise.v1beta1.IOSKeySettings definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto} - */ -const IOSKeySettings = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; \ No newline at end of file diff --git a/src/v1beta1/doc/google/protobuf/doc_empty.js b/src/v1beta1/doc/google/protobuf/doc_empty.js deleted file mode 100644 index 0b446dd..0000000 --- a/src/v1beta1/doc/google/protobuf/doc_empty.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A generic empty message that you can re-use to avoid defining duplicated - * empty messages in your APIs. A typical example is to use it as the request - * or the response type of an API method. For instance: - * - * service Foo { - * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); - * } - * - * The JSON representation for `Empty` is empty JSON object `{}`. - * @typedef Empty - * @memberof google.protobuf - * @see [google.protobuf.Empty definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/empty.proto} - */ -const Empty = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; \ No newline at end of file diff --git a/src/v1beta1/doc/google/protobuf/doc_field_mask.js b/src/v1beta1/doc/google/protobuf/doc_field_mask.js deleted file mode 100644 index 011207b..0000000 --- a/src/v1beta1/doc/google/protobuf/doc_field_mask.js +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * `FieldMask` represents a set of symbolic field paths, for example: - * - * paths: "f.a" - * paths: "f.b.d" - * - * Here `f` represents a field in some root message, `a` and `b` - * fields in the message found in `f`, and `d` a field found in the - * message in `f.b`. - * - * Field masks are used to specify a subset of fields that should be - * returned by a get operation or modified by an update operation. - * Field masks also have a custom JSON encoding (see below). - * - * # Field Masks in Projections - * - * When used in the context of a projection, a response message or - * sub-message is filtered by the API to only contain those fields as - * specified in the mask. For example, if the mask in the previous - * example is applied to a response message as follows: - * - * f { - * a : 22 - * b { - * d : 1 - * x : 2 - * } - * y : 13 - * } - * z: 8 - * - * The result will not contain specific values for fields x,y and z - * (their value will be set to the default, and omitted in proto text - * output): - * - * - * f { - * a : 22 - * b { - * d : 1 - * } - * } - * - * A repeated field is not allowed except at the last position of a - * paths string. - * - * If a FieldMask object is not present in a get operation, the - * operation applies to all fields (as if a FieldMask of all fields - * had been specified). - * - * Note that a field mask does not necessarily apply to the - * top-level response message. In case of a REST get operation, the - * field mask applies directly to the response, but in case of a REST - * list operation, the mask instead applies to each individual message - * in the returned resource list. In case of a REST custom method, - * other definitions may be used. Where the mask applies will be - * clearly documented together with its declaration in the API. In - * any case, the effect on the returned resource/resources is required - * behavior for APIs. - * - * # Field Masks in Update Operations - * - * A field mask in update operations specifies which fields of the - * targeted resource are going to be updated. The API is required - * to only change the values of the fields as specified in the mask - * and leave the others untouched. If a resource is passed in to - * describe the updated values, the API ignores the values of all - * fields not covered by the mask. - * - * If a repeated field is specified for an update operation, new values will - * be appended to the existing repeated field in the target resource. Note that - * a repeated field is only allowed in the last position of a `paths` string. - * - * If a sub-message is specified in the last position of the field mask for an - * update operation, then new value will be merged into the existing sub-message - * in the target resource. - * - * For example, given the target message: - * - * f { - * b { - * d: 1 - * x: 2 - * } - * c: [1] - * } - * - * And an update message: - * - * f { - * b { - * d: 10 - * } - * c: [2] - * } - * - * then if the field mask is: - * - * paths: ["f.b", "f.c"] - * - * then the result will be: - * - * f { - * b { - * d: 10 - * x: 2 - * } - * c: [1, 2] - * } - * - * An implementation may provide options to override this default behavior for - * repeated and message fields. - * - * In order to reset a field's value to the default, the field must - * be in the mask and set to the default value in the provided resource. - * Hence, in order to reset all fields of a resource, provide a default - * instance of the resource and set all fields in the mask, or do - * not provide a mask as described below. - * - * If a field mask is not present on update, the operation applies to - * all fields (as if a field mask of all fields has been specified). - * Note that in the presence of schema evolution, this may mean that - * fields the client does not know and has therefore not filled into - * the request will be reset to their default. If this is unwanted - * behavior, a specific service may require a client to always specify - * a field mask, producing an error if not. - * - * As with get operations, the location of the resource which - * describes the updated values in the request message depends on the - * operation kind. In any case, the effect of the field mask is - * required to be honored by the API. - * - * ## Considerations for HTTP REST - * - * The HTTP kind of an update operation which uses a field mask must - * be set to PATCH instead of PUT in order to satisfy HTTP semantics - * (PUT must only be used for full updates). - * - * # JSON Encoding of Field Masks - * - * In JSON, a field mask is encoded as a single string where paths are - * separated by a comma. Fields name in each path are converted - * to/from lower-camel naming conventions. - * - * As an example, consider the following message declarations: - * - * message Profile { - * User user = 1; - * Photo photo = 2; - * } - * message User { - * string display_name = 1; - * string address = 2; - * } - * - * In proto a field mask for `Profile` may look as such: - * - * mask { - * paths: "user.display_name" - * paths: "photo" - * } - * - * In JSON, the same mask is represented as below: - * - * { - * mask: "user.displayName,photo" - * } - * - * # Field Masks and Oneof Fields - * - * Field masks treat fields in oneofs just as regular fields. Consider the - * following message: - * - * message SampleMessage { - * oneof test_oneof { - * string name = 4; - * SubMessage sub_message = 9; - * } - * } - * - * The field mask can be: - * - * mask { - * paths: "name" - * } - * - * Or: - * - * mask { - * paths: "sub_message" - * } - * - * Note that oneof type names ("test_oneof" in this case) cannot be used in - * paths. - * - * ## Field Mask Verification - * - * The implementation of any API method which has a FieldMask type field in the - * request should verify the included field paths, and return an - * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. - * - * @property {string[]} paths - * The set of field mask paths. - * - * @typedef FieldMask - * @memberof google.protobuf - * @see [google.protobuf.FieldMask definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/field_mask.proto} - */ -const FieldMask = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; \ No newline at end of file diff --git a/src/v1beta1/doc/google/protobuf/doc_timestamp.js b/src/v1beta1/doc/google/protobuf/doc_timestamp.js deleted file mode 100644 index 3bc1e98..0000000 --- a/src/v1beta1/doc/google/protobuf/doc_timestamp.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2019 Google LLC -// -// 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Timestamp represents a point in time independent of any time zone or local - * calendar, encoded as a count of seconds and fractions of seconds at - * nanosecond resolution. The count is relative to an epoch at UTC midnight on - * January 1, 1970, in the proleptic Gregorian calendar which extends the - * Gregorian calendar backwards to year one. - * - * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap - * second table is needed for interpretation, using a [24-hour linear - * smear](https://developers.google.com/time/smear). - * - * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By - * restricting to that range, we ensure that we can convert to and from [RFC - * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. - * - * # Examples - * - * Example 1: Compute Timestamp from POSIX `time()`. - * - * Timestamp timestamp; - * timestamp.set_seconds(time(NULL)); - * timestamp.set_nanos(0); - * - * Example 2: Compute Timestamp from POSIX `gettimeofday()`. - * - * struct timeval tv; - * gettimeofday(&tv, NULL); - * - * Timestamp timestamp; - * timestamp.set_seconds(tv.tv_sec); - * timestamp.set_nanos(tv.tv_usec * 1000); - * - * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. - * - * FILETIME ft; - * GetSystemTimeAsFileTime(&ft); - * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; - * - * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z - * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. - * Timestamp timestamp; - * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); - * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); - * - * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. - * - * long millis = System.currentTimeMillis(); - * - * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) - * .setNanos((int) ((millis % 1000) * 1000000)).build(); - * - * - * Example 5: Compute Timestamp from current time in Python. - * - * timestamp = Timestamp() - * timestamp.GetCurrentTime() - * - * # JSON Mapping - * - * In JSON format, the Timestamp type is encoded as a string in the - * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the - * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" - * where {year} is always expressed using four digits while {month}, {day}, - * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional - * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), - * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone - * is required. A proto3 JSON serializer should always use UTC (as indicated by - * "Z") when printing the Timestamp type and a proto3 JSON parser should be - * able to accept both UTC and other timezones (as indicated by an offset). - * - * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past - * 01:30 UTC on January 15, 2017. - * - * In JavaScript, one can convert a Date object to this format using the - * standard - * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) - * method. In Python, a standard `datetime.datetime` object can be converted - * to this format using - * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with - * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use - * the Joda Time's [`ISODateTimeFormat.dateTime()`](https://cloud.google.com - * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D - * ) to obtain a formatter capable of generating timestamps in this format. - * - * @property {number} seconds - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. - * - * @property {number} nanos - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 - * inclusive. - * - * @typedef Timestamp - * @memberof google.protobuf - * @see [google.protobuf.Timestamp definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto} - */ -const Timestamp = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; \ No newline at end of file diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index 40e2707..22bd220 100644 --- a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -17,10 +17,18 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax'; +import { + APICallback, + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + PaginationResponse, +} from 'google-gax'; import * as path from 'path'; -import { Transform } from 'stream'; +import {Transform} from 'stream'; import * as protosTypes from '../../protos/protos'; import * as gapicConfig from './recaptcha_enterprise_service_v1_beta1_client_config.json'; @@ -69,11 +77,14 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const staticMembers = this + .constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -83,8 +94,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -94,17 +105,15 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. - opts.scopes = (this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client).scopes; + opts.scopes = (this + .constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client).scopes; const gaxGrpc = new gaxModule.GrpcClient(opts); // Save the auth object to the client, for use by other methods. - this.auth = (gaxGrpc.auth as gax.GoogleAuth); + this.auth = gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -120,20 +129,22 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); const protos = gaxGrpc.loadProto( - opts.fallback ? - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}' - ), + projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'), assessmentPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/assessments/{assessment}' ), @@ -146,14 +157,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listKeys: - new gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + listKeys: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'keys' + ), }; // Put together the default options sent with requests. const defaults = gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -163,32 +180,44 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // Put together the "service stub" for // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. this.recaptchaEnterpriseServiceV1Beta1Stub = gaxGrpc.createStub( - opts.fallback ? - (protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : - // tslint:disable-next-line no-any - (protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, - opts) as Promise<{[method: string]: Function}>; + opts.fallback + ? (protos as protobuf.Root).lookupService( + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1' + ) + : // tslint:disable-next-line no-any + (protos as any).google.cloud.recaptchaenterprise.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1, + opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const recaptchaEnterpriseServiceV1Beta1StubMethods = - ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; + const recaptchaEnterpriseServiceV1Beta1StubMethods = [ + 'createAssessment', + 'annotateAssessment', + 'createKey', + 'listKeys', + 'getKey', + 'updateKey', + 'deleteKey', + ]; for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { const innerCallPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.then( stub => (...args: Array<{}>) => { return stub[methodName].apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = gaxModule.createApiCall( innerCallPromise, defaults[methodName], this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] ); this._innerApiCalls[methodName] = ( @@ -196,10 +225,10 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { callOptions?: CallOptions, callback?: APICallback ) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - return apiCall(argument, callOptions, callback); + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return apiCall(argument, callOptions, callback); }; } } @@ -231,9 +260,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -243,8 +270,9 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -256,55 +284,76 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // -- Service calls -- // ------------------- createAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; createAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, - {}|undefined>): void; -/** - * Creates an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment - * Required. The assessment details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined, + {} | undefined + > + ): void; + /** + * Creates an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment + * Required. The assessment details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -313,61 +362,82 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); return this._innerApiCalls.createAssessment(request, options, callback); } annotateAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; annotateAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, - {}|undefined>): void; -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fradulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} request.annotation - * Required. The annotation that will be assigned to the Event. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined, + {} | undefined + > + ): void; + /** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fradulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} request.annotation + * Required. The annotation that will be assigned to the Event. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ annotateAssessment( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined>, - callback?: Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -376,60 +446,81 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); return this._innerApiCalls.annotateAssessment(request, options, callback); } createKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined + ), + {} | undefined + ] + >; createKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, - {}|undefined>): void; -/** - * Creates a new reCAPTCHA Enterprise key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project_number}". - * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key - * Required. Information to create a reCAPTCHA Enterprise key. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined, + {} | undefined + > + ): void; + /** + * Creates a new reCAPTCHA Enterprise key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the key will be created, in the + * format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. Information to create a reCAPTCHA Enterprise key. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined>, - callback?: Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -438,58 +529,79 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); return this._innerApiCalls.createKey(request, options, callback); } getKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined + ), + {} | undefined + ] + >; getKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, - {}|undefined>): void; -/** - * Returns the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested key, in the format - * "projects/{project_number}/keys/{key_id}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined, + {} | undefined + > + ): void; + /** + * Returns the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested key, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined>, - callback?: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -498,60 +610,81 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); return this._innerApiCalls.getKey(request, options, callback); } updateKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined + ), + {} | undefined + ] + >; updateKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, - {}|undefined>): void; -/** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key - * Required. The key to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined, + {} | undefined + > + ): void; + /** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. The key to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The mask to control which field of the key get updated. If the mask is not + * present, all fields will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined>, - callback?: Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -560,58 +693,79 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'key_name': request.key!.name || '', + key_name: request.key!.name || '', }); return this._innerApiCalls.updateKey(request, options, callback); } deleteKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined + ), + {} | undefined + ] + >; deleteKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, - {}|undefined>): void; -/** - * Deletes the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be deleted, in the format - * "projects/{project_number}/keys/{key_id}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.protobuf.IEmpty, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined, + {} | undefined + > + ): void; + /** + * Deletes the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be deleted, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteKey( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined>, - callback?: Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.protobuf.IEmpty, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, - {}|undefined>): - Promise<[ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + ( + | protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -620,80 +774,89 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); return this._innerApiCalls.deleteKey(request, options, callback); } listKeys( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: gax.CallOptions): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>; + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ] + >; listKeys( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options: gax.CallOptions, - callback: Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>): void; -/** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options: gax.CallOptions, + callback: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + > + ): void; + /** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ listKeys( - request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>, - callback?: Callback< + request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse>): - Promise<[ - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>|void { + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + >, + callback?: Callback< + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + > + ): Promise< + [ + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -702,45 +865,45 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); return this._innerApiCalls.listKeys(request, options, callback); - } + } -/** - * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listKeys} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. - */ + /** + * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listKeys} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. + */ listKeysStream( - request?: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: gax.CallOptions | {}): - Transform{ - request = request || {}; + request?: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; const callSettings = new gax.CallSettings(options); return this._descriptors.page.listKeys.createStream( this._innerApiCalls.listKeys as gax.GaxCall, @@ -758,9 +921,9 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this._pathTemplates.projectPathTemplate.render({ - project: project, + project, }); } @@ -782,10 +945,10 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} assessment * @returns {string} Resource name string. */ - assessmentPath(project:string,assessment:string) { + assessmentPath(project: string, assessment: string) { return this._pathTemplates.assessmentPathTemplate.render({ - project: project, - assessment: assessment, + project, + assessment, }); } @@ -797,7 +960,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @returns {string} A string representing the project. */ matchProjectFromAssessmentName(assessmentName: string) { - return this._pathTemplates.assessmentPathTemplate.match(assessmentName).project; + return this._pathTemplates.assessmentPathTemplate.match(assessmentName) + .project; } /** @@ -808,7 +972,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @returns {string} A string representing the assessment. */ matchAssessmentFromAssessmentName(assessmentName: string) { - return this._pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + return this._pathTemplates.assessmentPathTemplate.match(assessmentName) + .assessment; } /** @@ -818,10 +983,10 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} key * @returns {string} Resource name string. */ - keyPath(project:string,key:string) { + keyPath(project: string, key: string) { return this._pathTemplates.keyPathTemplate.render({ - project: project, - key: key, + project, + key, }); } diff --git a/synth.metadata b/synth.metadata index 7b86102..077c4a5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,19 +1,12 @@ { - "updateTime": "2019-12-20T18:52:38.278342Z", + "updateTime": "2019-12-20T21:54:20.405024Z", "sources": [ - { - "generator": { - "name": "artman", - "version": "0.42.3", - "dockerImage": "googleapis/artman@sha256:feed210b5723c6f524b52ef6d7740a030f2d1a8f7c29a71c5e5b4481ceaad7f5" - } - }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "5f3f1d0f1c06b6475a17d995e4f7a436ca67ec9e", - "internalRef": "286598440" + "sha": "1a380ea21dea9b6ac6ad28c60ad96d9d73574e19", + "internalRef": "286616241" } }, { @@ -30,9 +23,8 @@ "source": "googleapis", "apiName": "recaptchaenterprise", "apiVersion": "v1beta1", - "language": "nodejs", - "generator": "gapic", - "config": "google/cloud/recaptchaenterprise/artman_recaptchaenterprise_v1beta1.yaml" + "language": "typescript", + "generator": "gapic-generator-typescript" } } ], @@ -64,18 +56,30 @@ { "path": "README.md" }, + { + "path": "package-lock.json" + }, + { + "path": "tslint.json" + }, { "path": "CONTRIBUTING.md" }, { "path": ".prettierrc" }, + { + "path": "tsconfig.json" + }, { "path": ".eslintignore" }, { "path": ".nycrc" }, + { + "path": "linkinator.config.json" + }, { "path": "protos/protos.d.ts" }, @@ -85,14 +89,26 @@ { "path": "protos/protos.js" }, + { + "path": "protos/google/cloud/common_resources.proto" + }, { "path": "protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" }, { - "path": "test/gapic-v1beta1.js" + "path": "test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts" + }, + { + "path": "system-test/.eslintrc.yml" + }, + { + "path": "system-test/install.ts" + }, + { + "path": "system-test/fixtures/sample/src/index.js" }, { - "path": "__pycache__/synth.cpython-36.pyc" + "path": "system-test/fixtures/sample/src/index.ts" }, { "path": "samples/README.md" @@ -112,6 +128,84 @@ { "path": ".github/ISSUE_TEMPLATE/support_request.md" }, + { + "path": "build/protos/.DS_Store" + }, + { + "path": "build/protos/protos.d.ts" + }, + { + "path": "build/protos/protos.json" + }, + { + "path": "build/protos/protos.js" + }, + { + "path": "build/protos/google/.DS_Store" + }, + { + "path": "build/protos/google/cloud/.DS_Store" + }, + { + "path": "build/protos/google/cloud/common_resources.proto" + }, + { + "path": "build/protos/google/cloud/recaptchaenterprise/.DS_Store" + }, + { + "path": "build/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" + }, + { + "path": "build/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.d.ts" + }, + { + "path": "build/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.js.map" + }, + { + "path": "build/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.js" + }, + { + "path": "build/system-test/install.js.map" + }, + { + "path": "build/system-test/install.js" + }, + { + "path": "build/system-test/install.d.ts" + }, + { + "path": "build/src/index.js" + }, + { + "path": "build/src/index.js.map" + }, + { + "path": "build/src/index.d.ts" + }, + { + "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.d.ts" + }, + { + "path": "build/src/v1beta1/index.js" + }, + { + "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js" + }, + { + "path": "build/src/v1beta1/index.js.map" + }, + { + "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js.map" + }, + { + "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json" + }, + { + "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.d.ts" + }, + { + "path": "build/src/v1beta1/index.d.ts" + }, { "path": ".kokoro/test.bat" }, @@ -214,32 +308,17 @@ { "path": ".kokoro/continuous/node12/common.cfg" }, - { - "path": "src/browser.js" - }, { "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json" }, { - "path": "src/v1beta1/index.js" + "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts" }, { - "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js" + "path": "src/v1beta1/index.ts" }, { "path": "src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json" - }, - { - "path": "src/v1beta1/doc/google/cloud/recaptchaenterprise/v1beta1/doc_recaptchaenterprise.js" - }, - { - "path": "src/v1beta1/doc/google/protobuf/doc_empty.js" - }, - { - "path": "src/v1beta1/doc/google/protobuf/doc_field_mask.js" - }, - { - "path": "src/v1beta1/doc/google/protobuf/doc_timestamp.js" } ] } \ No newline at end of file diff --git a/synth.py b/synth.py index 36abf19..d6e84fe 100644 --- a/synth.py +++ b/synth.py @@ -21,19 +21,26 @@ logging.basicConfig(level=logging.DEBUG) # run the gapic generator -gapic = gcp.GAPICGenerator() +gapic = gcp.GAPICMicrogenerator() versions = ['v1beta1'] for version in versions: - library = gapic.node_library( - 'recaptchaenterprise', - version) - s.copy(library, excludes=['package.json', 'src/index.js']) + library = gapic.typescript_library( + 'recaptchaenterprise', version, + generator_args={ + "grpc-service-config": f"google/cloud/recaptchaenterprise/{version}/recaptchaenterprise_grpc_service_config.json", + "package-name": f"@google-cloud/recaptcha-enterprise", + }, + proto_path=f'/google/cloud/recaptchaenterprise/{version}', + extra_proto_files=['google/cloud/common_resources.proto'] + ) + s.copy(library, excludes=['package.json', 'src/index.ts']) # Copy common templates common_templates = gcp.CommonTemplates() -templates = common_templates.node_library() +templates = common_templates.node_library(source_location='build/src') s.copy(templates) # Node.js specific cleanup subprocess.run(['npm', 'install']) subprocess.run(['npm', 'run', 'fix']) +subprocess.run(['npx', 'compileProtos', 'src']) diff --git a/system-test/install.ts b/system-test/install.ts index 51fd2b4..2736aee 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -16,33 +16,35 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; describe('typescript consumer tests', () => { - it('should have correct type signature for typescript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); it('should have correct type signature for javascript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.js' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - }); diff --git a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts index 9557219..5971213 100644 --- a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts +++ b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts @@ -20,387 +20,433 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; const recaptchaenterpriseservicev1beta1Module = require('../src'); - const FAKE_STATUS_CODE = 1; -class FakeError{ - name: string; - message: string; - code: number; - constructor(n: number){ - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } +class FakeError { + name: string; + message: string; + code: number; + constructor(n: number) { + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } } const error = new FakeError(FAKE_STATUS_CODE); export interface Callback { - (err: FakeError|null, response?: {} | null): void; + (err: FakeError | null, response?: {} | null): void; } -export class Operation{ - constructor(){}; - promise() {}; +export class Operation { + constructor() {} + promise() {} } -function mockSimpleGrpcMethod(expectedRequest: {}, response: {} | null, error: FakeError | null) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; +function mockSimpleGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; } describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + fallback: true, + } + ); + assert(client); + }); + describe('createAssessment', () => { + it('invokes createAssessment without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createAssessment(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); + + it('invokes createAssessment with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createAssessment(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); }); - it('should create a client with no option', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - fallback: true, - }); - assert(client); + }); + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.annotateAssessment(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('createAssessment', () => { - it('invokes createAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createAssessment(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - it('invokes createAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createAssessment = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createAssessment(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + it('invokes annotateAssessment with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( + request, + null, + error + ); + client.annotateAssessment(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); }); - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.annotateAssessment(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - - it('invokes annotateAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.annotateAssessment = mockSimpleGrpcMethod( - request, - null, - error - ); - client.annotateAssessment(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + }); + describe('createKey', () => { + it('invokes createKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('createKey', () => { - it('invokes createKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createKey = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createKey(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - it('invokes createKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createKey = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createKey(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + it('invokes createKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('getKey', () => { + it('invokes getKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('getKey', () => { - it('invokes getKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getKey = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getKey(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - it('invokes getKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getKey = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getKey(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + it('invokes getKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getKey = mockSimpleGrpcMethod(request, null, error); + client.getKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('updateKey', () => { + it('invokes updateKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; + request.key = {}; + request.key.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.updateKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('updateKey', () => { - it('invokes updateKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; - request.key = {}; - request.key.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateKey = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateKey(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - it('invokes updateKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; - request.key = {}; - request.key.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateKey = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateKey(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + it('invokes updateKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest = {}; + request.key = {}; + request.key.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.updateKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('deleteKey', () => { + it('invokes deleteKey without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteKey(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('deleteKey', () => { - it('invokes deleteKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteKey(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - }); - it('invokes deleteKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteKey(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }) - }); + it('invokes deleteKey with error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteKey = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteKey(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); }); - describe('listKeys', () => { - it('invokes listKeys without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listKeys = (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listKeys(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); + }); + describe('listKeys', () => { + it('invokes listKeys without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listKeys = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listKeys(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); }); - describe('listKeysStream', () => { - it('invokes listKeysStream without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listKeys = (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client.listKeysStream(request, {}).on('data', (response: {}) =>{ - assert.deepStrictEqual(response, expectedResponse); - done(); - }).on('error', (err: FakeError) => { - done(err); - }); - stream.write(request); + }); + describe('listKeysStream', () => { + it('invokes listKeysStream without error', done => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + // Mock request + const request: protosTypes.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listKeys = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client + .listKeysStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); }); + stream.write(request); }); + }); }); From 96eeceef84a00055a9ecbac2d0e03cd28a892bfd Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Fri, 20 Dec 2019 15:10:47 -0800 Subject: [PATCH 3/5] fix test --- synth.metadata | 41 +++++++++++++------ system-test/.eslintrc | 3 -- system-test/.eslintrc.yml | 4 -- ...cha_enterprise_service_v1_beta1-v1beta1.ts | 40 +++++++++--------- 4 files changed, 48 insertions(+), 40 deletions(-) delete mode 100644 system-test/.eslintrc delete mode 100644 system-test/.eslintrc.yml diff --git a/synth.metadata b/synth.metadata index 077c4a5..8b6a68b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-12-20T21:54:20.405024Z", + "updateTime": "2019-12-20T22:54:08.115964Z", "sources": [ { "git": { @@ -56,9 +56,6 @@ { "path": "README.md" }, - { - "path": "package-lock.json" - }, { "path": "tslint.json" }, @@ -110,6 +107,33 @@ { "path": "system-test/fixtures/sample/src/index.ts" }, + { + "path": "node_modules/protobufjs/cli/package-lock.json" + }, + { + "path": "node_modules/protobufjs/cli/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/acorn/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/minimist/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/semver/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/acorn-jsx/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/package.json" + }, + { + "path": "node_modules/protobufjs/cli/node_modules/espree/package.json" + }, + { + "path": "__pycache__/synth.cpython-36.pyc" + }, { "path": "samples/README.md" }, @@ -173,15 +197,6 @@ { "path": "build/system-test/install.d.ts" }, - { - "path": "build/src/index.js" - }, - { - "path": "build/src/index.js.map" - }, - { - "path": "build/src/index.d.ts" - }, { "path": "build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.d.ts" }, diff --git a/system-test/.eslintrc b/system-test/.eslintrc deleted file mode 100644 index e28757c..0000000 --- a/system-test/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ ---- -env: - mocha: true \ No newline at end of file diff --git a/system-test/.eslintrc.yml b/system-test/.eslintrc.yml deleted file mode 100644 index dc5d9b0..0000000 --- a/system-test/.eslintrc.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -env: - mocha: true - diff --git a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts index 5971213..b4f3faf 100644 --- a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts +++ b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts @@ -18,7 +18,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; -const recaptchaenterpriseservicev1beta1Module = require('../src'); +const recaptchaenterpriseservicev1beta1Module = require('../src/v1beta1'); const FAKE_STATUS_CODE = 1; class FakeError { @@ -59,29 +59,29 @@ function mockSimpleGrpcMethod( describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { it('has servicePath', () => { const servicePath = - recaptchaenterpriseservicev1beta1Module.v1beta1 + recaptchaenterpriseservicev1beta1Module .RecaptchaEnterpriseServiceV1Beta1Client.servicePath; assert(servicePath); }); it('has apiEndpoint', () => { const apiEndpoint = - recaptchaenterpriseservicev1beta1Module.v1beta1 + recaptchaenterpriseservicev1beta1Module .RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; assert(apiEndpoint); }); it('has port', () => { const port = - recaptchaenterpriseservicev1beta1Module.v1beta1 + recaptchaenterpriseservicev1beta1Module .RecaptchaEnterpriseServiceV1Beta1Client.port; assert(port); assert(typeof port === 'number'); }); it('should create a client with no option', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client(); assert(client); }); it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { fallback: true, } @@ -90,7 +90,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('createAssessment', () => { it('invokes createAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -114,7 +114,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes createAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -140,7 +140,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('annotateAssessment', () => { it('invokes annotateAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -164,7 +164,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes annotateAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -190,7 +190,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('createKey', () => { it('invokes createKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -214,7 +214,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes createKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -240,7 +240,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('getKey', () => { it('invokes getKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -264,7 +264,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes getKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -286,7 +286,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('updateKey', () => { it('invokes updateKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -312,7 +312,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes updateKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -340,7 +340,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('deleteKey', () => { it('invokes deleteKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -364,7 +364,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes deleteKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -390,7 +390,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('listKeys', () => { it('invokes listKeys without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -418,7 +418,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('listKeysStream', () => { it('invokes listKeysStream without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', From 6d7ca865eda35cca9863cec3c32aea498b2aa69a Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Fri, 20 Dec 2019 15:51:46 -0800 Subject: [PATCH 4/5] add index.ts to src --- src/index.ts | 24 +++++++++++ synth.metadata | 5 +-- system-test/.eslintrc.yml | 4 ++ ...cha_enterprise_service_v1_beta1-v1beta1.ts | 40 +++++++++---------- 4 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 src/index.ts create mode 100644 system-test/.eslintrc.yml diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..cfe8daf --- /dev/null +++ b/src/index.ts @@ -0,0 +1,24 @@ +// Copyright 2019 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +// For compatibility with JavaScript libraries we need to provide this default export: +// tslint:disable-next-line no-default-export +export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; diff --git a/synth.metadata b/synth.metadata index 8b6a68b..aaf488f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-12-20T22:54:08.115964Z", + "updateTime": "2019-12-20T23:47:04.933248Z", "sources": [ { "git": { @@ -131,9 +131,6 @@ { "path": "node_modules/protobufjs/cli/node_modules/espree/package.json" }, - { - "path": "__pycache__/synth.cpython-36.pyc" - }, { "path": "samples/README.md" }, diff --git a/system-test/.eslintrc.yml b/system-test/.eslintrc.yml new file mode 100644 index 0000000..dc5d9b0 --- /dev/null +++ b/system-test/.eslintrc.yml @@ -0,0 +1,4 @@ +--- +env: + mocha: true + diff --git a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts index b4f3faf..5971213 100644 --- a/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts +++ b/test/gapic-recaptcha_enterprise_service_v1_beta1-v1beta1.ts @@ -18,7 +18,7 @@ import * as protosTypes from '../protos/protos'; import * as assert from 'assert'; -const recaptchaenterpriseservicev1beta1Module = require('../src/v1beta1'); +const recaptchaenterpriseservicev1beta1Module = require('../src'); const FAKE_STATUS_CODE = 1; class FakeError { @@ -59,29 +59,29 @@ function mockSimpleGrpcMethod( describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { it('has servicePath', () => { const servicePath = - recaptchaenterpriseservicev1beta1Module + recaptchaenterpriseservicev1beta1Module.v1beta1 .RecaptchaEnterpriseServiceV1Beta1Client.servicePath; assert(servicePath); }); it('has apiEndpoint', () => { const apiEndpoint = - recaptchaenterpriseservicev1beta1Module + recaptchaenterpriseservicev1beta1Module.v1beta1 .RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; assert(apiEndpoint); }); it('has port', () => { const port = - recaptchaenterpriseservicev1beta1Module + recaptchaenterpriseservicev1beta1Module.v1beta1 .RecaptchaEnterpriseServiceV1Beta1Client.port; assert(port); assert(typeof port === 'number'); }); it('should create a client with no option', () => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client(); + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); assert(client); }); it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { fallback: true, } @@ -90,7 +90,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('createAssessment', () => { it('invokes createAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -114,7 +114,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes createAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -140,7 +140,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('annotateAssessment', () => { it('invokes annotateAssessment without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -164,7 +164,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes annotateAssessment with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -190,7 +190,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('createKey', () => { it('invokes createKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -214,7 +214,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes createKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -240,7 +240,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('getKey', () => { it('invokes getKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -264,7 +264,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes getKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -286,7 +286,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('updateKey', () => { it('invokes updateKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -312,7 +312,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes updateKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -340,7 +340,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('deleteKey', () => { it('invokes deleteKey without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -364,7 +364,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); it('invokes deleteKey with error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -390,7 +390,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('listKeys', () => { it('invokes listKeys without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', @@ -418,7 +418,7 @@ describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { }); describe('listKeysStream', () => { it('invokes listKeysStream without error', done => { - const client = new recaptchaenterpriseservicev1beta1Module.RecaptchaEnterpriseServiceV1Beta1Client( + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', From 292300ba3a2066dde13972eee357de9b8de5a281 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Fri, 20 Dec 2019 15:52:12 -0800 Subject: [PATCH 5/5] lint --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index cfe8daf..6ef81cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,8 @@ // ** All changes to this file may be overwritten. ** import * as v1beta1 from './v1beta1'; -const RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +const RecaptchaEnterpriseServiceV1Beta1Client = + v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; // For compatibility with JavaScript libraries we need to provide this default export: // tslint:disable-next-line no-default-export