From 9f10843e1fb2eb0a41016fcdcebb31c1732d1800 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 20 Aug 2021 23:04:12 +0000 Subject: [PATCH 1/2] feat: turns on self-signed JWT feature flag PiperOrigin-RevId: 392067151 Source-Link: https://github.com/googleapis/googleapis/commit/06345f7b95c4b4a3ffe4303f1f2984ccc304b2e0 Source-Link: https://github.com/googleapis/googleapis-gen/commit/95882b37970e41e4cd51b22fa507cfd46dc7c4b6 --- owl-bot-staging/v1/.eslintignore | 6 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 10 + owl-bot-staging/v1/package.json | 64 + .../v1/recaptchaenterprise.proto | 460 ++++++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 97 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../v1/recaptcha_enterprise_service_client.ts | 1044 +++++++++++++++++ ...tcha_enterprise_service_client_config.json | 61 + ...captcha_enterprise_service_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + .../gapic_recaptcha_enterprise_service_v1.ts | 1006 ++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta1/.eslintignore | 6 + owl-bot-staging/v1beta1/.eslintrc.json | 3 + owl-bot-staging/v1beta1/.gitignore | 14 + owl-bot-staging/v1beta1/.jsdoc.js | 55 + owl-bot-staging/v1beta1/.mocharc.js | 33 + owl-bot-staging/v1beta1/.prettierrc.js | 22 + owl-bot-staging/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 10 + owl-bot-staging/v1beta1/package.json | 64 + .../v1beta1/recaptchaenterprise.proto | 442 +++++++ owl-bot-staging/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 97 ++ owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 + ...tcha_enterprise_service_v1_beta1_client.ts | 1044 +++++++++++++++++ ...rprise_service_v1_beta1_client_config.json | 61 + ...nterprise_service_v1_beta1_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + ...cha_enterprise_service_v1_beta1_v1beta1.ts | 1006 ++++++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 44 files changed, 6210 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts create mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1beta1/.eslintignore create mode 100644 owl-bot-staging/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1beta1/.gitignore create mode 100644 owl-bot-staging/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1beta1/README.md create mode 100644 owl-bot-staging/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1beta1/package.json create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto create mode 100644 owl-bot-staging/v1beta1/src/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 0000000..521dc25 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 0000000..b6e3bb5 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2021 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. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/recaptcha-enterprise', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 0000000..50bc7f7 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2021 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 0000000..84f4713 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2021 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 0000000..57a5e16 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 0000000..8bbe62f --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/recaptcha-enterprise", + "version": "0.1.0", + "description": "Recaptchaenterprise client for Node.js", + "repository": "googleapis/nodejs-recaptchaenterprise", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google recaptchaenterprise", + "recaptchaenterprise", + "recaptcha enterprise service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto b/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto new file mode 100644 index 0000000..9b60fce --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto @@ -0,0 +1,460 @@ +// Copyright 2020 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. + +syntax = "proto3"; + +package google.cloud.recaptchaenterprise.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/recaptchaenterprise/v1;recaptchaenterprise"; +option java_multiple_files = true; +option java_outer_classname = "RecaptchaEnterpriseProto"; +option java_package = "com.google.recaptchaenterprise.v1"; +option objc_class_prefix = "GCRE"; +option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1"; +option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1"; + +// Service to determine the likelihood an event is legitimate. +service RecaptchaEnterpriseService { + option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates an Assessment of the likelihood an event is legitimate. + rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/assessments" + body: "assessment" + }; + option (google.api.method_signature) = "parent,assessment"; + } + + // Annotates a previously created Assessment to provide additional information + // on whether the event turned out to be authentic or fradulent. + rpc AnnotateAssessment(AnnotateAssessmentRequest) returns (AnnotateAssessmentResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/assessments/*}:annotate" + body: "*" + }; + option (google.api.method_signature) = "name,annotation"; + } + + // Creates a new reCAPTCHA Enterprise key. + rpc CreateKey(CreateKeyRequest) returns (Key) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/keys" + body: "key" + }; + } + + // Returns the list of all keys that belong to a project. + rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/keys" + }; + } + + // Returns the specified key. + rpc GetKey(GetKeyRequest) returns (Key) { + option (google.api.http) = { + get: "/v1/{name=projects/*/keys/*}" + }; + } + + // Updates the specified key. + rpc UpdateKey(UpdateKeyRequest) returns (Key) { + option (google.api.http) = { + patch: "/v1/{key.name=projects/*/keys/*}" + body: "key" + }; + } + + // Deletes the specified key. + rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/keys/*}" + }; + } +} + +// The create assessment request message. +message CreateAssessmentRequest { + // Required. The name of the project in which the assessment will be created, + // in the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The assessment details. + Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request message to annotate an Assessment. +message AnnotateAssessmentRequest { + // Enum that reprensents the types of annotations. + enum 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; + + // Provides information that the event was related to a login event in which + // the user typed the correct password. + PASSWORD_CORRECT = 3; + + // Provides information that the event was related to a login event in which + // the user typed the incorrect password. + PASSWORD_INCORRECT = 4; + } + + // Required. The resource name of the Assessment, in the format + // "projects/{project}/assessments/{assessment}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + } + ]; + + // Required. The annotation that will be assigned to the Event. + Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Empty response for AnnotateAssessment. +message AnnotateAssessmentResponse { + +} + +// A recaptcha assessment resource. +message Assessment { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + pattern: "projects/{project}/assessments/{assessment}" + }; + + // Output only. The resource name for the Assessment in the format + // "projects/{project}/assessments/{assessment}". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The event being assessed. + Event event = 2; + + // Output only. The risk analysis result for the event being assessed. + RiskAnalysis risk_analysis = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Properties of the provided event token. + TokenProperties token_properties = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +message Event { + // Optional. The user response token provided by the reCAPTCHA client-side integration + // on your site. + string token = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The site key that was used to invoke reCAPTCHA on your site and generate + // the token. + string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The user agent present in the request from the user's device related to + // this event. + string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address in the request from the user's device related to this event. + string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; + + // 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. + string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +// Risk analysis result for an event. +message RiskAnalysis { + // LINT.IfChange(classification_reason) + // Reasons contributing to the risk analysis verdict. + enum 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; + } + + // 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). + float score = 1; + + // Reasons contributing to the risk analysis verdict. + repeated ClassificationReason reasons = 2; +} + +message TokenProperties { + // LINT.IfChange + // Enum that represents the types of invalid token reasons. + enum 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 was not present. + MISSING = 5; + } + + // Whether the provided user response token is valid. When valid = false, the + // reason could be specified in invalid_reason or it could also be due to + // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey + // used to generate the token was different than the one specified in the + // assessment). + bool valid = 1; + + // Reason associated with the response when valid = false. + InvalidReason invalid_reason = 2; + + // The timestamp corresponding to the generation of the token. + google.protobuf.Timestamp create_time = 3; + + // The hostname of the page on which the token was generated. + string hostname = 4; + + // Action name provided at token generation. + string action = 5; +} + +// The create key request message. +message CreateKeyRequest { + // Required. The name of the project in which the key will be created, in the + // format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. Information to create a reCAPTCHA Enterprise key. + Key key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The list keys request message. +message ListKeysRequest { + // Required. The name of the project that contains the keys that will be + // listed, in the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. The maximum number of keys to return. Default is 10. Max limit is + // 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The next_page_token value returned from a previous. + // ListKeysRequest, if any. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response to request to list keys in a project. +message ListKeysResponse { + // Key details. + repeated Key keys = 1; + + // Token to retrieve the next page of results. It is set to empty if no keys + // remain in results. + string next_page_token = 2; +} + +// The get key request message. +message GetKeyRequest { + // Required. The name of the requested key, in the format + // "projects/{project}/keys/{key}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// The update key request message. +message UpdateKeyRequest { + // Required. The key to update. + Key key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The mask to control which field of the key get updated. If the mask is not + // present, all fields will be updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The delete key request message. +message DeleteKeyRequest { + // Required. The name of the key to be deleted, in the format + // "projects/{project}/keys/{key}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// A key used to identify and configure applications (web and/or mobile) that +// use reCAPTCHA Enterprise. +message Key { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Key" + pattern: "projects/{project}/keys/{key}" + }; + + // The resource name for the Key in the format + // "projects/{project}/keys/{key}". + string name = 1; + + // Human-readable display name of this key. Modifiable by user. + string display_name = 2; + + // Platform specific settings for this key. The key can only be used on one + // platform, the one it has settings for. + oneof platform_settings { + // Settings for keys that can be used by websites. + WebKeySettings web_settings = 3; + + // Settings for keys that can be used by Android apps. + AndroidKeySettings android_settings = 4; + + // Settings for keys that can be used by iOS apps. + IOSKeySettings ios_settings = 5; + } + + // Optional. See + // Creating and managing labels. + map labels = 6 [(google.api.field_behavior) = OPTIONAL]; + + // The timestamp corresponding to the creation of this Key. + google.protobuf.Timestamp create_time = 7; +} + +// Settings specific to keys that can be used by websites. +message WebKeySettings { + // Enum that represents the integration types for web keys. + enum 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 = 1; + + // Displays the "I'm not a robot" checkbox and may show captcha challenges + // after it is checked. + CHECKBOX = 2; + + // Doesn't display the "I'm not a robot" checkbox, but may show captcha + // challenges after risk analysis. + INVISIBLE = 3; + } + + // Enum that represents the possible challenge frequency and difficulty + // configurations for a web key. + enum 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. + BALANCE = 2; + + // Key tends to show more and harder challenges. + SECURITY = 3; + } + + // If set to true, it means allowed_domains will not be enforced. + bool allow_all_domains = 3; + + // 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' + repeated string allowed_domains = 1; + + // Required. Whether this key can be used on AMP (Accelerated Mobile Pages) websites. + bool allow_amp_traffic = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Describes how this key is integrated with the website. + IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; + + // Settings for the frequency and difficulty at which this key triggers + // captcha challenges. This should only be specified for IntegrationTypes + // CHECKBOX and INVISIBLE. + ChallengeSecurityPreference challenge_security_preference = 5; +} + +// Settings specific to keys that can be used by Android apps. +message AndroidKeySettings { + // Android package names of apps allowed to use the key. + // Example: 'com.companyname.appname' + repeated string allowed_package_names = 1; +} + +// Settings specific to keys that can be used by iOS apps. +message IOSKeySettings { + // iOS bundle ids of apps allowed to use the key. + // Example: 'com.companyname.productname.appname' + repeated string allowed_bundle_ids = 1; +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 0000000..29221d6 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 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 v1 from './v1'; +const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; +type RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; +export {v1, RecaptchaEnterpriseServiceClient}; +export default {v1, RecaptchaEnterpriseServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 0000000..182faf0 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,97 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recaptchaenterprise.v1", + "libraryPackage": "@google-cloud/recaptcha-enterprise", + "services": { + "RecaptchaEnterpriseService": { + "clients": { + "grpc": { + "libraryClient": "RecaptchaEnterpriseServiceClient", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecaptchaEnterpriseServiceClient", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 0000000..2159903 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 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. ** + +export {RecaptchaEnterpriseServiceClient} from './recaptcha_enterprise_service_client'; diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts new file mode 100644 index 0000000..dba0779 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts @@ -0,0 +1,1044 @@ +// Copyright 2021 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. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/recaptcha_enterprise_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recaptcha_enterprise_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service to determine the likelihood an event is legitimate. + * @class + * @memberof v1 + */ +export class RecaptchaEnterpriseServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recaptchaEnterpriseServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecaptchaEnterpriseServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @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 {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // 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 this._gaxModule.PathTemplate( + 'projects/{project}/assessments/{assessment}' + ), + keyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/keys/{key}' + ), + projectPathTemplate: new this._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 this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', 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 = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.recaptchaEnterpriseServiceStub) { + return this.recaptchaEnterpriseServiceStub; + } + + // Put together the "service stub" for + // google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService. + this.recaptchaEnterpriseServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const recaptchaEnterpriseServiceStubMethods = + ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; + for (const methodName of recaptchaEnterpriseServiceStubMethods) { + const callPromise = this.recaptchaEnterpriseServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.recaptchaEnterpriseServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + 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. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined + ]>; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|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}". + * @param {google.cloud.recaptchaenterprise.v1.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.v1.Assessment}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createAssessment(request); + */ + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.createAssessment(request, options, callback); + } + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|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}/assessments/{assessment}". + * @param {google.cloud.recaptchaenterprise.v1.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.v1.AnnotateAssessmentResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.annotateAssessment(request); + */ + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.annotateAssessment(request, options, callback); + } + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined + ]>; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): void; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|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}". + * @param {google.cloud.recaptchaenterprise.v1.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.v1.Key}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createKey(request); + */ + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.createKey(request, options, callback); + } + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined + ]>; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>): void; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|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}/keys/{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.v1.Key}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getKey(request); + */ + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.getKey(request, options, callback); + } + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined + ]>; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): void; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1.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.v1.Key}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateKey(request); + */ + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.updateKey(request, options, callback); + } + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined + ]>; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|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}/keys/{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 [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteKey(request); + */ + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.deleteKey(request, options, callback); + } + + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ]>; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): void; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): 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}". + * @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.v1.Key}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.listKeys(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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}". + * @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.v1.Key} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listKeysStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: CallOptions): + Transform{ + 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 || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listKeys.createStream( + this.innerApiCalls.listKeys as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listKeys`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @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}". + * @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 {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listKeysAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listKeysAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: CallOptions): + AsyncIterable{ + 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 || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listKeys.asyncIterate( + this.innerApiCalls['listKeys'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * 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; + } + + /** + * 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; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.recaptchaEnterpriseServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json new file mode 100644 index 0000000..20e3110 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AnnotateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListKeys": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json new file mode 100644 index 0000000..790fef9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..dd1a158 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); + +function main() { + const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..362e1a6 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 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 {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise'; + +// check that the client class type name can be used +function doStuffWithRecaptchaEnterpriseServiceClient(client: RecaptchaEnterpriseServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + doStuffWithRecaptchaEnterpriseServiceClient(recaptchaEnterpriseServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 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'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts b/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts new file mode 100644 index 0000000..bc418a1 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts @@ -0,0 +1,1006 @@ +// Copyright 2021 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 protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as recaptchaenterpriseserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.RecaptchaEnterpriseServiceClient', () => { + it('has servicePath', () => { + const servicePath = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceStub); + }); + + it('has close method', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createAssessment(request), expectedError); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); + client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateAssessment(request), expectedError); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createKey', () => { + it('invokes createKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); + const [response] = await client.createKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createKey(request), expectedError); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getKey', () => { + it('invokes getKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); + const [response] = await client.getKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getKey(request), expectedError); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateKey', () => { + it('invokes updateKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); + client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateKey(request), expectedError); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteKey', () => { + it('invokes deleteKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteKey( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteKey(request), expectedError); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listKeys', () => { + it('invokes listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listKeys(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listKeys without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKeys( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listKeys(request), expectedError); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listKeysStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listKeysStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), + ]; + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + const iterable = client.listKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('assessment', () => { + const fakePath = "/rendered/path/assessment"; + const expectedParameters = { + project: "projectValue", + assessment: "assessmentValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('assessmentPath', () => { + const result = client.assessmentPath("projectValue", "assessmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, "assessmentValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('key', () => { + const fakePath = "/rendered/path/key"; + const expectedParameters = { + project: "projectValue", + key: "keyValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.keyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.keyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('keyPath', () => { + const result = client.keyPath("projectValue", "keyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.keyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromKeyName', () => { + const result = client.matchProjectFromKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyFromKeyName', () => { + const result = client.matchKeyFromKeyName(fakePath); + assert.strictEqual(result, "keyValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 0000000..6a9d07d --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'RecaptchaEnterpriseService', + filename: './recaptcha-enterprise-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + 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[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore new file mode 100644 index 0000000..521dc25 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js new file mode 100644 index 0000000..b6e3bb5 --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2021 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. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/recaptcha-enterprise', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js new file mode 100644 index 0000000..50bc7f7 --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2021 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js new file mode 100644 index 0000000..84f4713 --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2021 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md new file mode 100644 index 0000000..57a5e16 --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1beta1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 0000000..0720dd0 --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/recaptcha-enterprise", + "version": "0.1.0", + "description": "Recaptchaenterprise client for Node.js", + "repository": "googleapis/nodejs-recaptchaenterprise", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google recaptchaenterprise", + "recaptchaenterprise", + "recaptcha enterprise service v1 beta1" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto b/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto new file mode 100644 index 0000000..099d304 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto @@ -0,0 +1,442 @@ +// 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. +// + +syntax = "proto3"; + +package google.cloud.recaptchaenterprise.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/recaptchaenterprise/v1beta1;recaptchaenterprise"; +option java_multiple_files = true; +option java_outer_classname = "RecaptchaEnterpriseProto"; +option java_package = "com.google.recaptchaenterprise.v1beta1"; +option objc_class_prefix = "GCRE"; +option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1beta1"; +option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1beta1"; + +// Service to determine the likelihood an event is legitimate. +service RecaptchaEnterpriseServiceV1Beta1 { + option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates an Assessment of the likelihood an event is legitimate. + rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/assessments" + body: "assessment" + }; + option (google.api.method_signature) = "parent,assessment"; + } + + // Annotates a previously created Assessment to provide additional information + // on whether the event turned out to be authentic or fradulent. + rpc AnnotateAssessment(AnnotateAssessmentRequest) returns (AnnotateAssessmentResponse) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/assessments/*}:annotate" + body: "*" + }; + option (google.api.method_signature) = "name,annotation"; + } + + // Creates a new reCAPTCHA Enterprise key. + rpc CreateKey(CreateKeyRequest) returns (Key) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*}/keys" + body: "key" + }; + } + + // Returns the list of all keys that belong to a project. + rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*}/keys" + }; + } + + // Returns the specified key. + rpc GetKey(GetKeyRequest) returns (Key) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/keys/*}" + }; + } + + // Updates the specified key. + rpc UpdateKey(UpdateKeyRequest) returns (Key) { + option (google.api.http) = { + patch: "/v1beta1/{key.name=projects/*/keys/*}" + body: "key" + }; + } + + // Deletes the specified key. + rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/keys/*}" + }; + } +} + +// The create assessment request message. +message CreateAssessmentRequest { + // Required. The name of the project in which the assessment will be created, + // in the format "projects/{project_number}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The assessment details. + Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request message to annotate an Assessment. +message AnnotateAssessmentRequest { + // Enum that reprensents the types of annotations. + enum 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; + } + + // Required. The resource name of the Assessment, in the format + // "projects/{project_number}/assessments/{assessment_id}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + } + ]; + + // Required. The annotation that will be assigned to the Event. + Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Empty response for AnnotateAssessment. +message AnnotateAssessmentResponse { + +} + +// A recaptcha assessment resource. +message Assessment { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Assessment" + pattern: "projects/{project}/assessments/{assessment}" + }; + + // LINT.IfChange(classification_reason) + // Reasons contributing to the risk analysis verdict. + enum 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; + } + + // Output only. The resource name for the Assessment in the format + // "projects/{project_number}/assessments/{assessment_id}". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The event being assessed. + Event event = 2; + + // 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). + float score = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Properties of the provided event token. + TokenProperties token_properties = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Reasons contributing to the risk analysis verdict. + repeated ClassificationReason reasons = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +message Event { + // Optional. The user response token provided by the reCAPTCHA client-side integration + // on your site. + string token = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The site key that was used to invoke reCAPTCHA on your site and generate + // the token. + string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The user agent present in the request from the user's device related to + // this event. + string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The IP address in the request from the user's device related to this event. + string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; + + // 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. + string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; +} + +message TokenProperties { + // LINT.IfChange + // Enum that represents the types of invalid token reasons. + enum 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; + } + + // Whether the provided user response token is valid. + bool valid = 1; + + // Reason associated with the response when valid = false. + InvalidReason invalid_reason = 2; + + // The timestamp corresponding to the generation of the token. + google.protobuf.Timestamp create_time = 3; + + // The hostname of the page on which the token was generated. + string hostname = 4; + + // Action name provided at token generation. + string action = 5; +} + +// The create key request message. +message CreateKeyRequest { + // Required. The name of the project in which the key will be created, in the + // format "projects/{project_number}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. Information to create a reCAPTCHA Enterprise key. + Key key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The list keys request message. +message ListKeysRequest { + // Required. The name of the project that contains the keys that will be + // listed, in the format "projects/{project_number}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Optional. The maximum number of keys to return. Default is 10. Max limit is + // 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The next_page_token value returned from a previous. + // ListKeysRequest, if any. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response to request to list keys in a project. +message ListKeysResponse { + // Key details. + repeated Key keys = 1; + + // Token to retrieve the next page of results. It is set to empty if no keys + // remain in results. + string next_page_token = 2; +} + +// The get key request message. +message GetKeyRequest { + // Required. The name of the requested key, in the format + // "projects/{project_number}/keys/{key_id}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// The update key request message. +message UpdateKeyRequest { + // Required. The key to update. + Key key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The mask to control which field of the key get updated. If the mask is not + // present, all fields will be updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// The delete key request message. +message DeleteKeyRequest { + // Required. The name of the key to be deleted, in the format + // "projects/{project_number}/keys/{key_id}". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Key" + } + ]; +} + +// A key used to identify and configure applications (web and/or mobile) that +// use reCAPTCHA Enterprise. +message Key { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Key" + pattern: "projects/{project}/keys/{key}" + }; + + // The resource name for the Key in the format + // "projects/{project_number}/keys/{key_id}". + string name = 1; + + // Human-readable display name of this key. Modifiable by user. + string display_name = 2; + + // Platform specific settings for this key. The key can only be used on one + // platform, the one it has settings for. + oneof platform_settings { + // Settings for keys that can be used by websites. + WebKeySettings web_settings = 3; + + // Settings for keys that can be used by Android apps. + AndroidKeySettings android_settings = 4; + + // Settings for keys that can be used by iOS apps. + IOSKeySettings ios_settings = 5; + } +} + +// Settings specific to keys that can be used by websites. +message WebKeySettings { + // Enum that represents the integration types for web keys. + enum 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; + } + + // Enum that represents the possible challenge frequency and difficulty + // configurations for a web key. + enum 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; + } + + // Whether allowed_domains is enforced or not. + bool enforce_allowed_domains = 3; + + // 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' + repeated string allowed_domains = 1; + + // Whether this key can be used on AMP (Accelerated Mobile Pages) websites. + bool allow_amp_traffic = 2; + + // Required. Describes how this key is integrated with the website. + IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; + + // 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. + ChallengeSecurityPreference challenge_security_preference = 5; +} + +// Settings specific to keys that can be used by Android apps. +message AndroidKeySettings { + // Android package names of apps allowed to use the key. + // Example: 'com.companyname.appname' + repeated string allowed_package_names = 1; +} + +// Settings specific to keys that can be used by iOS apps. +message IOSKeySettings { + // iOS bundle ids of apps allowed to use the key. + // Example: 'com.companyname.productname.appname' + repeated string allowed_bundle_ids = 1; +} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 0000000..2c2d807 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 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; +type RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; +export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 0000000..7a2089e --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,97 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.recaptchaenterprise.v1beta1", + "libraryPackage": "@google-cloud/recaptcha-enterprise", + "services": { + "RecaptchaEnterpriseServiceV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts new file mode 100644 index 0000000..6314ef6 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 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. ** + +export {RecaptchaEnterpriseServiceV1Beta1Client} from './recaptcha_enterprise_service_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts new file mode 100644 index 0000000..9de4fed --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -0,0 +1,1044 @@ +// Copyright 2021 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. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +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 _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recaptchaEnterpriseServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @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 {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // 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 this._gaxModule.PathTemplate( + 'projects/{project}/assessments/{assessment}' + ), + keyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/keys/{key}' + ), + projectPathTemplate: new this._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 this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + }; + + // Put together the default options sent with requests. + this._defaults = this._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 = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.recaptchaEnterpriseServiceV1Beta1Stub) { + return this.recaptchaEnterpriseServiceV1Beta1Stub; + } + + // Put together the "service stub" for + // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. + this.recaptchaEnterpriseServiceV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, + this._opts, this._providedCustomServicePath) 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 callPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.recaptchaEnterpriseServiceV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'recaptchaenterprise.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + 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. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + createAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createAssessment(request); + */ + createAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.createAssessment(request, options, callback); + } + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): void; + annotateAssessment( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.annotateAssessment(request); + */ + annotateAssessment( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.annotateAssessment(request, options, callback); + } + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined + ]>; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): void; + createKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createKey(request); + */ + createKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.createKey(request, options, callback); + } + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined + ]>; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, + {}|null|undefined>): void; + getKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getKey(request); + */ + getKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.getKey(request, options, callback); + } + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined + ]>; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): void; + updateKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateKey(request); + */ + updateKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.updateKey(request, options, callback); + } + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined + ]>; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): void; + deleteKey( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, + {}|null|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}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteKey(request); + */ + deleteKey( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.deleteKey(request, options, callback); + } + + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ]>; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): void; + listKeys( + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): 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 will perform 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. + * Note that it can affect your quota. + * We recommend using `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listKeys( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 || '', + }); + this.initialize(); + return this.innerApiCalls.listKeys(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listKeysStream( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: CallOptions): + Transform{ + 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 || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listKeys.createStream( + this.innerApiCalls.listKeys as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listKeys`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @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 {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listKeysAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listKeysAsync( + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: CallOptions): + AsyncIterable{ + 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 || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listKeys.asyncIterate( + this.innerApiCalls['listKeys'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * 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; + } + + /** + * 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; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.recaptchaEnterpriseServiceV1Beta1Stub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json new file mode 100644 index 0000000..726aae1 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AnnotateAssessment": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListKeys": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteKey": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json new file mode 100644 index 0000000..35d2e75 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" +] diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..54439a4 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); + +function main() { + const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..9d4654c --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 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 {RecaptchaEnterpriseServiceV1Beta1Client} from '@google-cloud/recaptcha-enterprise'; + +// check that the client class type name can be used +function doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(client: RecaptchaEnterpriseServiceV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const recaptchaEnterpriseServiceV1Beta1Client = new RecaptchaEnterpriseServiceV1Beta1Client(); + doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(recaptchaEnterpriseServiceV1Beta1Client); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 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'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts new file mode 100644 index 0000000..c00561a --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts @@ -0,0 +1,1006 @@ +// Copyright 2021 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 protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as recaptchaenterpriseservicev1beta1Module from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +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); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceV1Beta1Stub); + }); + + it('has close method', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createAssessment(request), expectedError); + assert((client.innerApiCalls.createAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); + client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateAssessment(request), expectedError); + assert((client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createKey', () => { + it('invokes createKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); + const [response] = await client.createKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createKey(request), expectedError); + assert((client.innerApiCalls.createKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getKey', () => { + it('invokes getKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); + const [response] = await client.getKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getKey(request), expectedError); + assert((client.innerApiCalls.getKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateKey', () => { + it('invokes updateKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); + client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateKey( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = "key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateKey(request), expectedError); + assert((client.innerApiCalls.updateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteKey', () => { + it('invokes deleteKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteKey( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteKey(request), expectedError); + assert((client.innerApiCalls.deleteKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listKeys', () => { + it('invokes listKeys without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listKeys(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listKeys without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + ]; + client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKeys( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listKeys with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listKeys(request), expectedError); + assert((client.innerApiCalls.listKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listKeysStream without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + ]; + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listKeysStream with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listKeys without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), + ]; + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; + const iterable = client.listKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listKeys with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('assessment', () => { + const fakePath = "/rendered/path/assessment"; + const expectedParameters = { + project: "projectValue", + assessment: "assessmentValue", + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('assessmentPath', () => { + const result = client.assessmentPath("projectValue", "assessmentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, "assessmentValue"); + assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('key', () => { + const fakePath = "/rendered/path/key"; + const expectedParameters = { + project: "projectValue", + key: "keyValue", + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.keyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.keyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('keyPath', () => { + const result = client.keyPath("projectValue", "keyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.keyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromKeyName', () => { + const result = client.matchProjectFromKeyName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyFromKeyName', () => { + const result = client.matchKeyFromKeyName(fakePath); + assert.strictEqual(result, "keyValue"); + assert((client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js new file mode 100644 index 0000000..a5030d6 --- /dev/null +++ b/owl-bot-staging/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'RecaptchaEnterpriseServiceV1Beta1', + filename: './recaptcha-enterprise-service-v1-beta1.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + 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[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From ca9089a5bb3f3bae7e03c73f942abce4e8e2ee74 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 20 Aug 2021 23:05:25 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v1/.eslintignore | 6 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 10 - owl-bot-staging/v1/package.json | 64 - .../v1/recaptchaenterprise.proto | 460 -------- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 97 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../v1/recaptcha_enterprise_service_client.ts | 1044 ----------------- ...tcha_enterprise_service_client_config.json | 61 - ...captcha_enterprise_service_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - .../gapic_recaptcha_enterprise_service_v1.ts | 1006 ---------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta1/.eslintignore | 6 - owl-bot-staging/v1beta1/.eslintrc.json | 3 - owl-bot-staging/v1beta1/.gitignore | 14 - owl-bot-staging/v1beta1/.jsdoc.js | 55 - owl-bot-staging/v1beta1/.mocharc.js | 33 - owl-bot-staging/v1beta1/.prettierrc.js | 22 - owl-bot-staging/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 10 - owl-bot-staging/v1beta1/package.json | 64 - .../v1beta1/recaptchaenterprise.proto | 442 ------- owl-bot-staging/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 97 -- owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 - ...tcha_enterprise_service_v1_beta1_client.ts | 1044 ----------------- ...rprise_service_v1_beta1_client_config.json | 61 - ...nterprise_service_v1_beta1_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - ...cha_enterprise_service_v1_beta1_v1beta1.ts | 1006 ---------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - src/v1/recaptcha_enterprise_service_client.ts | 6 + ...tcha_enterprise_service_v1_beta1_client.ts | 6 + 46 files changed, 12 insertions(+), 6210 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta1/.gitignore delete mode 100644 owl-bot-staging/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta1/README.md delete mode 100644 owl-bot-staging/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta1/package.json delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto delete mode 100644 owl-bot-staging/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index 521dc25..0000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index b6e3bb5..0000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/recaptcha-enterprise', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 50bc7f7..0000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2021 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 84f4713..0000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 57a5e16..0000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index 29a223b..0000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 8bbe62f..0000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/recaptcha-enterprise", - "version": "0.1.0", - "description": "Recaptchaenterprise client for Node.js", - "repository": "googleapis/nodejs-recaptchaenterprise", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google recaptchaenterprise", - "recaptchaenterprise", - "recaptcha enterprise service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto b/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto deleted file mode 100644 index 9b60fce..0000000 --- a/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto +++ /dev/null @@ -1,460 +0,0 @@ -// Copyright 2020 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. - -syntax = "proto3"; - -package google.cloud.recaptchaenterprise.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/recaptchaenterprise/v1;recaptchaenterprise"; -option java_multiple_files = true; -option java_outer_classname = "RecaptchaEnterpriseProto"; -option java_package = "com.google.recaptchaenterprise.v1"; -option objc_class_prefix = "GCRE"; -option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1"; -option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1"; - -// Service to determine the likelihood an event is legitimate. -service RecaptchaEnterpriseService { - option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates an Assessment of the likelihood an event is legitimate. - rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/assessments" - body: "assessment" - }; - option (google.api.method_signature) = "parent,assessment"; - } - - // Annotates a previously created Assessment to provide additional information - // on whether the event turned out to be authentic or fradulent. - rpc AnnotateAssessment(AnnotateAssessmentRequest) returns (AnnotateAssessmentResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/assessments/*}:annotate" - body: "*" - }; - option (google.api.method_signature) = "name,annotation"; - } - - // Creates a new reCAPTCHA Enterprise key. - rpc CreateKey(CreateKeyRequest) returns (Key) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/keys" - body: "key" - }; - } - - // Returns the list of all keys that belong to a project. - rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/keys" - }; - } - - // Returns the specified key. - rpc GetKey(GetKeyRequest) returns (Key) { - option (google.api.http) = { - get: "/v1/{name=projects/*/keys/*}" - }; - } - - // Updates the specified key. - rpc UpdateKey(UpdateKeyRequest) returns (Key) { - option (google.api.http) = { - patch: "/v1/{key.name=projects/*/keys/*}" - body: "key" - }; - } - - // Deletes the specified key. - rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/keys/*}" - }; - } -} - -// The create assessment request message. -message CreateAssessmentRequest { - // Required. The name of the project in which the assessment will be created, - // in the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The assessment details. - Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request message to annotate an Assessment. -message AnnotateAssessmentRequest { - // Enum that reprensents the types of annotations. - enum 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; - - // Provides information that the event was related to a login event in which - // the user typed the correct password. - PASSWORD_CORRECT = 3; - - // Provides information that the event was related to a login event in which - // the user typed the incorrect password. - PASSWORD_INCORRECT = 4; - } - - // Required. The resource name of the Assessment, in the format - // "projects/{project}/assessments/{assessment}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - } - ]; - - // Required. The annotation that will be assigned to the Event. - Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Empty response for AnnotateAssessment. -message AnnotateAssessmentResponse { - -} - -// A recaptcha assessment resource. -message Assessment { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - pattern: "projects/{project}/assessments/{assessment}" - }; - - // Output only. The resource name for the Assessment in the format - // "projects/{project}/assessments/{assessment}". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The event being assessed. - Event event = 2; - - // Output only. The risk analysis result for the event being assessed. - RiskAnalysis risk_analysis = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Properties of the provided event token. - TokenProperties token_properties = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -message Event { - // Optional. The user response token provided by the reCAPTCHA client-side integration - // on your site. - string token = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The site key that was used to invoke reCAPTCHA on your site and generate - // the token. - string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The user agent present in the request from the user's device related to - // this event. - string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address in the request from the user's device related to this event. - string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; - - // 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. - string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -// Risk analysis result for an event. -message RiskAnalysis { - // LINT.IfChange(classification_reason) - // Reasons contributing to the risk analysis verdict. - enum 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; - } - - // 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). - float score = 1; - - // Reasons contributing to the risk analysis verdict. - repeated ClassificationReason reasons = 2; -} - -message TokenProperties { - // LINT.IfChange - // Enum that represents the types of invalid token reasons. - enum 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 was not present. - MISSING = 5; - } - - // Whether the provided user response token is valid. When valid = false, the - // reason could be specified in invalid_reason or it could also be due to - // a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey - // used to generate the token was different than the one specified in the - // assessment). - bool valid = 1; - - // Reason associated with the response when valid = false. - InvalidReason invalid_reason = 2; - - // The timestamp corresponding to the generation of the token. - google.protobuf.Timestamp create_time = 3; - - // The hostname of the page on which the token was generated. - string hostname = 4; - - // Action name provided at token generation. - string action = 5; -} - -// The create key request message. -message CreateKeyRequest { - // Required. The name of the project in which the key will be created, in the - // format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. Information to create a reCAPTCHA Enterprise key. - Key key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The list keys request message. -message ListKeysRequest { - // Required. The name of the project that contains the keys that will be - // listed, in the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Optional. The maximum number of keys to return. Default is 10. Max limit is - // 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The next_page_token value returned from a previous. - // ListKeysRequest, if any. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response to request to list keys in a project. -message ListKeysResponse { - // Key details. - repeated Key keys = 1; - - // Token to retrieve the next page of results. It is set to empty if no keys - // remain in results. - string next_page_token = 2; -} - -// The get key request message. -message GetKeyRequest { - // Required. The name of the requested key, in the format - // "projects/{project}/keys/{key}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// The update key request message. -message UpdateKeyRequest { - // Required. The key to update. - Key key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The mask to control which field of the key get updated. If the mask is not - // present, all fields will be updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// The delete key request message. -message DeleteKeyRequest { - // Required. The name of the key to be deleted, in the format - // "projects/{project}/keys/{key}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// A key used to identify and configure applications (web and/or mobile) that -// use reCAPTCHA Enterprise. -message Key { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Key" - pattern: "projects/{project}/keys/{key}" - }; - - // The resource name for the Key in the format - // "projects/{project}/keys/{key}". - string name = 1; - - // Human-readable display name of this key. Modifiable by user. - string display_name = 2; - - // Platform specific settings for this key. The key can only be used on one - // platform, the one it has settings for. - oneof platform_settings { - // Settings for keys that can be used by websites. - WebKeySettings web_settings = 3; - - // Settings for keys that can be used by Android apps. - AndroidKeySettings android_settings = 4; - - // Settings for keys that can be used by iOS apps. - IOSKeySettings ios_settings = 5; - } - - // Optional. See - // Creating and managing labels. - map labels = 6 [(google.api.field_behavior) = OPTIONAL]; - - // The timestamp corresponding to the creation of this Key. - google.protobuf.Timestamp create_time = 7; -} - -// Settings specific to keys that can be used by websites. -message WebKeySettings { - // Enum that represents the integration types for web keys. - enum 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 = 1; - - // Displays the "I'm not a robot" checkbox and may show captcha challenges - // after it is checked. - CHECKBOX = 2; - - // Doesn't display the "I'm not a robot" checkbox, but may show captcha - // challenges after risk analysis. - INVISIBLE = 3; - } - - // Enum that represents the possible challenge frequency and difficulty - // configurations for a web key. - enum 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. - BALANCE = 2; - - // Key tends to show more and harder challenges. - SECURITY = 3; - } - - // If set to true, it means allowed_domains will not be enforced. - bool allow_all_domains = 3; - - // 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' - repeated string allowed_domains = 1; - - // Required. Whether this key can be used on AMP (Accelerated Mobile Pages) websites. - bool allow_amp_traffic = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Describes how this key is integrated with the website. - IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; - - // Settings for the frequency and difficulty at which this key triggers - // captcha challenges. This should only be specified for IntegrationTypes - // CHECKBOX and INVISIBLE. - ChallengeSecurityPreference challenge_security_preference = 5; -} - -// Settings specific to keys that can be used by Android apps. -message AndroidKeySettings { - // Android package names of apps allowed to use the key. - // Example: 'com.companyname.appname' - repeated string allowed_package_names = 1; -} - -// Settings specific to keys that can be used by iOS apps. -message IOSKeySettings { - // iOS bundle ids of apps allowed to use the key. - // Example: 'com.companyname.productname.appname' - repeated string allowed_bundle_ids = 1; -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 29221d6..0000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 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 v1 from './v1'; -const RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; -type RecaptchaEnterpriseServiceClient = v1.RecaptchaEnterpriseServiceClient; -export {v1, RecaptchaEnterpriseServiceClient}; -export default {v1, RecaptchaEnterpriseServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 182faf0..0000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recaptchaenterprise.v1", - "libraryPackage": "@google-cloud/recaptcha-enterprise", - "services": { - "RecaptchaEnterpriseService": { - "clients": { - "grpc": { - "libraryClient": "RecaptchaEnterpriseServiceClient", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecaptchaEnterpriseServiceClient", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 2159903..0000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 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. ** - -export {RecaptchaEnterpriseServiceClient} from './recaptcha_enterprise_service_client'; diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts deleted file mode 100644 index dba0779..0000000 --- a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts +++ /dev/null @@ -1,1044 +0,0 @@ -// Copyright 2021 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. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/recaptcha_enterprise_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recaptcha_enterprise_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Service to determine the likelihood an event is legitimate. - * @class - * @memberof v1 - */ -export class RecaptchaEnterpriseServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recaptchaEnterpriseServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecaptchaEnterpriseServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @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 {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // 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 this._gaxModule.PathTemplate( - 'projects/{project}/assessments/{assessment}' - ), - keyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/keys/{key}' - ), - projectPathTemplate: new this._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 this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', 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 = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.recaptchaEnterpriseServiceStub) { - return this.recaptchaEnterpriseServiceStub; - } - - // Put together the "service stub" for - // google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService. - this.recaptchaEnterpriseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const recaptchaEnterpriseServiceStubMethods = - ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; - for (const methodName of recaptchaEnterpriseServiceStubMethods) { - const callPromise = this.recaptchaEnterpriseServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.recaptchaEnterpriseServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - 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. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|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}". - * @param {google.cloud.recaptchaenterprise.v1.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.v1.Assessment}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createAssessment(request); - */ - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.createAssessment(request, options, callback); - } - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|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}/assessments/{assessment}". - * @param {google.cloud.recaptchaenterprise.v1.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.v1.AnnotateAssessmentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.annotateAssessment(request); - */ - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.annotateAssessment(request, options, callback); - } - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|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}". - * @param {google.cloud.recaptchaenterprise.v1.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.v1.Key}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createKey(request); - */ - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.createKey(request, options, callback); - } - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|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}/keys/{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.v1.Key}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getKey(request); - */ - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.getKey(request, options, callback); - } - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recaptchaenterprise.v1.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.v1.Key}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.updateKey(request); - */ - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.updateKey(request, options, callback); - } - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|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}/keys/{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 [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteKey(request); - */ - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.deleteKey(request, options, callback); - } - - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): void; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): 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}". - * @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.v1.Key}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.listKeys(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @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}". - * @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.v1.Key} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listKeysStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: CallOptions): - Transform{ - 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 || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listKeys.createStream( - this.innerApiCalls.listKeys as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listKeys`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @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}". - * @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 {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listKeysAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listKeysAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: CallOptions): - AsyncIterable{ - 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 || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listKeys.asyncIterate( - this.innerApiCalls['listKeys'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * 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; - } - - /** - * 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; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.recaptchaEnterpriseServiceStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json deleted file mode 100644 index 20e3110..0000000 --- a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "interfaces": { - "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AnnotateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListKeys": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json deleted file mode 100644 index 790fef9..0000000 --- a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index dd1a158..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); - -function main() { - const recaptchaEnterpriseServiceClient = new recaptchaenterprise.RecaptchaEnterpriseServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 362e1a6..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 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 {RecaptchaEnterpriseServiceClient} from '@google-cloud/recaptcha-enterprise'; - -// check that the client class type name can be used -function doStuffWithRecaptchaEnterpriseServiceClient(client: RecaptchaEnterpriseServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); - doStuffWithRecaptchaEnterpriseServiceClient(recaptchaEnterpriseServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 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'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts b/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts deleted file mode 100644 index bc418a1..0000000 --- a/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts +++ /dev/null @@ -1,1006 +0,0 @@ -// Copyright 2021 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 protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as recaptchaenterpriseserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.RecaptchaEnterpriseServiceClient', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceStub); - }); - - it('has close method', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAssessment(request), expectedError); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateAssessment(request), expectedError); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createKey', () => { - it('invokes createKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); - const [response] = await client.createKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createKey(request), expectedError); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getKey', () => { - it('invokes getKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); - const [response] = await client.getKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKey(request), expectedError); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateKey', () => { - it('invokes updateKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateKey(request), expectedError); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteKey', () => { - it('invokes deleteKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKey( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteKey(request), expectedError); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listKeys', () => { - it('invokes listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listKeys(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listKeys without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeys( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKeys(request), expectedError); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listKeysStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listKeysStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - const iterable = client.listKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('key', () => { - const fakePath = "/rendered/path/key"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.keyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyPath', () => { - const result = client.keyPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyName', () => { - const result = client.matchProjectFromKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromKeyName', () => { - const result = client.matchKeyFromKeyName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index 6a9d07d..0000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'RecaptchaEnterpriseService', - filename: './recaptcha-enterprise-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - 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[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore deleted file mode 100644 index 521dc25..0000000 --- a/owl-bot-staging/v1beta1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js deleted file mode 100644 index b6e3bb5..0000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/recaptcha-enterprise', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js deleted file mode 100644 index 50bc7f7..0000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2021 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js deleted file mode 100644 index 84f4713..0000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md deleted file mode 100644 index 57a5e16..0000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Recaptchaenterprise: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json deleted file mode 100644 index 29a223b..0000000 --- a/owl-bot-staging/v1beta1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index 0720dd0..0000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/recaptcha-enterprise", - "version": "0.1.0", - "description": "Recaptchaenterprise client for Node.js", - "repository": "googleapis/nodejs-recaptchaenterprise", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google recaptchaenterprise", - "recaptchaenterprise", - "recaptcha enterprise service v1 beta1" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto b/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto deleted file mode 100644 index 099d304..0000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto +++ /dev/null @@ -1,442 +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 -// -// 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. -// - -syntax = "proto3"; - -package google.cloud.recaptchaenterprise.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/recaptchaenterprise/v1beta1;recaptchaenterprise"; -option java_multiple_files = true; -option java_outer_classname = "RecaptchaEnterpriseProto"; -option java_package = "com.google.recaptchaenterprise.v1beta1"; -option objc_class_prefix = "GCRE"; -option php_namespace = "Google\\Cloud\\RecaptchaEnterprise\\V1beta1"; -option ruby_package = "Google::Cloud::RecaptchaEnterprise::V1beta1"; - -// Service to determine the likelihood an event is legitimate. -service RecaptchaEnterpriseServiceV1Beta1 { - option (google.api.default_host) = "recaptchaenterprise.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates an Assessment of the likelihood an event is legitimate. - rpc CreateAssessment(CreateAssessmentRequest) returns (Assessment) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/assessments" - body: "assessment" - }; - option (google.api.method_signature) = "parent,assessment"; - } - - // Annotates a previously created Assessment to provide additional information - // on whether the event turned out to be authentic or fradulent. - rpc AnnotateAssessment(AnnotateAssessmentRequest) returns (AnnotateAssessmentResponse) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/assessments/*}:annotate" - body: "*" - }; - option (google.api.method_signature) = "name,annotation"; - } - - // Creates a new reCAPTCHA Enterprise key. - rpc CreateKey(CreateKeyRequest) returns (Key) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*}/keys" - body: "key" - }; - } - - // Returns the list of all keys that belong to a project. - rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*}/keys" - }; - } - - // Returns the specified key. - rpc GetKey(GetKeyRequest) returns (Key) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/keys/*}" - }; - } - - // Updates the specified key. - rpc UpdateKey(UpdateKeyRequest) returns (Key) { - option (google.api.http) = { - patch: "/v1beta1/{key.name=projects/*/keys/*}" - body: "key" - }; - } - - // Deletes the specified key. - rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/keys/*}" - }; - } -} - -// The create assessment request message. -message CreateAssessmentRequest { - // Required. The name of the project in which the assessment will be created, - // in the format "projects/{project_number}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The assessment details. - Assessment assessment = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request message to annotate an Assessment. -message AnnotateAssessmentRequest { - // Enum that reprensents the types of annotations. - enum 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; - } - - // Required. The resource name of the Assessment, in the format - // "projects/{project_number}/assessments/{assessment_id}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - } - ]; - - // Required. The annotation that will be assigned to the Event. - Annotation annotation = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Empty response for AnnotateAssessment. -message AnnotateAssessmentResponse { - -} - -// A recaptcha assessment resource. -message Assessment { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Assessment" - pattern: "projects/{project}/assessments/{assessment}" - }; - - // LINT.IfChange(classification_reason) - // Reasons contributing to the risk analysis verdict. - enum 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; - } - - // Output only. The resource name for the Assessment in the format - // "projects/{project_number}/assessments/{assessment_id}". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The event being assessed. - Event event = 2; - - // 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). - float score = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Properties of the provided event token. - TokenProperties token_properties = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Reasons contributing to the risk analysis verdict. - repeated ClassificationReason reasons = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -message Event { - // Optional. The user response token provided by the reCAPTCHA client-side integration - // on your site. - string token = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The site key that was used to invoke reCAPTCHA on your site and generate - // the token. - string site_key = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The user agent present in the request from the user's device related to - // this event. - string user_agent = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The IP address in the request from the user's device related to this event. - string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL]; - - // 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. - string expected_action = 5 [(google.api.field_behavior) = OPTIONAL]; -} - -message TokenProperties { - // LINT.IfChange - // Enum that represents the types of invalid token reasons. - enum 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; - } - - // Whether the provided user response token is valid. - bool valid = 1; - - // Reason associated with the response when valid = false. - InvalidReason invalid_reason = 2; - - // The timestamp corresponding to the generation of the token. - google.protobuf.Timestamp create_time = 3; - - // The hostname of the page on which the token was generated. - string hostname = 4; - - // Action name provided at token generation. - string action = 5; -} - -// The create key request message. -message CreateKeyRequest { - // Required. The name of the project in which the key will be created, in the - // format "projects/{project_number}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. Information to create a reCAPTCHA Enterprise key. - Key key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The list keys request message. -message ListKeysRequest { - // Required. The name of the project that contains the keys that will be - // listed, in the format "projects/{project_number}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Optional. The maximum number of keys to return. Default is 10. Max limit is - // 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The next_page_token value returned from a previous. - // ListKeysRequest, if any. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Response to request to list keys in a project. -message ListKeysResponse { - // Key details. - repeated Key keys = 1; - - // Token to retrieve the next page of results. It is set to empty if no keys - // remain in results. - string next_page_token = 2; -} - -// The get key request message. -message GetKeyRequest { - // Required. The name of the requested key, in the format - // "projects/{project_number}/keys/{key_id}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// The update key request message. -message UpdateKeyRequest { - // Required. The key to update. - Key key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The mask to control which field of the key get updated. If the mask is not - // present, all fields will be updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// The delete key request message. -message DeleteKeyRequest { - // Required. The name of the key to be deleted, in the format - // "projects/{project_number}/keys/{key_id}". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Key" - } - ]; -} - -// A key used to identify and configure applications (web and/or mobile) that -// use reCAPTCHA Enterprise. -message Key { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Key" - pattern: "projects/{project}/keys/{key}" - }; - - // The resource name for the Key in the format - // "projects/{project_number}/keys/{key_id}". - string name = 1; - - // Human-readable display name of this key. Modifiable by user. - string display_name = 2; - - // Platform specific settings for this key. The key can only be used on one - // platform, the one it has settings for. - oneof platform_settings { - // Settings for keys that can be used by websites. - WebKeySettings web_settings = 3; - - // Settings for keys that can be used by Android apps. - AndroidKeySettings android_settings = 4; - - // Settings for keys that can be used by iOS apps. - IOSKeySettings ios_settings = 5; - } -} - -// Settings specific to keys that can be used by websites. -message WebKeySettings { - // Enum that represents the integration types for web keys. - enum 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; - } - - // Enum that represents the possible challenge frequency and difficulty - // configurations for a web key. - enum 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; - } - - // Whether allowed_domains is enforced or not. - bool enforce_allowed_domains = 3; - - // 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' - repeated string allowed_domains = 1; - - // Whether this key can be used on AMP (Accelerated Mobile Pages) websites. - bool allow_amp_traffic = 2; - - // Required. Describes how this key is integrated with the website. - IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED]; - - // 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. - ChallengeSecurityPreference challenge_security_preference = 5; -} - -// Settings specific to keys that can be used by Android apps. -message AndroidKeySettings { - // Android package names of apps allowed to use the key. - // Example: 'com.companyname.appname' - repeated string allowed_package_names = 1; -} - -// Settings specific to keys that can be used by iOS apps. -message IOSKeySettings { - // iOS bundle ids of apps allowed to use the key. - // Example: 'com.companyname.productname.appname' - repeated string allowed_bundle_ids = 1; -} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts deleted file mode 100644 index 2c2d807..0000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 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; -type RecaptchaEnterpriseServiceV1Beta1Client = v1beta1.RecaptchaEnterpriseServiceV1Beta1Client; -export {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; -export default {v1beta1, RecaptchaEnterpriseServiceV1Beta1Client}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 7a2089e..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.recaptchaenterprise.v1beta1", - "libraryPackage": "@google-cloud/recaptcha-enterprise", - "services": { - "RecaptchaEnterpriseServiceV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecaptchaEnterpriseServiceV1Beta1Client", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 6314ef6..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2021 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. ** - -export {RecaptchaEnterpriseServiceV1Beta1Client} from './recaptcha_enterprise_service_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts deleted file mode 100644 index 9de4fed..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ /dev/null @@ -1,1044 +0,0 @@ -// Copyright 2021 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. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -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 _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recaptchaEnterpriseServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecaptchaEnterpriseServiceV1Beta1Client. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @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 {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // 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 this._gaxModule.PathTemplate( - 'projects/{project}/assessments/{assessment}' - ), - keyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/keys/{key}' - ), - projectPathTemplate: new this._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 this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') - }; - - // Put together the default options sent with requests. - this._defaults = this._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 = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.recaptchaEnterpriseServiceV1Beta1Stub) { - return this.recaptchaEnterpriseServiceV1Beta1Stub; - } - - // Put together the "service stub" for - // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. - this.recaptchaEnterpriseServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, - this._opts, this._providedCustomServicePath) 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 callPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.recaptchaEnterpriseServiceV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'recaptchaenterprise.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - 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. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createAssessment(request); - */ - createAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.createAssessment(request, options, callback); - } - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; - annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.annotateAssessment(request); - */ - annotateAssessment( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.annotateAssessment(request, options, callback); - } - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; - createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createKey(request); - */ - createKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.createKey(request, options, callback); - } - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; - getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getKey(request); - */ - getKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.getKey(request, options, callback); - } - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; - updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.updateKey(request); - */ - updateKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.updateKey(request, options, callback); - } - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; - deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|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}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.deleteKey(request); - */ - deleteKey( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.deleteKey(request, options, callback); - } - - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): void; - listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): 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 will perform 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. - * Note that it can affect your quota. - * We recommend using `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listKeys( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 || '', - }); - this.initialize(); - return this.innerApiCalls.listKeys(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @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. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listKeysStream( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: CallOptions): - Transform{ - 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 || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listKeys.createStream( - this.innerApiCalls.listKeys as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listKeys`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @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 {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listKeysAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listKeysAsync( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: CallOptions): - AsyncIterable{ - 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 || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listKeys.asyncIterate( - this.innerApiCalls['listKeys'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * 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; - } - - /** - * 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; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.recaptchaEnterpriseServiceV1Beta1Stub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json deleted file mode 100644 index 726aae1..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "interfaces": { - "google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AnnotateAssessment": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListKeys": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteKey": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json deleted file mode 100644 index 35d2e75..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto" -] diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 54439a4..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); - -function main() { - const recaptchaEnterpriseServiceV1Beta1Client = new recaptchaenterprise.RecaptchaEnterpriseServiceV1Beta1Client(); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 9d4654c..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 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 {RecaptchaEnterpriseServiceV1Beta1Client} from '@google-cloud/recaptcha-enterprise'; - -// check that the client class type name can be used -function doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(client: RecaptchaEnterpriseServiceV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const recaptchaEnterpriseServiceV1Beta1Client = new RecaptchaEnterpriseServiceV1Beta1Client(); - doStuffWithRecaptchaEnterpriseServiceV1Beta1Client(recaptchaEnterpriseServiceV1Beta1Client); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts deleted file mode 100644 index 1f850b5..0000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 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'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts deleted file mode 100644 index c00561a..0000000 --- a/owl-bot-staging/v1beta1/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,1006 +0,0 @@ -// Copyright 2021 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 protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as recaptchaenterpriseservicev1beta1Module from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -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); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceV1Beta1Stub); - }); - - it('has close method', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAssessment(request), expectedError); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateAssessment(request), expectedError); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createKey', () => { - it('invokes createKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); - const [response] = await client.createKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createKey(request), expectedError); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getKey', () => { - it('invokes getKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); - const [response] = await client.getKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKey(request), expectedError); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('updateKey', () => { - it('invokes updateKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateKey(request), expectedError); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('deleteKey', () => { - it('invokes deleteKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKey( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteKey(request), expectedError); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('listKeys', () => { - it('invokes listKeys without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listKeys(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listKeys without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeys( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listKeys with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKeys(request), expectedError); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listKeysStream without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listKeysStream with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listKeys without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; - const iterable = client.listKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listKeys with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('key', () => { - const fakePath = "/rendered/path/key"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.keyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyPath', () => { - const result = client.keyPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyName', () => { - const result = client.matchProjectFromKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromKeyName', () => { - const result = client.matchKeyFromKeyName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js deleted file mode 100644 index a5030d6..0000000 --- a/owl-bot-staging/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'RecaptchaEnterpriseServiceV1Beta1', - filename: './recaptcha-enterprise-service-v1-beta1.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - 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[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1/recaptcha_enterprise_service_client.ts b/src/v1/recaptcha_enterprise_service_client.ts index 23ccb56..ce4b941 100644 --- a/src/v1/recaptcha_enterprise_service_client.ts +++ b/src/v1/recaptcha_enterprise_service_client.ts @@ -132,6 +132,12 @@ export class RecaptchaEnterpriseServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. if (servicePath === staticMembers.servicePath) { this.auth.defaultScopes = staticMembers.scopes; diff --git a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index b2533d8..886beb8 100644 --- a/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -132,6 +132,12 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. if (servicePath === staticMembers.servicePath) { this.auth.defaultScopes = staticMembers.scopes;