From 98c10149133a8e150bc4cffcadb60740571c425f Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 7 Dec 2021 01:50:23 +0000 Subject: [PATCH 1/2] feat: add new reCAPTCHA Enterprise fraud annotations PiperOrigin-RevId: 414549384 Source-Link: https://github.com/googleapis/googleapis/commit/9b9da22ee21750793c110aa98eeb63034c1484ca Source-Link: https://github.com/googleapis/googleapis-gen/commit/e4e3b2c01ce675c100ed54519cad3274ea20a8a2 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTRlM2IyYzAxY2U2NzVjMTAwZWQ1NDUxOWNhZDMyNzRlYTIwYThhMiJ9 --- owl-bot-staging/v1/.eslintignore | 7 + 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 | 880 ++++++++ ..._enterprise_service.annotate_assessment.js | 72 + ...ha_enterprise_service.create_assessment.js | 59 + ...recaptcha_enterprise_service.create_key.js | 59 + ...recaptcha_enterprise_service.delete_key.js | 54 + .../recaptcha_enterprise_service.get_key.js | 54 + ...ecaptcha_enterprise_service.get_metrics.js | 54 + .../recaptcha_enterprise_service.list_keys.js | 66 + ....list_related_account_group_memberships.js | 71 + ...ise_service.list_related_account_groups.js | 71 + ...ecaptcha_enterprise_service.migrate_key.js | 54 + ...earch_related_account_group_memberships.js | 78 + ...recaptcha_enterprise_service.update_key.js | 58 + owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 159 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../v1/recaptcha_enterprise_service_client.ts | 1953 ++++++++++++++++ ...tcha_enterprise_service_client_config.json | 81 + ...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 | 1965 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta1/.eslintignore | 7 + 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 ++++ ...se_service_v1_beta1.annotate_assessment.js | 59 + ...rise_service_v1_beta1.create_assessment.js | 59 + ..._enterprise_service_v1_beta1.create_key.js | 59 + ..._enterprise_service_v1_beta1.delete_key.js | 54 + ...cha_enterprise_service_v1_beta1.get_key.js | 54 + ...a_enterprise_service_v1_beta1.list_keys.js | 66 + ..._enterprise_service_v1_beta1.update_key.js | 58 + 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 | 1042 +++++++++ ...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 + 63 files changed, 9739 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/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js 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/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js 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..cfc348e --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ 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..0121dfa --- /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": 5 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 0000000..8b0a764 --- /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.28.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.32", + "@types/sinon": "^10.0.6", + "c8": "^7.10.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^2.14.5", + "mocha": "^9.1.3", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.2", + "ts-loader": "^9.2.6", + "typescript": "^4.4.4", + "webpack": "^5.62.1", + "webpack-cli": "^4.9.1" + }, + "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..1be736a --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto @@ -0,0 +1,880 @@ +// 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 +// +// 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 fraudulent. + 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/*}" + }; + } + + // Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. + // Once a key is migrated, it can be used from either product. SiteVerify + // requests are billed as CreateAssessment calls. You must be + // authenticated as one of the current owners of the reCAPTCHA Site Key, and + // your user must have the reCAPTCHA Enterprise Admin IAM role in the + // destination project. + rpc MigrateKey(MigrateKeyRequest) returns (Key) { + option (google.api.http) = { + post: "/v1/{name=projects/*/keys/*}:migrate" + body: "*" + }; + } + + // Get some aggregated metrics for a Key. This data can be used to build + // dashboards. + rpc GetMetrics(GetMetricsRequest) returns (Metrics) { + option (google.api.http) = { + get: "/v1/{name=projects/*/keys/*/metrics}" + }; + option (google.api.method_signature) = "name"; + } + + // List groups of related accounts. + rpc ListRelatedAccountGroups(ListRelatedAccountGroupsRequest) returns (ListRelatedAccountGroupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/relatedaccountgroups" + }; + option (google.api.method_signature) = "parent"; + } + + // Get the memberships in a group of related accounts. + rpc ListRelatedAccountGroupMemberships(ListRelatedAccountGroupMembershipsRequest) returns (ListRelatedAccountGroupMembershipsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/relatedaccountgroups/*}/memberships" + }; + option (google.api.method_signature) = "parent"; + } + + // Search group memberships related to a given account. + rpc SearchRelatedAccountGroupMemberships(SearchRelatedAccountGroupMembershipsRequest) returns (SearchRelatedAccountGroupMembershipsResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/relatedaccountgroupmemberships:search" + body: "*" + }; + option (google.api.method_signature) = "parent,hashed_account_id"; + } +} + +// 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 represents 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. Deprecated, prefer indicating + // CORRECT_PASSWORD through the reasons field instead. + PASSWORD_CORRECT = 3 [deprecated = true]; + + // Provides information that the event was related to a login event in which + // the user typed the incorrect password. Deprecated, prefer indicating + // INCORRECT_PASSWORD through the reasons field instead. + PASSWORD_INCORRECT = 4 [deprecated = true]; + } + + // Enum that represents potential reasons for annotating an assessment. + enum Reason { + // Default unspecified reason. + REASON_UNSPECIFIED = 0; + + // Indicates a chargeback was issued for the transaction associated with the + // assessment, with no other details. When possible, specify the type by + // using CHARGEBACK_FRAUD or CHARGEBACK_DISPUTE instead. + CHARGEBACK = 1; + + // Indicates a chargeback related to an alleged unauthorized transaction + // from the perspective of the cardholder (for example, the card number was + // stolen). + CHARGEBACK_FRAUD = 8; + + // Indicates a chargeback related to the cardholder having provided their + // card but allegedly not being satisfied with the purchase + // (for example, misrepresentation, attempted cancellation). + CHARGEBACK_DISPUTE = 9; + + // Indicates the transaction associated with the assessment is suspected of + // being fraudulent based on the payment method, billing details, shipping + // address or other transaction information. + PAYMENT_HEURISTICS = 2; + + // Indicates that the user was served a 2FA challenge. An old assessment + // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been + // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. + // This is equivalent to `FAILED_TWO_FACTOR`. + INITIATED_TWO_FACTOR = 7; + + // Indicates that the user passed a 2FA challenge. + PASSED_TWO_FACTOR = 3; + + // Indicates that the user failed a 2FA challenge. + FAILED_TWO_FACTOR = 4; + + // Indicates the user provided the correct password. + CORRECT_PASSWORD = 5; + + // Indicates the user provided an incorrect password. + INCORRECT_PASSWORD = 6; + } + + // 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" + } + ]; + + // Optional. The annotation that will be assigned to the Event. This field can be left + // empty to provide reasons that apply to an event without concluding whether + // the event is legitimate or fraudulent. + Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional reasons for the annotation that will be assigned to the Event. + repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional unique stable hashed user identifier to apply to the assessment. + // This is an alternative to setting the hashed_account_id in + // CreateAssessment, for example when the account identifier is not yet known + // in the initial request. It is recommended that the identifier is hashed + // using hmac-sha256 with stable secret. + bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// 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]; + + // Assessment returned by Account Defender when a hashed_account_id is + // provided. + AccountDefenderAssessment account_defender_assessment = 6; +} + +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]; + + // Optional. Optional unique stable hashed user identifier for the request. The + // identifier should ideally be hashed using sha256 with stable secret. + bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; +} + +// Risk analysis result for an event. +message RiskAnalysis { + // 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 { + // 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; + + // A retriable error (such as network failure) occurred on the browser. + // Could easily be simulated by an attacker. + BROWSER_ERROR = 6; + } + + // 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; +} + +// Account Defender risk assessment. +message AccountDefenderAssessment { + // Labels returned by Account Defender for this request. + enum AccountDefenderLabel { + // Default unspecified type. + ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; + + // The request matches a known good profile for the user. + PROFILE_MATCH = 1; + + // The request is potentially a suspicious login event and should be further + // verified either via multi-factor authentication or another system. + SUSPICIOUS_LOGIN_ACTIVITY = 2; + + // The request matched a profile that previously had suspicious account + // creation behavior. This could mean this is a fake account. + SUSPICIOUS_ACCOUNT_CREATION = 3; + + // The account in the request has a high number of related accounts. It does + // not necessarily imply that the account is bad but could require + // investigating. + RELATED_ACCOUNTS_NUMBER_HIGH = 4; + } + + // Labels for this request. + repeated AccountDefenderLabel labels = 1; +} + +// 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 fields 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" + } + ]; +} + +// The migrate key request message. +message MigrateKeyRequest { + // Required. The name of the key to be migrated, 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 get metrics request message. +message GetMetricsRequest { + // Required. The name of the requested metrics, in the format + // "projects/{project}/keys/{key}/metrics". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/Metrics" + } + ]; +} + +// Metrics for a single Key. +message Metrics { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/Metrics" + pattern: "projects/{project}/keys/{key}/metrics" + }; + + // Output only. The name of the metrics, in the format + // "projects/{project}/keys/{key}/metrics". + string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Inclusive start time aligned to a day (UTC). + google.protobuf.Timestamp start_time = 1; + + // Metrics will be continuous and in order by dates, and in the granularity + // of day. All Key types should have score-based data. + repeated ScoreMetrics score_metrics = 2; + + // Metrics will be continuous and in order by dates, and in the granularity + // of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + // challenge-based data. + repeated ChallengeMetrics challenge_metrics = 3; +} + +// 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; + } + + // See + // Creating and managing labels. + map labels = 6; + + // The timestamp corresponding to the creation of this Key. + google.protobuf.Timestamp create_time = 7; + + // Options for user acceptance testing. + TestingOptions testing_options = 9; +} + +// Options for user acceptance testing. +message TestingOptions { + // Enum that represents the challenge option for challenge-based (CHECKBOX, + // INVISIBLE) testing keys. + enum TestingChallenge { + // Perform the normal risk analysis and return either nocaptcha or a + // challenge depending on risk and trust factors. + TESTING_CHALLENGE_UNSPECIFIED = 0; + + // Challenge requests for this key always return a nocaptcha, which + // does not require a solution. + NOCAPTCHA = 1; + + // Challenge requests for this key always return an unsolvable + // challenge. + UNSOLVABLE_CHALLENGE = 2; + } + + // All assessments for this Key will return this score. Must be between 0 + // (likely not legitimate) and 1 (likely legitimate) inclusive. + float testing_score = 1; + + // For challenge-based keys only (CHECKBOX, INVISIBLE), all challenge requests + // for this site will return nocaptcha if NOCAPTCHA, or an unsolvable + // challenge if CHALLENGE. + TestingChallenge testing_challenge = 2; +} + +// 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; + + // If set to true, the key can be used on AMP (Accelerated Mobile Pages) + // websites. This is supported only for the SCORE integration type. + 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 and INVISIBLE. + ChallengeSecurityPreference challenge_security_preference = 5; +} + +// Settings specific to keys that can be used by Android apps. +message AndroidKeySettings { + // If set to true, allowed_package_names are not enforced. + bool allow_all_package_names = 2; + + // 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 { + // If set to true, allowed_bundle_ids are not enforced. + bool allow_all_bundle_ids = 2; + + // iOS bundle ids of apps allowed to use the key. + // Example: 'com.companyname.productname.appname' + repeated string allowed_bundle_ids = 1; +} + +// Score distribution. +message ScoreDistribution { + // Map key is score value multiplied by 100. The scores are discrete values + // between [0, 1]. The maximum number of buckets is on order of a few dozen, + // but typically much lower (ie. 10). + map score_buckets = 1; +} + +// Metrics related to scoring. +message ScoreMetrics { + // Aggregated score metrics for all traffic. + ScoreDistribution overall_metrics = 1; + + // Action-based metrics. The map key is the action name which specified by the + // site owners at time of the "execute" client-side call. + // Populated only for SCORE keys. + map action_metrics = 2; +} + +// Metrics related to challenges. +message ChallengeMetrics { + // Count of reCAPTCHA checkboxes or badges rendered. This is mostly equivalent + // to a count of pageloads for pages that include reCAPTCHA. + int64 pageload_count = 1; + + // Count of nocaptchas (successful verification without a challenge) issued. + int64 nocaptcha_count = 2; + + // Count of submitted challenge solutions that were incorrect or otherwise + // deemed suspicious such that a subsequent challenge was triggered. + int64 failed_count = 3; + + // Count of nocaptchas (successful verification without a challenge) plus + // submitted challenge solutions that were correct and resulted in + // verification. + int64 passed_count = 4; +} + +// The request message to list memberships in a related account group. +message ListRelatedAccountGroupMembershipsRequest { + // Required. The resource name for the related account group in the format + // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // Optional. The maximum number of accounts to return. The service may return fewer than + // this value. + // If unspecified, at most 50 accounts will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` + // call. + // + // When paginating, all other parameters provided to + // `ListRelatedAccountGroupMemberships` must match the call that provided the + // page token. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `ListRelatedAccountGroupMemberships` call. +message ListRelatedAccountGroupMembershipsResponse { + // The memberships listed by the query. + repeated RelatedAccountGroupMembership related_account_group_memberships = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// The request message to list related account groups. +message ListRelatedAccountGroupsRequest { + // Required. The name of the project to list related account groups from, in the format + // "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + } + ]; + + // Optional. The maximum number of groups to return. The service may return fewer than + // this value. + // If unspecified, at most 50 groups will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListRelatedAccountGroups` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // `ListRelatedAccountGroups` must match the call that provided the page + // token. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `ListRelatedAccountGroups` call. +message ListRelatedAccountGroupsResponse { + // The groups of related accounts listed by the query. + repeated RelatedAccountGroup related_account_groups = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// The request message to search related account group memberships. +message SearchRelatedAccountGroupMembershipsRequest { + // Required. The name of the project to search related account group memberships from, + // in the format "projects/{project}". + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // Optional. The unique stable hashed user identifier we should search connections to. + // The identifier should correspond to a `hashed_account_id` provided in a + // previous CreateAssessment or AnnotateAssessment call. + bytes hashed_account_id = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of groups to return. The service may return fewer than + // this value. + // If unspecified, at most 50 groups will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous + // `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + // subsequent page. + // + // When paginating, all other parameters provided to + // `SearchRelatedAccountGroupMemberships` must match the call that provided + // the page token. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response to a `SearchRelatedAccountGroupMemberships` call. +message SearchRelatedAccountGroupMembershipsResponse { + // The queried memberships. + repeated RelatedAccountGroupMembership related_account_group_memberships = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// A membership in a group of related accounts. +message RelatedAccountGroupMembership { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}" + }; + + // Required. The resource name for this membership in the format + // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" + } + ]; + + // The unique stable hashed user identifier of the member. The identifier + // corresponds to a `hashed_account_id` provided in a previous + // CreateAssessment or AnnotateAssessment call. + bytes hashed_account_id = 2; +} + +// A group of related accounts. +message RelatedAccountGroup { + option (google.api.resource) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}" + }; + + // Required. The resource name for the related account group in the format + // `projects/{project}/relatedaccountgroups/{related_account_group}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" + } + ]; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js new file mode 100644 index 0000000..d3bca76 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js @@ -0,0 +1,72 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Assessment, in the format + * "projects/{project}/assessments/{assessment}". + */ + // const name = 'abc123' + /** + * Optional. The annotation that will be assigned to the Event. This field can be left + * empty to provide reasons that apply to an event without concluding whether + * the event is legitimate or fraudulent. + */ + // const annotation = {} + /** + * Optional. Optional reasons for the annotation that will be assigned to the Event. + */ + // const reasons = 1234 + /** + * Optional. Optional unique stable hashed user identifier to apply to the assessment. + * This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + */ + // const hashedAccountId = 'Buffer.from('string')' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callAnnotateAssessment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.annotateAssessment(request); + console.log(response); + } + + callAnnotateAssessment(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js new file mode 100644 index 0000000..fce5aa2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js @@ -0,0 +1,59 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, assessment) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Required. The assessment details. + */ + // const assessment = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callCreateAssessment() { + // Construct request + const request = { + parent, + assessment, + }; + + // Run request + const response = await recaptchaenterpriseClient.createAssessment(request); + console.log(response); + } + + callCreateAssessment(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js new file mode 100644 index 0000000..1c51666 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js @@ -0,0 +1,59 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, key) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project in which the key will be created, in the + * format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Required. Information to create a reCAPTCHA Enterprise key. + */ + // const key = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callCreateKey() { + // Construct request + const request = { + parent, + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.createKey(request); + console.log(response); + } + + callCreateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js new file mode 100644 index 0000000..e3101e8 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the key to be deleted, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callDeleteKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.deleteKey(request); + console.log(response); + } + + callDeleteKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js new file mode 100644 index 0000000..12bce4b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the requested key, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callGetKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.getKey(request); + console.log(response); + } + + callGetKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js new file mode 100644 index 0000000..be33e23 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the requested metrics, in the format + * "projects/{project}/keys/{key}/metrics". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callGetMetrics() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.getMetrics(request); + console.log(response); + } + + callGetMetrics(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js new file mode 100644 index 0000000..5557018 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js @@ -0,0 +1,66 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + */ + // const pageSize = 1234 + /** + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListKeys(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js new file mode 100644 index 0000000..83c71d0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js @@ -0,0 +1,71 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of accounts to return. The service may return fewer than + * this value. + * If unspecified, at most 50 accounts will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` + * call. + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListRelatedAccountGroupMemberships() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRelatedAccountGroupMemberships(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js new file mode 100644 index 0000000..c039342 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js @@ -0,0 +1,71 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project to list related account groups from, in the format + * "projects/{project}". + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callListRelatedAccountGroups() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRelatedAccountGroups(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js new file mode 100644 index 0000000..a84bab6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the key to be migrated, in the format + * "projects/{project}/keys/{key}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callMigrateKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.migrateKey(request); + console.log(response); + } + + callMigrateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js new file mode 100644 index 0000000..9f6c800 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js @@ -0,0 +1,78 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project to search related account group memberships from, + * in the format "projects/{project}". + */ + // const parent = 'abc123' + /** + * Optional. The unique stable hashed user identifier we should search connections to. + * The identifier should correspond to a `hashed_account_id` provided in a + * previous CreateAssessment or AnnotateAssessment call. + */ + // const hashedAccountId = 'Buffer.from('string')' + /** + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callSearchRelatedAccountGroupMemberships() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchRelatedAccountGroupMemberships(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js new file mode 100644 index 0000000..eae0df5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js @@ -0,0 +1,58 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(key) { + // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The key to update. + */ + // const key = {} + /** + * Optional. The mask to control which fields of the key get updated. If the mask is not + * present, all fields will be updated. + */ + // const updateMask = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); + + async function callUpdateKey() { + // Construct request + const request = { + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.updateKey(request); + console.log(response); + } + + callUpdateKey(); + // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); 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..09321f2 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,159 @@ +{ + "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" + ] + }, + "MigrateKey": { + "methods": [ + "migrateKey" + ] + }, + "GetMetrics": { + "methods": [ + "getMetrics" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + }, + "ListRelatedAccountGroups": { + "methods": [ + "listRelatedAccountGroups", + "listRelatedAccountGroupsStream", + "listRelatedAccountGroupsAsync" + ] + }, + "ListRelatedAccountGroupMemberships": { + "methods": [ + "listRelatedAccountGroupMemberships", + "listRelatedAccountGroupMembershipsStream", + "listRelatedAccountGroupMembershipsAsync" + ] + }, + "SearchRelatedAccountGroupMemberships": { + "methods": [ + "searchRelatedAccountGroupMemberships", + "searchRelatedAccountGroupMembershipsStream", + "searchRelatedAccountGroupMembershipsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecaptchaEnterpriseServiceClient", + "rpcs": { + "CreateAssessment": { + "methods": [ + "createAssessment" + ] + }, + "AnnotateAssessment": { + "methods": [ + "annotateAssessment" + ] + }, + "CreateKey": { + "methods": [ + "createKey" + ] + }, + "GetKey": { + "methods": [ + "getKey" + ] + }, + "UpdateKey": { + "methods": [ + "updateKey" + ] + }, + "DeleteKey": { + "methods": [ + "deleteKey" + ] + }, + "MigrateKey": { + "methods": [ + "migrateKey" + ] + }, + "GetMetrics": { + "methods": [ + "getMetrics" + ] + }, + "ListKeys": { + "methods": [ + "listKeys", + "listKeysStream", + "listKeysAsync" + ] + }, + "ListRelatedAccountGroups": { + "methods": [ + "listRelatedAccountGroups", + "listRelatedAccountGroupsStream", + "listRelatedAccountGroupsAsync" + ] + }, + "ListRelatedAccountGroupMemberships": { + "methods": [ + "listRelatedAccountGroupMemberships", + "listRelatedAccountGroupMembershipsStream", + "listRelatedAccountGroupMembershipsAsync" + ] + }, + "SearchRelatedAccountGroupMemberships": { + "methods": [ + "searchRelatedAccountGroupMemberships", + "searchRelatedAccountGroupMembershipsStream", + "searchRelatedAccountGroupMembershipsAsync" + ] + } + } + } + } + } + } +} 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..8f7929e --- /dev/null +++ b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts @@ -0,0 +1,1953 @@ +// 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}' + ), + metricsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/keys/{key}/metrics' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + relatedAccountGroupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}' + ), + relatedAccountGroupMembershipPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}' + ), + }; + + // 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'), + listRelatedAccountGroups: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroups'), + listRelatedAccountGroupMemberships: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships'), + searchRelatedAccountGroupMemberships: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships') + }; + + // 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', 'migrateKey', 'getMetrics', 'listRelatedAccountGroups', 'listRelatedAccountGroupMemberships', 'searchRelatedAccountGroupMemberships']; + 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 -- + // ------------------- +/** + * 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 include:samples/generated/v1/recaptcha_enterprise_service.create_assessment.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async + */ + 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; + 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); + } +/** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fraudulent. + * + * @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] + * Optional. The annotation that will be assigned to the Event. This field can be left + * empty to provide reasons that apply to an event without concluding whether + * the event is legitimate or fraudulent. + * @param {number[]} [request.reasons] + * Optional. Optional reasons for the annotation that will be assigned to the Event. + * @param {Buffer} [request.hashedAccountId] + * Optional. Optional unique stable hashed user identifier to apply to the assessment. + * This is an alternative to setting the hashed_account_id in + * CreateAssessment, for example when the account identifier is not yet known + * in the initial request. It is recommended that the identifier is hashed + * using hmac-sha256 with stable secret. + * @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 include:samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1/recaptcha_enterprise_service.create_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1/recaptcha_enterprise_service.get_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async + */ + 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; + 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); + } +/** + * 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 fields 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 include:samples/generated/v1/recaptcha_enterprise_service.update_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1/recaptcha_enterprise_service.delete_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async + */ + 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; + 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); + } +/** + * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. + * Once a key is migrated, it can be used from either product. SiteVerify + * requests are billed as CreateAssessment calls. You must be + * authenticated as one of the current owners of the reCAPTCHA Site Key, and + * your user must have the reCAPTCHA Enterprise Admin IAM role in the + * destination project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be migrated, 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 include:samples/generated/v1/recaptcha_enterprise_service.migrate_key.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async + */ + migrateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined + ]>; + migrateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): void; + migrateKey( + request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): void; + migrateKey( + request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|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.migrateKey(request, options, callback); + } +/** + * Get some aggregated metrics for a Key. This data can be used to build + * dashboards. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested metrics, in the format + * "projects/{project}/keys/{key}/metrics". + * @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 [Metrics]{@link google.cloud.recaptchaenterprise.v1.Metrics}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/recaptcha_enterprise_service.get_metrics.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async + */ + getMetrics( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined + ]>; + getMetrics( + request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): void; + getMetrics( + request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): void; + getMetrics( + request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IMetrics, + protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|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.getMetrics(request, options, callback); + } + + /** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @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, + 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; + 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 defaultCallSettings = this._defaults['listKeys']; + const callSettings = defaultCallSettings.merge(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 include:samples/generated/v1/recaptcha_enterprise_service.list_keys.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async + */ + 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 || '', + }); + const defaultCallSettings = this._defaults['listKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listKeys.asyncIterate( + this.innerApiCalls['listKeys'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * List groups of related accounts. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project to list related account groups from, in the format + * "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + * @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 [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup}. + * 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 `listRelatedAccountGroupsAsync()` + * 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. + */ + listRelatedAccountGroups( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse + ]>; + listRelatedAccountGroups( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; + listRelatedAccountGroups( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; + listRelatedAccountGroups( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse + ]>|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.listRelatedAccountGroups(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 to list related account groups from, in the format + * "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + * @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 [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup} 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 `listRelatedAccountGroupsAsync()` + * 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. + */ + listRelatedAccountGroupsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + 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 defaultCallSettings = this._defaults['listRelatedAccountGroups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroups.createStream( + this.innerApiCalls.listRelatedAccountGroups as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRelatedAccountGroups`, 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 to list related account groups from, in the format + * "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroups` must match the call that provided the page + * token. + * @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 + * [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup}. 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 include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async + */ + listRelatedAccountGroupsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, + 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 || '', + }); + const defaultCallSettings = this._defaults['listRelatedAccountGroups']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroups.asyncIterate( + this.innerApiCalls['listRelatedAccountGroups'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Get the memberships in a group of related accounts. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service may return fewer than + * this value. + * If unspecified, at most 50 accounts will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` + * call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. + * 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 `listRelatedAccountGroupMembershipsAsync()` + * 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. + */ + listRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse + ]>; + listRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + listRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + listRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse + ]>|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.listRelatedAccountGroupMemberships(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 resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service may return fewer than + * this value. + * If unspecified, at most 50 accounts will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` + * call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership} 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 `listRelatedAccountGroupMembershipsAsync()` + * 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. + */ + listRelatedAccountGroupMembershipsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + 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 defaultCallSettings = this._defaults['listRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroupMemberships.createStream( + this.innerApiCalls.listRelatedAccountGroupMemberships as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRelatedAccountGroupMemberships`, 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 resource name for the related account group in the format + * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of accounts to return. The service may return fewer than + * this value. + * If unspecified, at most 50 accounts will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` + * call. + * + * When paginating, all other parameters provided to + * `ListRelatedAccountGroupMemberships` must match the call that provided the + * page token. + * @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 + * [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. 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 include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async + */ + listRelatedAccountGroupMembershipsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, + 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 || '', + }); + const defaultCallSettings = this._defaults['listRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate( + this.innerApiCalls['listRelatedAccountGroupMemberships'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Search group memberships related to a given account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project to search related account group memberships from, + * in the format "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search connections to. + * The identifier should correspond to a `hashed_account_id` provided in a + * previous CreateAssessment or AnnotateAssessment call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. + * 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 `searchRelatedAccountGroupMembershipsAsync()` + * 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. + */ + searchRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse + ]>; + searchRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + searchRelatedAccountGroupMemberships( + request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; + searchRelatedAccountGroupMemberships( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): + Promise<[ + protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, + protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse + ]>|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.searchRelatedAccountGroupMemberships(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 to search related account group memberships from, + * in the format "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search connections to. + * The identifier should correspond to a `hashed_account_id` provided in a + * previous CreateAssessment or AnnotateAssessment call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership} 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 `searchRelatedAccountGroupMembershipsAsync()` + * 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. + */ + searchRelatedAccountGroupMembershipsStream( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + 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 defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchRelatedAccountGroupMemberships.createStream( + this.innerApiCalls.searchRelatedAccountGroupMemberships as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchRelatedAccountGroupMemberships`, 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 to search related account group memberships from, + * in the format "projects/{project}". + * @param {Buffer} [request.hashedAccountId] + * Optional. The unique stable hashed user identifier we should search connections to. + * The identifier should correspond to a `hashed_account_id` provided in a + * previous CreateAssessment or AnnotateAssessment call. + * @param {number} [request.pageSize] + * Optional. The maximum number of groups to return. The service may return fewer than + * this value. + * If unspecified, at most 50 groups will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous + * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the + * subsequent page. + * + * When paginating, all other parameters provided to + * `SearchRelatedAccountGroupMemberships` must match the call that provided + * the page token. + * @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 + * [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. 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 include:samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js + * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async + */ + searchRelatedAccountGroupMembershipsAsync( + request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, + 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 || '', + }); + const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate( + this.innerApiCalls['searchRelatedAccountGroupMemberships'] 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 metrics resource name string. + * + * @param {string} project + * @param {string} key + * @returns {string} Resource name string. + */ + metricsPath(project:string,key:string) { + return this.pathTemplates.metricsPathTemplate.render({ + project: project, + key: key, + }); + } + + /** + * Parse the project from Metrics resource. + * + * @param {string} metricsName + * A fully-qualified path representing Metrics resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMetricsName(metricsName: string) { + return this.pathTemplates.metricsPathTemplate.match(metricsName).project; + } + + /** + * Parse the key from Metrics resource. + * + * @param {string} metricsName + * A fully-qualified path representing Metrics resource. + * @returns {string} A string representing the key. + */ + matchKeyFromMetricsName(metricsName: string) { + return this.pathTemplates.metricsPathTemplate.match(metricsName).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; + } + + /** + * Return a fully-qualified relatedAccountGroup resource name string. + * + * @param {string} project + * @param {string} relatedaccountgroup + * @returns {string} Resource name string. + */ + relatedAccountGroupPath(project:string,relatedaccountgroup:string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.render({ + project: project, + relatedaccountgroup: relatedaccountgroup, + }); + } + + /** + * Parse the project from RelatedAccountGroup resource. + * + * @param {string} relatedAccountGroupName + * A fully-qualified path representing RelatedAccountGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRelatedAccountGroupName(relatedAccountGroupName: string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).project; + } + + /** + * Parse the relatedaccountgroup from RelatedAccountGroup resource. + * + * @param {string} relatedAccountGroupName + * A fully-qualified path representing RelatedAccountGroup resource. + * @returns {string} A string representing the relatedaccountgroup. + */ + matchRelatedaccountgroupFromRelatedAccountGroupName(relatedAccountGroupName: string) { + return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).relatedaccountgroup; + } + + /** + * Return a fully-qualified relatedAccountGroupMembership resource name string. + * + * @param {string} project + * @param {string} relatedaccountgroup + * @param {string} membership + * @returns {string} Resource name string. + */ + relatedAccountGroupMembershipPath(project:string,relatedaccountgroup:string,membership:string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.render({ + project: project, + relatedaccountgroup: relatedaccountgroup, + membership: membership, + }); + } + + /** + * Parse the project from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).project; + } + + /** + * Parse the relatedaccountgroup from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the relatedaccountgroup. + */ + matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).relatedaccountgroup; + } + + /** + * Parse the membership from RelatedAccountGroupMembership resource. + * + * @param {string} relatedAccountGroupMembershipName + * A fully-qualified path representing RelatedAccountGroupMembership resource. + * @returns {string} A string representing the membership. + */ + matchMembershipFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { + return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).membership; + } + + /** + * 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..66fe297 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json @@ -0,0 +1,81 @@ +{ + "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" + }, + "MigrateKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetMetrics": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRelatedAccountGroups": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRelatedAccountGroupMemberships": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SearchRelatedAccountGroupMemberships": { + "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..6d2e82e --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts @@ -0,0 +1,1965 @@ +// 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('migrateKey', () => { + it('invokes migrateKey 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.MigrateKeyRequest()); + 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.migrateKey = stubSimpleCall(expectedResponse); + const [response] = await client.migrateKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes migrateKey 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.MigrateKeyRequest()); + 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.migrateKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.migrateKey( + 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.migrateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes migrateKey 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.MigrateKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.migrateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.migrateKey(request), expectedError); + assert((client.innerApiCalls.migrateKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getMetrics', () => { + it('invokes getMetrics 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.GetMetricsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Metrics()); + client.innerApiCalls.getMetrics = stubSimpleCall(expectedResponse); + const [response] = await client.getMetrics(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getMetrics 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.GetMetricsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Metrics()); + client.innerApiCalls.getMetrics = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMetrics( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IMetrics|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getMetrics as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getMetrics 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.GetMetricsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getMetrics = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getMetrics(request), expectedError); + assert((client.innerApiCalls.getMetrics 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('listRelatedAccountGroups', () => { + it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(expectedResponse); + const [response] = await client.listRelatedAccountGroups(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRelatedAccountGroups( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRelatedAccountGroups(request), expectedError); + assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRelatedAccountGroupsStream 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRelatedAccountGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { + 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.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listRelatedAccountGroupsStream 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRelatedAccountGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), + ]; + client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; + const iterable = client.listRelatedAccountGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRelatedAccountGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listRelatedAccountGroupMemberships', () => { + it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.listRelatedAccountGroupMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRelatedAccountGroupMemberships( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRelatedAccountGroupMemberships(request), expectedError); + assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listRelatedAccountGroupMembershipsStream 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + 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.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listRelatedAccountGroupMembershipsStream 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + const iterable = client.listRelatedAccountGroupMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRelatedAccountGroupMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('searchRelatedAccountGroupMemberships', () => { + it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.searchRelatedAccountGroupMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchRelatedAccountGroupMemberships( + request, + (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchRelatedAccountGroupMemberships(request), expectedError); + assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchRelatedAccountGroupMembershipsStream 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + 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.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); + assert.strictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes searchRelatedAccountGroupMembershipsStream 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchRelatedAccountGroupMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; + stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); + assert.strictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), + ]; + client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.searchRelatedAccountGroupMemberships.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('metrics', () => { + const fakePath = "/rendered/path/metrics"; + 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.metricsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.metricsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('metricsPath', () => { + const result = client.metricsPath("projectValue", "keyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.metricsPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMetricsName', () => { + const result = client.matchProjectFromMetricsName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchKeyFromMetricsName', () => { + const result = client.matchKeyFromMetricsName(fakePath); + assert.strictEqual(result, "keyValue"); + assert((client.pathTemplates.metricsPathTemplate.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)); + }); + }); + + describe('relatedAccountGroup', () => { + const fakePath = "/rendered/path/relatedAccountGroup"; + const expectedParameters = { + project: "projectValue", + relatedaccountgroup: "relatedaccountgroupValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.relatedAccountGroupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.relatedAccountGroupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('relatedAccountGroupPath', () => { + const result = client.relatedAccountGroupPath("projectValue", "relatedaccountgroupValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRelatedAccountGroupName', () => { + const result = client.matchProjectFromRelatedAccountGroupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRelatedaccountgroupFromRelatedAccountGroupName', () => { + const result = client.matchRelatedaccountgroupFromRelatedAccountGroupName(fakePath); + assert.strictEqual(result, "relatedaccountgroupValue"); + assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('relatedAccountGroupMembership', () => { + const fakePath = "/rendered/path/relatedAccountGroupMembership"; + const expectedParameters = { + project: "projectValue", + relatedaccountgroup: "relatedaccountgroupValue", + membership: "membershipValue", + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('relatedAccountGroupMembershipPath', () => { + const result = client.relatedAccountGroupMembershipPath("projectValue", "relatedaccountgroupValue", "membershipValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRelatedAccountGroupMembershipName', () => { + const result = client.matchProjectFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRelatedaccountgroupFromRelatedAccountGroupMembershipName', () => { + const result = client.matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "relatedaccountgroupValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMembershipFromRelatedAccountGroupMembershipName', () => { + const result = client.matchMembershipFromRelatedAccountGroupMembershipName(fakePath); + assert.strictEqual(result, "membershipValue"); + assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.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..cfc348e --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ 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..0121dfa --- /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": 5 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 0000000..a6f512d --- /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.28.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.32", + "@types/sinon": "^10.0.6", + "c8": "^7.10.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^2.14.5", + "mocha": "^9.1.3", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.2", + "ts-loader": "^9.2.6", + "typescript": "^4.4.4", + "webpack": "^5.62.1", + "webpack-cli": "^4.9.1" + }, + "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/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js new file mode 100644 index 0000000..a1b22b0 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js @@ -0,0 +1,59 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name, annotation) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + */ + // const name = 'abc123' + /** + * Required. The annotation that will be assigned to the Event. + */ + // const annotation = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callAnnotateAssessment() { + // Construct request + const request = { + name, + annotation, + }; + + // Run request + const response = await recaptchaenterpriseClient.annotateAssessment(request); + console.log(response); + } + + callAnnotateAssessment(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js new file mode 100644 index 0000000..3fc71f5 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js @@ -0,0 +1,59 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, assessment) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Required. The assessment details. + */ + // const assessment = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callCreateAssessment() { + // Construct request + const request = { + parent, + assessment, + }; + + // Run request + const response = await recaptchaenterpriseClient.createAssessment(request); + console.log(response); + } + + callCreateAssessment(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js new file mode 100644 index 0000000..6415203 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js @@ -0,0 +1,59 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent, key) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project in which the key will be created, in the + * format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Required. Information to create a reCAPTCHA Enterprise key. + */ + // const key = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callCreateKey() { + // Construct request + const request = { + parent, + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.createKey(request); + console.log(response); + } + + callCreateKey(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js new file mode 100644 index 0000000..14babc5 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the key to be deleted, in the format + * "projects/{project_number}/keys/{key_id}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callDeleteKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.deleteKey(request); + console.log(response); + } + + callDeleteKey(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js new file mode 100644 index 0000000..3dda3d9 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js @@ -0,0 +1,54 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(name) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the requested key, in the format + * "projects/{project_number}/keys/{key_id}". + */ + // const name = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callGetKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await recaptchaenterpriseClient.getKey(request); + console.log(response); + } + + callGetKey(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js new file mode 100644 index 0000000..61551fb --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js @@ -0,0 +1,66 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(parent) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + */ + // const pageSize = 1234 + /** + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + */ + // const pageToken = 'abc123' + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callListKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await recaptchaenterpriseClient.listKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListKeys(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js new file mode 100644 index 0000000..7910cec --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js @@ -0,0 +1,58 @@ +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +'use strict'; + +function main(key) { + // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The key to update. + */ + // const key = {} + /** + * Optional. The mask to control which field of the key get updated. If the mask is not + * present, all fields will be updated. + */ + // const updateMask = {} + + // Imports the Recaptchaenterprise library + const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; + + // Instantiates a client + const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); + + async function callUpdateKey() { + // Construct request + const request = { + key, + }; + + // Run request + const response = await recaptchaenterpriseClient.updateKey(request); + console.log(response); + } + + callUpdateKey(); + // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); 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..e1145d6 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -0,0 +1,1042 @@ +// 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 -- + // ------------------- +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async + */ + 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; + 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); + } +/** + * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async + */ + 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; + 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); + } + + /** + * 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, + 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; + 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 defaultCallSettings = this._defaults['listKeys']; + const callSettings = defaultCallSettings.merge(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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js + * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async + */ + 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 || '', + }); + const defaultCallSettings = this._defaults['listKeys']; + const callSettings = defaultCallSettings.merge(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 28cf4b45f22844f807a193ac702a24184911ede1 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 7 Dec 2021 01:52:27 +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 | 7 - 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 | 880 -------- ..._enterprise_service.annotate_assessment.js | 72 - ...ha_enterprise_service.create_assessment.js | 59 - ...recaptcha_enterprise_service.create_key.js | 59 - ...recaptcha_enterprise_service.delete_key.js | 54 - .../recaptcha_enterprise_service.get_key.js | 54 - ...ecaptcha_enterprise_service.get_metrics.js | 54 - .../recaptcha_enterprise_service.list_keys.js | 66 - ....list_related_account_group_memberships.js | 71 - ...ise_service.list_related_account_groups.js | 71 - ...ecaptcha_enterprise_service.migrate_key.js | 54 - ...earch_related_account_group_memberships.js | 78 - ...recaptcha_enterprise_service.update_key.js | 58 - owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 159 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../v1/recaptcha_enterprise_service_client.ts | 1953 ---------------- ...tcha_enterprise_service_client_config.json | 81 - ...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 | 1965 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta1/.eslintignore | 7 - 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 ---- ...se_service_v1_beta1.annotate_assessment.js | 59 - ...rise_service_v1_beta1.create_assessment.js | 59 - ..._enterprise_service_v1_beta1.create_key.js | 59 - ..._enterprise_service_v1_beta1.delete_key.js | 54 - ...cha_enterprise_service_v1_beta1.get_key.js | 54 - ...a_enterprise_service_v1_beta1.list_keys.js | 66 - ..._enterprise_service_v1_beta1.update_key.js | 58 - 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 | 1042 --------- ...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 - .../v1/recaptchaenterprise.proto | 15 +- protos/protos.d.ts | 2 + protos/protos.js | 14 + protos/protos.json | 2 + 67 files changed, 31 insertions(+), 9741 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/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js 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/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js 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 cfc348e..0000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ 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 0121dfa..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": 5 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 8b0a764..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.28.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.32", - "@types/sinon": "^10.0.6", - "c8": "^7.10.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^2.14.5", - "mocha": "^9.1.3", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.2", - "ts-loader": "^9.2.6", - "typescript": "^4.4.4", - "webpack": "^5.62.1", - "webpack-cli": "^4.9.1" - }, - "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 1be736a..0000000 --- a/owl-bot-staging/v1/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto +++ /dev/null @@ -1,880 +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 -// -// 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 fraudulent. - 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/*}" - }; - } - - // Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. - // Once a key is migrated, it can be used from either product. SiteVerify - // requests are billed as CreateAssessment calls. You must be - // authenticated as one of the current owners of the reCAPTCHA Site Key, and - // your user must have the reCAPTCHA Enterprise Admin IAM role in the - // destination project. - rpc MigrateKey(MigrateKeyRequest) returns (Key) { - option (google.api.http) = { - post: "/v1/{name=projects/*/keys/*}:migrate" - body: "*" - }; - } - - // Get some aggregated metrics for a Key. This data can be used to build - // dashboards. - rpc GetMetrics(GetMetricsRequest) returns (Metrics) { - option (google.api.http) = { - get: "/v1/{name=projects/*/keys/*/metrics}" - }; - option (google.api.method_signature) = "name"; - } - - // List groups of related accounts. - rpc ListRelatedAccountGroups(ListRelatedAccountGroupsRequest) returns (ListRelatedAccountGroupsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/relatedaccountgroups" - }; - option (google.api.method_signature) = "parent"; - } - - // Get the memberships in a group of related accounts. - rpc ListRelatedAccountGroupMemberships(ListRelatedAccountGroupMembershipsRequest) returns (ListRelatedAccountGroupMembershipsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/relatedaccountgroups/*}/memberships" - }; - option (google.api.method_signature) = "parent"; - } - - // Search group memberships related to a given account. - rpc SearchRelatedAccountGroupMemberships(SearchRelatedAccountGroupMembershipsRequest) returns (SearchRelatedAccountGroupMembershipsResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/relatedaccountgroupmemberships:search" - body: "*" - }; - option (google.api.method_signature) = "parent,hashed_account_id"; - } -} - -// 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 represents 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. Deprecated, prefer indicating - // CORRECT_PASSWORD through the reasons field instead. - PASSWORD_CORRECT = 3 [deprecated = true]; - - // Provides information that the event was related to a login event in which - // the user typed the incorrect password. Deprecated, prefer indicating - // INCORRECT_PASSWORD through the reasons field instead. - PASSWORD_INCORRECT = 4 [deprecated = true]; - } - - // Enum that represents potential reasons for annotating an assessment. - enum Reason { - // Default unspecified reason. - REASON_UNSPECIFIED = 0; - - // Indicates a chargeback was issued for the transaction associated with the - // assessment, with no other details. When possible, specify the type by - // using CHARGEBACK_FRAUD or CHARGEBACK_DISPUTE instead. - CHARGEBACK = 1; - - // Indicates a chargeback related to an alleged unauthorized transaction - // from the perspective of the cardholder (for example, the card number was - // stolen). - CHARGEBACK_FRAUD = 8; - - // Indicates a chargeback related to the cardholder having provided their - // card but allegedly not being satisfied with the purchase - // (for example, misrepresentation, attempted cancellation). - CHARGEBACK_DISPUTE = 9; - - // Indicates the transaction associated with the assessment is suspected of - // being fraudulent based on the payment method, billing details, shipping - // address or other transaction information. - PAYMENT_HEURISTICS = 2; - - // Indicates that the user was served a 2FA challenge. An old assessment - // with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been - // overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow. - // This is equivalent to `FAILED_TWO_FACTOR`. - INITIATED_TWO_FACTOR = 7; - - // Indicates that the user passed a 2FA challenge. - PASSED_TWO_FACTOR = 3; - - // Indicates that the user failed a 2FA challenge. - FAILED_TWO_FACTOR = 4; - - // Indicates the user provided the correct password. - CORRECT_PASSWORD = 5; - - // Indicates the user provided an incorrect password. - INCORRECT_PASSWORD = 6; - } - - // 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" - } - ]; - - // Optional. The annotation that will be assigned to the Event. This field can be left - // empty to provide reasons that apply to an event without concluding whether - // the event is legitimate or fraudulent. - Annotation annotation = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Optional reasons for the annotation that will be assigned to the Event. - repeated Reason reasons = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Optional unique stable hashed user identifier to apply to the assessment. - // This is an alternative to setting the hashed_account_id in - // CreateAssessment, for example when the account identifier is not yet known - // in the initial request. It is recommended that the identifier is hashed - // using hmac-sha256 with stable secret. - bytes hashed_account_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// 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]; - - // Assessment returned by Account Defender when a hashed_account_id is - // provided. - AccountDefenderAssessment account_defender_assessment = 6; -} - -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]; - - // Optional. Optional unique stable hashed user identifier for the request. The - // identifier should ideally be hashed using sha256 with stable secret. - bytes hashed_account_id = 6 [(google.api.field_behavior) = OPTIONAL]; -} - -// Risk analysis result for an event. -message RiskAnalysis { - // 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 { - // 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; - - // A retriable error (such as network failure) occurred on the browser. - // Could easily be simulated by an attacker. - BROWSER_ERROR = 6; - } - - // 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; -} - -// Account Defender risk assessment. -message AccountDefenderAssessment { - // Labels returned by Account Defender for this request. - enum AccountDefenderLabel { - // Default unspecified type. - ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0; - - // The request matches a known good profile for the user. - PROFILE_MATCH = 1; - - // The request is potentially a suspicious login event and should be further - // verified either via multi-factor authentication or another system. - SUSPICIOUS_LOGIN_ACTIVITY = 2; - - // The request matched a profile that previously had suspicious account - // creation behavior. This could mean this is a fake account. - SUSPICIOUS_ACCOUNT_CREATION = 3; - - // The account in the request has a high number of related accounts. It does - // not necessarily imply that the account is bad but could require - // investigating. - RELATED_ACCOUNTS_NUMBER_HIGH = 4; - } - - // Labels for this request. - repeated AccountDefenderLabel labels = 1; -} - -// 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 fields 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" - } - ]; -} - -// The migrate key request message. -message MigrateKeyRequest { - // Required. The name of the key to be migrated, 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 get metrics request message. -message GetMetricsRequest { - // Required. The name of the requested metrics, in the format - // "projects/{project}/keys/{key}/metrics". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/Metrics" - } - ]; -} - -// Metrics for a single Key. -message Metrics { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/Metrics" - pattern: "projects/{project}/keys/{key}/metrics" - }; - - // Output only. The name of the metrics, in the format - // "projects/{project}/keys/{key}/metrics". - string name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Inclusive start time aligned to a day (UTC). - google.protobuf.Timestamp start_time = 1; - - // Metrics will be continuous and in order by dates, and in the granularity - // of day. All Key types should have score-based data. - repeated ScoreMetrics score_metrics = 2; - - // Metrics will be continuous and in order by dates, and in the granularity - // of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have - // challenge-based data. - repeated ChallengeMetrics challenge_metrics = 3; -} - -// 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; - } - - // See - // Creating and managing labels. - map labels = 6; - - // The timestamp corresponding to the creation of this Key. - google.protobuf.Timestamp create_time = 7; - - // Options for user acceptance testing. - TestingOptions testing_options = 9; -} - -// Options for user acceptance testing. -message TestingOptions { - // Enum that represents the challenge option for challenge-based (CHECKBOX, - // INVISIBLE) testing keys. - enum TestingChallenge { - // Perform the normal risk analysis and return either nocaptcha or a - // challenge depending on risk and trust factors. - TESTING_CHALLENGE_UNSPECIFIED = 0; - - // Challenge requests for this key always return a nocaptcha, which - // does not require a solution. - NOCAPTCHA = 1; - - // Challenge requests for this key always return an unsolvable - // challenge. - UNSOLVABLE_CHALLENGE = 2; - } - - // All assessments for this Key will return this score. Must be between 0 - // (likely not legitimate) and 1 (likely legitimate) inclusive. - float testing_score = 1; - - // For challenge-based keys only (CHECKBOX, INVISIBLE), all challenge requests - // for this site will return nocaptcha if NOCAPTCHA, or an unsolvable - // challenge if CHALLENGE. - TestingChallenge testing_challenge = 2; -} - -// 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; - - // If set to true, the key can be used on AMP (Accelerated Mobile Pages) - // websites. This is supported only for the SCORE integration type. - 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 and INVISIBLE. - ChallengeSecurityPreference challenge_security_preference = 5; -} - -// Settings specific to keys that can be used by Android apps. -message AndroidKeySettings { - // If set to true, allowed_package_names are not enforced. - bool allow_all_package_names = 2; - - // 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 { - // If set to true, allowed_bundle_ids are not enforced. - bool allow_all_bundle_ids = 2; - - // iOS bundle ids of apps allowed to use the key. - // Example: 'com.companyname.productname.appname' - repeated string allowed_bundle_ids = 1; -} - -// Score distribution. -message ScoreDistribution { - // Map key is score value multiplied by 100. The scores are discrete values - // between [0, 1]. The maximum number of buckets is on order of a few dozen, - // but typically much lower (ie. 10). - map score_buckets = 1; -} - -// Metrics related to scoring. -message ScoreMetrics { - // Aggregated score metrics for all traffic. - ScoreDistribution overall_metrics = 1; - - // Action-based metrics. The map key is the action name which specified by the - // site owners at time of the "execute" client-side call. - // Populated only for SCORE keys. - map action_metrics = 2; -} - -// Metrics related to challenges. -message ChallengeMetrics { - // Count of reCAPTCHA checkboxes or badges rendered. This is mostly equivalent - // to a count of pageloads for pages that include reCAPTCHA. - int64 pageload_count = 1; - - // Count of nocaptchas (successful verification without a challenge) issued. - int64 nocaptcha_count = 2; - - // Count of submitted challenge solutions that were incorrect or otherwise - // deemed suspicious such that a subsequent challenge was triggered. - int64 failed_count = 3; - - // Count of nocaptchas (successful verification without a challenge) plus - // submitted challenge solutions that were correct and resulted in - // verification. - int64 passed_count = 4; -} - -// The request message to list memberships in a related account group. -message ListRelatedAccountGroupMembershipsRequest { - // Required. The resource name for the related account group in the format - // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // Optional. The maximum number of accounts to return. The service may return fewer than - // this value. - // If unspecified, at most 50 accounts will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` - // call. - // - // When paginating, all other parameters provided to - // `ListRelatedAccountGroupMemberships` must match the call that provided the - // page token. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `ListRelatedAccountGroupMemberships` call. -message ListRelatedAccountGroupMembershipsResponse { - // The memberships listed by the query. - repeated RelatedAccountGroupMembership related_account_group_memberships = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// The request message to list related account groups. -message ListRelatedAccountGroupsRequest { - // Required. The name of the project to list related account groups from, in the format - // "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - } - ]; - - // Optional. The maximum number of groups to return. The service may return fewer than - // this value. - // If unspecified, at most 50 groups will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListRelatedAccountGroups` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // `ListRelatedAccountGroups` must match the call that provided the page - // token. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `ListRelatedAccountGroups` call. -message ListRelatedAccountGroupsResponse { - // The groups of related accounts listed by the query. - repeated RelatedAccountGroup related_account_groups = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// The request message to search related account group memberships. -message SearchRelatedAccountGroupMembershipsRequest { - // Required. The name of the project to search related account group memberships from, - // in the format "projects/{project}". - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // Optional. The unique stable hashed user identifier we should search connections to. - // The identifier should correspond to a `hashed_account_id` provided in a - // previous CreateAssessment or AnnotateAssessment call. - bytes hashed_account_id = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of groups to return. The service may return fewer than - // this value. - // If unspecified, at most 50 groups will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous - // `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - // subsequent page. - // - // When paginating, all other parameters provided to - // `SearchRelatedAccountGroupMemberships` must match the call that provided - // the page token. - string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response to a `SearchRelatedAccountGroupMemberships` call. -message SearchRelatedAccountGroupMembershipsResponse { - // The queried memberships. - repeated RelatedAccountGroupMembership related_account_group_memberships = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// A membership in a group of related accounts. -message RelatedAccountGroupMembership { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}" - }; - - // Required. The resource name for this membership in the format - // `projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroupMembership" - } - ]; - - // The unique stable hashed user identifier of the member. The identifier - // corresponds to a `hashed_account_id` provided in a previous - // CreateAssessment or AnnotateAssessment call. - bytes hashed_account_id = 2; -} - -// A group of related accounts. -message RelatedAccountGroup { - option (google.api.resource) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - pattern: "projects/{project}/relatedaccountgroups/{relatedaccountgroup}" - }; - - // Required. The resource name for the related account group in the format - // `projects/{project}/relatedaccountgroups/{related_account_group}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "recaptchaenterprise.googleapis.com/RelatedAccountGroup" - } - ]; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js deleted file mode 100644 index d3bca76..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js +++ /dev/null @@ -1,72 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". - */ - // const name = 'abc123' - /** - * Optional. The annotation that will be assigned to the Event. This field can be left - * empty to provide reasons that apply to an event without concluding whether - * the event is legitimate or fraudulent. - */ - // const annotation = {} - /** - * Optional. Optional reasons for the annotation that will be assigned to the Event. - */ - // const reasons = 1234 - /** - * Optional. Optional unique stable hashed user identifier to apply to the assessment. - * This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - */ - // const hashedAccountId = 'Buffer.from('string')' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callAnnotateAssessment() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.annotateAssessment(request); - console.log(response); - } - - callAnnotateAssessment(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js deleted file mode 100644 index fce5aa2..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_assessment.js +++ /dev/null @@ -1,59 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent, assessment) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Required. The assessment details. - */ - // const assessment = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callCreateAssessment() { - // Construct request - const request = { - parent, - assessment, - }; - - // Run request - const response = await recaptchaenterpriseClient.createAssessment(request); - console.log(response); - } - - callCreateAssessment(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js deleted file mode 100644 index 1c51666..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.create_key.js +++ /dev/null @@ -1,59 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent, key) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Required. Information to create a reCAPTCHA Enterprise key. - */ - // const key = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callCreateKey() { - // Construct request - const request = { - parent, - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.createKey(request); - console.log(response); - } - - callCreateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js deleted file mode 100644 index e3101e8..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.delete_key.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callDeleteKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.deleteKey(request); - console.log(response); - } - - callDeleteKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js deleted file mode 100644 index 12bce4b..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_key.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callGetKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.getKey(request); - console.log(response); - } - - callGetKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js deleted file mode 100644 index be33e23..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.get_metrics.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callGetMetrics() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.getMetrics(request); - console.log(response); - } - - callGetMetrics(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js deleted file mode 100644 index 5557018..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_keys.js +++ /dev/null @@ -1,66 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - */ - // const pageSize = 1234 - /** - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListKeys(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js deleted file mode 100644 index 83c71d0..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js +++ /dev/null @@ -1,71 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of accounts to return. The service may return fewer than - * this value. - * If unspecified, at most 50 accounts will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` - * call. - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListRelatedAccountGroupMemberships() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupMembershipsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRelatedAccountGroupMemberships(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js deleted file mode 100644 index c039342..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js +++ /dev/null @@ -1,71 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project to list related account groups from, in the format - * "projects/{project}". - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callListRelatedAccountGroups() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listRelatedAccountGroupsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRelatedAccountGroups(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js deleted file mode 100644 index a84bab6..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.migrate_key.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callMigrateKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.migrateKey(request); - console.log(response); - } - - callMigrateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js deleted file mode 100644 index 9f6c800..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js +++ /dev/null @@ -1,78 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project to search related account group memberships from, - * in the format "projects/{project}". - */ - // const parent = 'abc123' - /** - * Optional. The unique stable hashed user identifier we should search connections to. - * The identifier should correspond to a `hashed_account_id` provided in a - * previous CreateAssessment or AnnotateAssessment call. - */ - // const hashedAccountId = 'Buffer.from('string')' - /** - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callSearchRelatedAccountGroupMemberships() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.searchRelatedAccountGroupMembershipsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchRelatedAccountGroupMemberships(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js b/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js deleted file mode 100644 index eae0df5..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/recaptcha_enterprise_service.update_key.js +++ /dev/null @@ -1,58 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(key) { - // [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The key to update. - */ - // const key = {} - /** - * Optional. The mask to control which fields of the key get updated. If the mask is not - * present, all fields will be updated. - */ - // const updateMask = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceClient} = require('@google-cloud/recaptcha-enterprise').v1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceClient(); - - async function callUpdateKey() { - // Construct request - const request = { - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.updateKey(request); - console.log(response); - } - - callUpdateKey(); - // [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); 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 09321f2..0000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,159 +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" - ] - }, - "MigrateKey": { - "methods": [ - "migrateKey" - ] - }, - "GetMetrics": { - "methods": [ - "getMetrics" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - }, - "ListRelatedAccountGroups": { - "methods": [ - "listRelatedAccountGroups", - "listRelatedAccountGroupsStream", - "listRelatedAccountGroupsAsync" - ] - }, - "ListRelatedAccountGroupMemberships": { - "methods": [ - "listRelatedAccountGroupMemberships", - "listRelatedAccountGroupMembershipsStream", - "listRelatedAccountGroupMembershipsAsync" - ] - }, - "SearchRelatedAccountGroupMemberships": { - "methods": [ - "searchRelatedAccountGroupMemberships", - "searchRelatedAccountGroupMembershipsStream", - "searchRelatedAccountGroupMembershipsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecaptchaEnterpriseServiceClient", - "rpcs": { - "CreateAssessment": { - "methods": [ - "createAssessment" - ] - }, - "AnnotateAssessment": { - "methods": [ - "annotateAssessment" - ] - }, - "CreateKey": { - "methods": [ - "createKey" - ] - }, - "GetKey": { - "methods": [ - "getKey" - ] - }, - "UpdateKey": { - "methods": [ - "updateKey" - ] - }, - "DeleteKey": { - "methods": [ - "deleteKey" - ] - }, - "MigrateKey": { - "methods": [ - "migrateKey" - ] - }, - "GetMetrics": { - "methods": [ - "getMetrics" - ] - }, - "ListKeys": { - "methods": [ - "listKeys", - "listKeysStream", - "listKeysAsync" - ] - }, - "ListRelatedAccountGroups": { - "methods": [ - "listRelatedAccountGroups", - "listRelatedAccountGroupsStream", - "listRelatedAccountGroupsAsync" - ] - }, - "ListRelatedAccountGroupMemberships": { - "methods": [ - "listRelatedAccountGroupMemberships", - "listRelatedAccountGroupMembershipsStream", - "listRelatedAccountGroupMembershipsAsync" - ] - }, - "SearchRelatedAccountGroupMemberships": { - "methods": [ - "searchRelatedAccountGroupMemberships", - "searchRelatedAccountGroupMembershipsStream", - "searchRelatedAccountGroupMembershipsAsync" - ] - } - } - } - } - } - } -} 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 8f7929e..0000000 --- a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client.ts +++ /dev/null @@ -1,1953 +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}' - ), - metricsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/keys/{key}/metrics' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - relatedAccountGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}' - ), - relatedAccountGroupMembershipPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}' - ), - }; - - // 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'), - listRelatedAccountGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroups'), - listRelatedAccountGroupMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships'), - searchRelatedAccountGroupMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'relatedAccountGroupMemberships') - }; - - // 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', 'migrateKey', 'getMetrics', 'listRelatedAccountGroups', 'listRelatedAccountGroupMemberships', 'searchRelatedAccountGroupMemberships']; - 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 -- - // ------------------- -/** - * 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 include:samples/generated/v1/recaptcha_enterprise_service.create_assessment.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateAssessment_async - */ - 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; - 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); - } -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fraudulent. - * - * @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] - * Optional. The annotation that will be assigned to the Event. This field can be left - * empty to provide reasons that apply to an event without concluding whether - * the event is legitimate or fraudulent. - * @param {number[]} [request.reasons] - * Optional. Optional reasons for the annotation that will be assigned to the Event. - * @param {Buffer} [request.hashedAccountId] - * Optional. Optional unique stable hashed user identifier to apply to the assessment. - * This is an alternative to setting the hashed_account_id in - * CreateAssessment, for example when the account identifier is not yet known - * in the initial request. It is recommended that the identifier is hashed - * using hmac-sha256 with stable secret. - * @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 include:samples/generated/v1/recaptcha_enterprise_service.annotate_assessment.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_AnnotateAssessment_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1/recaptcha_enterprise_service.create_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateKey_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1/recaptcha_enterprise_service.get_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async - */ - 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; - 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); - } -/** - * 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 fields 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 include:samples/generated/v1/recaptcha_enterprise_service.update_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateKey_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1/recaptcha_enterprise_service.delete_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async - */ - 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; - 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); - } -/** - * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. - * Once a key is migrated, it can be used from either product. SiteVerify - * requests are billed as CreateAssessment calls. You must be - * authenticated as one of the current owners of the reCAPTCHA Site Key, and - * your user must have the reCAPTCHA Enterprise Admin IAM role in the - * destination project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be migrated, 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 include:samples/generated/v1/recaptcha_enterprise_service.migrate_key.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_MigrateKey_async - */ - migrateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|undefined, {}|undefined - ]>; - migrateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): void; - migrateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): void; - migrateKey( - request?: protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IMigrateKeyRequest|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.migrateKey(request, options, callback); - } -/** - * Get some aggregated metrics for a Key. This data can be used to build - * dashboards. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". - * @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 [Metrics]{@link google.cloud.recaptchaenterprise.v1.Metrics}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/recaptcha_enterprise_service.get_metrics.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async - */ - getMetrics( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|undefined, {}|undefined - ]>; - getMetrics( - request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): void; - getMetrics( - request: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): void; - getMetrics( - request?: protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IMetrics, - protos.google.cloud.recaptchaenterprise.v1.IGetMetricsRequest|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.getMetrics(request, options, callback); - } - - /** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @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, - 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; - 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 defaultCallSettings = this._defaults['listKeys']; - const callSettings = defaultCallSettings.merge(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 include:samples/generated/v1/recaptcha_enterprise_service.list_keys.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListKeys_async - */ - 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 || '', - }); - const defaultCallSettings = this._defaults['listKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listKeys.asyncIterate( - this.innerApiCalls['listKeys'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * List groups of related accounts. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project to list related account groups from, in the format - * "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - * @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 [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup}. - * 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 `listRelatedAccountGroupsAsync()` - * 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. - */ - listRelatedAccountGroups( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse - ]>; - listRelatedAccountGroups( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; - listRelatedAccountGroups( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): void; - listRelatedAccountGroups( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsResponse - ]>|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.listRelatedAccountGroups(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 to list related account groups from, in the format - * "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - * @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 [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup} 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 `listRelatedAccountGroupsAsync()` - * 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. - */ - listRelatedAccountGroupsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - 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 defaultCallSettings = this._defaults['listRelatedAccountGroups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroups.createStream( - this.innerApiCalls.listRelatedAccountGroups as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRelatedAccountGroups`, 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 to list related account groups from, in the format - * "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroups` must match the call that provided the page - * token. - * @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 - * [RelatedAccountGroup]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroup}. 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 include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_groups.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroups_async - */ - listRelatedAccountGroupsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupsRequest, - 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 || '', - }); - const defaultCallSettings = this._defaults['listRelatedAccountGroups']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroups.asyncIterate( - this.innerApiCalls['listRelatedAccountGroups'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Get the memberships in a group of related accounts. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service may return fewer than - * this value. - * If unspecified, at most 50 accounts will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` - * call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. - * 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 `listRelatedAccountGroupMembershipsAsync()` - * 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. - */ - listRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse - ]>; - listRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - listRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - listRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsResponse - ]>|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.listRelatedAccountGroupMemberships(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 resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service may return fewer than - * this value. - * If unspecified, at most 50 accounts will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` - * call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership} 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 `listRelatedAccountGroupMembershipsAsync()` - * 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. - */ - listRelatedAccountGroupMembershipsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - 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 defaultCallSettings = this._defaults['listRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroupMemberships.createStream( - this.innerApiCalls.listRelatedAccountGroupMemberships as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRelatedAccountGroupMemberships`, 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 resource name for the related account group in the format - * `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of accounts to return. The service may return fewer than - * this value. - * If unspecified, at most 50 accounts will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` - * call. - * - * When paginating, all other parameters provided to - * `ListRelatedAccountGroupMemberships` must match the call that provided the - * page token. - * @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 - * [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. 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 include:samples/generated/v1/recaptcha_enterprise_service.list_related_account_group_memberships.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListRelatedAccountGroupMemberships_async - */ - listRelatedAccountGroupMembershipsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListRelatedAccountGroupMembershipsRequest, - 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 || '', - }); - const defaultCallSettings = this._defaults['listRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate( - this.innerApiCalls['listRelatedAccountGroupMemberships'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Search group memberships related to a given account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project to search related account group memberships from, - * in the format "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search connections to. - * The identifier should correspond to a `hashed_account_id` provided in a - * previous CreateAssessment or AnnotateAssessment call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. - * 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 `searchRelatedAccountGroupMembershipsAsync()` - * 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. - */ - searchRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse - ]>; - searchRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - searchRelatedAccountGroupMemberships( - request: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): void; - searchRelatedAccountGroupMemberships( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[], - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest|null, - protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsResponse - ]>|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.searchRelatedAccountGroupMemberships(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 to search related account group memberships from, - * in the format "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search connections to. - * The identifier should correspond to a `hashed_account_id` provided in a - * previous CreateAssessment or AnnotateAssessment call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - * @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 [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership} 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 `searchRelatedAccountGroupMembershipsAsync()` - * 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. - */ - searchRelatedAccountGroupMembershipsStream( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - 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 defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchRelatedAccountGroupMemberships.createStream( - this.innerApiCalls.searchRelatedAccountGroupMemberships as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchRelatedAccountGroupMemberships`, 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 to search related account group memberships from, - * in the format "projects/{project}". - * @param {Buffer} [request.hashedAccountId] - * Optional. The unique stable hashed user identifier we should search connections to. - * The identifier should correspond to a `hashed_account_id` provided in a - * previous CreateAssessment or AnnotateAssessment call. - * @param {number} [request.pageSize] - * Optional. The maximum number of groups to return. The service may return fewer than - * this value. - * If unspecified, at most 50 groups will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous - * `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the - * subsequent page. - * - * When paginating, all other parameters provided to - * `SearchRelatedAccountGroupMemberships` must match the call that provided - * the page token. - * @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 - * [RelatedAccountGroupMembership]{@link google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership}. 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 include:samples/generated/v1/recaptcha_enterprise_service.search_related_account_group_memberships.js - * region_tag:recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_SearchRelatedAccountGroupMemberships_async - */ - searchRelatedAccountGroupMembershipsAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.ISearchRelatedAccountGroupMembershipsRequest, - 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 || '', - }); - const defaultCallSettings = this._defaults['searchRelatedAccountGroupMemberships']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate( - this.innerApiCalls['searchRelatedAccountGroupMemberships'] 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 metrics resource name string. - * - * @param {string} project - * @param {string} key - * @returns {string} Resource name string. - */ - metricsPath(project:string,key:string) { - return this.pathTemplates.metricsPathTemplate.render({ - project: project, - key: key, - }); - } - - /** - * Parse the project from Metrics resource. - * - * @param {string} metricsName - * A fully-qualified path representing Metrics resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMetricsName(metricsName: string) { - return this.pathTemplates.metricsPathTemplate.match(metricsName).project; - } - - /** - * Parse the key from Metrics resource. - * - * @param {string} metricsName - * A fully-qualified path representing Metrics resource. - * @returns {string} A string representing the key. - */ - matchKeyFromMetricsName(metricsName: string) { - return this.pathTemplates.metricsPathTemplate.match(metricsName).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; - } - - /** - * Return a fully-qualified relatedAccountGroup resource name string. - * - * @param {string} project - * @param {string} relatedaccountgroup - * @returns {string} Resource name string. - */ - relatedAccountGroupPath(project:string,relatedaccountgroup:string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.render({ - project: project, - relatedaccountgroup: relatedaccountgroup, - }); - } - - /** - * Parse the project from RelatedAccountGroup resource. - * - * @param {string} relatedAccountGroupName - * A fully-qualified path representing RelatedAccountGroup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRelatedAccountGroupName(relatedAccountGroupName: string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).project; - } - - /** - * Parse the relatedaccountgroup from RelatedAccountGroup resource. - * - * @param {string} relatedAccountGroupName - * A fully-qualified path representing RelatedAccountGroup resource. - * @returns {string} A string representing the relatedaccountgroup. - */ - matchRelatedaccountgroupFromRelatedAccountGroupName(relatedAccountGroupName: string) { - return this.pathTemplates.relatedAccountGroupPathTemplate.match(relatedAccountGroupName).relatedaccountgroup; - } - - /** - * Return a fully-qualified relatedAccountGroupMembership resource name string. - * - * @param {string} project - * @param {string} relatedaccountgroup - * @param {string} membership - * @returns {string} Resource name string. - */ - relatedAccountGroupMembershipPath(project:string,relatedaccountgroup:string,membership:string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.render({ - project: project, - relatedaccountgroup: relatedaccountgroup, - membership: membership, - }); - } - - /** - * Parse the project from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).project; - } - - /** - * Parse the relatedaccountgroup from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the relatedaccountgroup. - */ - matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).relatedaccountgroup; - } - - /** - * Parse the membership from RelatedAccountGroupMembership resource. - * - * @param {string} relatedAccountGroupMembershipName - * A fully-qualified path representing RelatedAccountGroupMembership resource. - * @returns {string} A string representing the membership. - */ - matchMembershipFromRelatedAccountGroupMembershipName(relatedAccountGroupMembershipName: string) { - return this.pathTemplates.relatedAccountGroupMembershipPathTemplate.match(relatedAccountGroupMembershipName).membership; - } - - /** - * 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 66fe297..0000000 --- a/owl-bot-staging/v1/src/v1/recaptcha_enterprise_service_client_config.json +++ /dev/null @@ -1,81 +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" - }, - "MigrateKey": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetMetrics": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRelatedAccountGroups": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRelatedAccountGroupMemberships": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SearchRelatedAccountGroupMemberships": { - "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 6d2e82e..0000000 --- a/owl-bot-staging/v1/test/gapic_recaptcha_enterprise_service_v1.ts +++ /dev/null @@ -1,1965 +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('migrateKey', () => { - it('invokes migrateKey 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.MigrateKeyRequest()); - 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.migrateKey = stubSimpleCall(expectedResponse); - const [response] = await client.migrateKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes migrateKey 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.MigrateKeyRequest()); - 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.migrateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.migrateKey( - 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.migrateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes migrateKey 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.MigrateKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.migrateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.migrateKey(request), expectedError); - assert((client.innerApiCalls.migrateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('getMetrics', () => { - it('invokes getMetrics 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.GetMetricsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Metrics()); - client.innerApiCalls.getMetrics = stubSimpleCall(expectedResponse); - const [response] = await client.getMetrics(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getMetrics 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.GetMetricsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Metrics()); - client.innerApiCalls.getMetrics = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMetrics( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IMetrics|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getMetrics as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getMetrics 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.GetMetricsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getMetrics = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMetrics(request), expectedError); - assert((client.innerApiCalls.getMetrics 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('listRelatedAccountGroups', () => { - it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listRelatedAccountGroups(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRelatedAccountGroups( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listRelatedAccountGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRelatedAccountGroups(request), expectedError); - assert((client.innerApiCalls.listRelatedAccountGroups as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRelatedAccountGroupsStream 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRelatedAccountGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { - 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.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listRelatedAccountGroupsStream 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRelatedAccountGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroups, request)); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroup()), - ]; - client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; - const iterable = client.listRelatedAccountGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRelatedAccountGroups 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.ListRelatedAccountGroupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRelatedAccountGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listRelatedAccountGroupMemberships', () => { - it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.listRelatedAccountGroupMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRelatedAccountGroupMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRelatedAccountGroupMemberships(request), expectedError); - assert((client.innerApiCalls.listRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listRelatedAccountGroupMembershipsStream 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - 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.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listRelatedAccountGroupMembershipsStream 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRelatedAccountGroupMemberships, request)); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - const iterable = client.listRelatedAccountGroupMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listRelatedAccountGroupMemberships 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.ListRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRelatedAccountGroupMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('searchRelatedAccountGroupMemberships', () => { - it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.searchRelatedAccountGroupMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchRelatedAccountGroupMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.searchRelatedAccountGroupMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchRelatedAccountGroupMemberships(request), expectedError); - assert((client.innerApiCalls.searchRelatedAccountGroupMemberships as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchRelatedAccountGroupMembershipsStream 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - 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.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); - assert.strictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes searchRelatedAccountGroupMembershipsStream 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.searchRelatedAccountGroupMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchRelatedAccountGroupMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchRelatedAccountGroupMemberships, request)); - assert.strictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.RelatedAccountGroupMembership()), - ]; - client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with searchRelatedAccountGroupMemberships 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.SearchRelatedAccountGroupMembershipsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchRelatedAccountGroupMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IRelatedAccountGroupMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.searchRelatedAccountGroupMemberships.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('metrics', () => { - const fakePath = "/rendered/path/metrics"; - 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.metricsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.metricsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('metricsPath', () => { - const result = client.metricsPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.metricsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMetricsName', () => { - const result = client.matchProjectFromMetricsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.metricsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromMetricsName', () => { - const result = client.matchKeyFromMetricsName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.metricsPathTemplate.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)); - }); - }); - - describe('relatedAccountGroup', () => { - const fakePath = "/rendered/path/relatedAccountGroup"; - const expectedParameters = { - project: "projectValue", - relatedaccountgroup: "relatedaccountgroupValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.relatedAccountGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.relatedAccountGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('relatedAccountGroupPath', () => { - const result = client.relatedAccountGroupPath("projectValue", "relatedaccountgroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRelatedAccountGroupName', () => { - const result = client.matchProjectFromRelatedAccountGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRelatedaccountgroupFromRelatedAccountGroupName', () => { - const result = client.matchRelatedaccountgroupFromRelatedAccountGroupName(fakePath); - assert.strictEqual(result, "relatedaccountgroupValue"); - assert((client.pathTemplates.relatedAccountGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('relatedAccountGroupMembership', () => { - const fakePath = "/rendered/path/relatedAccountGroupMembership"; - const expectedParameters = { - project: "projectValue", - relatedaccountgroup: "relatedaccountgroupValue", - membership: "membershipValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('relatedAccountGroupMembershipPath', () => { - const result = client.relatedAccountGroupMembershipPath("projectValue", "relatedaccountgroupValue", "membershipValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRelatedAccountGroupMembershipName', () => { - const result = client.matchProjectFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRelatedaccountgroupFromRelatedAccountGroupMembershipName', () => { - const result = client.matchRelatedaccountgroupFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "relatedaccountgroupValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromRelatedAccountGroupMembershipName', () => { - const result = client.matchMembershipFromRelatedAccountGroupMembershipName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.relatedAccountGroupMembershipPathTemplate.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 cfc348e..0000000 --- a/owl-bot-staging/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ 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 0121dfa..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": 5 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index a6f512d..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.28.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.32", - "@types/sinon": "^10.0.6", - "c8": "^7.10.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^2.14.5", - "mocha": "^9.1.3", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.2", - "ts-loader": "^9.2.6", - "typescript": "^4.4.4", - "webpack": "^5.62.1", - "webpack-cli": "^4.9.1" - }, - "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/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js deleted file mode 100644 index a1b22b0..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js +++ /dev/null @@ -1,59 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name, annotation) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - */ - // const name = 'abc123' - /** - * Required. The annotation that will be assigned to the Event. - */ - // const annotation = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callAnnotateAssessment() { - // Construct request - const request = { - name, - annotation, - }; - - // Run request - const response = await recaptchaenterpriseClient.annotateAssessment(request); - console.log(response); - } - - callAnnotateAssessment(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js deleted file mode 100644 index 3fc71f5..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js +++ /dev/null @@ -1,59 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent, assessment) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Required. The assessment details. - */ - // const assessment = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callCreateAssessment() { - // Construct request - const request = { - parent, - assessment, - }; - - // Run request - const response = await recaptchaenterpriseClient.createAssessment(request); - console.log(response); - } - - callCreateAssessment(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js deleted file mode 100644 index 6415203..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js +++ /dev/null @@ -1,59 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent, key) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project in which the key will be created, in the - * format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Required. Information to create a reCAPTCHA Enterprise key. - */ - // const key = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callCreateKey() { - // Construct request - const request = { - parent, - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.createKey(request); - console.log(response); - } - - callCreateKey(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js deleted file mode 100644 index 14babc5..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the key to be deleted, in the format - * "projects/{project_number}/keys/{key_id}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callDeleteKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.deleteKey(request); - console.log(response); - } - - callDeleteKey(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js deleted file mode 100644 index 3dda3d9..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js +++ /dev/null @@ -1,54 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(name) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the requested key, in the format - * "projects/{project_number}/keys/{key_id}". - */ - // const name = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callGetKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await recaptchaenterpriseClient.getKey(request); - console.log(response); - } - - callGetKey(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js deleted file mode 100644 index 61551fb..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js +++ /dev/null @@ -1,66 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(parent) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - */ - // const pageSize = 1234 - /** - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - */ - // const pageToken = 'abc123' - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callListKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await recaptchaenterpriseClient.listKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListKeys(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js deleted file mode 100644 index 7910cec..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js +++ /dev/null @@ -1,58 +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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -'use strict'; - -function main(key) { - // [START recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The key to update. - */ - // const key = {} - /** - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - */ - // const updateMask = {} - - // Imports the Recaptchaenterprise library - const {RecaptchaEnterpriseServiceV1Beta1Client} = require('@google-cloud/recaptcha-enterprise').v1beta1; - - // Instantiates a client - const recaptchaenterpriseClient = new RecaptchaEnterpriseServiceV1Beta1Client(); - - async function callUpdateKey() { - // Construct request - const request = { - key, - }; - - // Run request - const response = await recaptchaenterpriseClient.updateKey(request); - console.log(response); - } - - callUpdateKey(); - // [END recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); 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 e1145d6..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ /dev/null @@ -1,1042 +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 -- - // ------------------- -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_assessment.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateAssessment_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.annotate_assessment.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_AnnotateAssessment_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.create_key.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_CreateKey_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.get_key.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_GetKey_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.update_key.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_UpdateKey_async - */ - 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; - 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); - } -/** - * 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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.delete_key.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_DeleteKey_async - */ - 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; - 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); - } - - /** - * 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, - 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; - 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 defaultCallSettings = this._defaults['listKeys']; - const callSettings = defaultCallSettings.merge(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 include:samples/generated/v1beta1/recaptcha_enterprise_service_v1_beta1.list_keys.js - * region_tag:recaptchaenterprise_v1beta1_generated_RecaptchaEnterpriseServiceV1Beta1_ListKeys_async - */ - 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 || '', - }); - const defaultCallSettings = this._defaults['listKeys']; - const callSettings = defaultCallSettings.merge(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/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto b/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto index a2dd1ba..1be736a 100644 --- a/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto +++ b/protos/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto @@ -186,10 +186,21 @@ message AnnotateAssessmentRequest { // Default unspecified reason. REASON_UNSPECIFIED = 0; - // Indicates a chargeback for fraud was issued for the transaction - // associated with the assessment. + // Indicates a chargeback was issued for the transaction associated with the + // assessment, with no other details. When possible, specify the type by + // using CHARGEBACK_FRAUD or CHARGEBACK_DISPUTE instead. CHARGEBACK = 1; + // Indicates a chargeback related to an alleged unauthorized transaction + // from the perspective of the cardholder (for example, the card number was + // stolen). + CHARGEBACK_FRAUD = 8; + + // Indicates a chargeback related to the cardholder having provided their + // card but allegedly not being satisfied with the purchase + // (for example, misrepresentation, attempted cancellation). + CHARGEBACK_DISPUTE = 9; + // Indicates the transaction associated with the assessment is suspected of // being fraudulent based on the payment method, billing details, shipping // address or other transaction information. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 5f2fd7b..3e626a8 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -521,6 +521,8 @@ export namespace google { enum Reason { REASON_UNSPECIFIED = 0, CHARGEBACK = 1, + CHARGEBACK_FRAUD = 8, + CHARGEBACK_DISPUTE = 9, PAYMENT_HEURISTICS = 2, INITIATED_TWO_FACTOR = 7, PASSED_TWO_FACTOR = 3, diff --git a/protos/protos.js b/protos/protos.js index b415fed..d2b2268 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -919,6 +919,8 @@ return "reasons: enum value[] expected"; case 0: case 1: + case 8: + case 9: case 2: case 7: case 3: @@ -985,6 +987,14 @@ case 1: message.reasons[i] = 1; break; + case "CHARGEBACK_FRAUD": + case 8: + message.reasons[i] = 8; + break; + case "CHARGEBACK_DISPUTE": + case 9: + message.reasons[i] = 9; + break; case "PAYMENT_HEURISTICS": case 2: message.reasons[i] = 2; @@ -1096,6 +1106,8 @@ * @enum {number} * @property {number} REASON_UNSPECIFIED=0 REASON_UNSPECIFIED value * @property {number} CHARGEBACK=1 CHARGEBACK value + * @property {number} CHARGEBACK_FRAUD=8 CHARGEBACK_FRAUD value + * @property {number} CHARGEBACK_DISPUTE=9 CHARGEBACK_DISPUTE value * @property {number} PAYMENT_HEURISTICS=2 PAYMENT_HEURISTICS value * @property {number} INITIATED_TWO_FACTOR=7 INITIATED_TWO_FACTOR value * @property {number} PASSED_TWO_FACTOR=3 PASSED_TWO_FACTOR value @@ -1107,6 +1119,8 @@ var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "REASON_UNSPECIFIED"] = 0; values[valuesById[1] = "CHARGEBACK"] = 1; + values[valuesById[8] = "CHARGEBACK_FRAUD"] = 8; + values[valuesById[9] = "CHARGEBACK_DISPUTE"] = 9; values[valuesById[2] = "PAYMENT_HEURISTICS"] = 2; values[valuesById[7] = "INITIATED_TWO_FACTOR"] = 7; values[valuesById[3] = "PASSED_TWO_FACTOR"] = 3; diff --git a/protos/protos.json b/protos/protos.json index c9911f0..d181a3b 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -296,6 +296,8 @@ "values": { "REASON_UNSPECIFIED": 0, "CHARGEBACK": 1, + "CHARGEBACK_FRAUD": 8, + "CHARGEBACK_DISPUTE": 9, "PAYMENT_HEURISTICS": 2, "INITIATED_TWO_FACTOR": 7, "PASSED_TWO_FACTOR": 3,