From 270477d85fbaa344bf899bc4e26849bfaac0a9c7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 09:49:27 +0000 Subject: [PATCH 1/2] feat: support regapic LRO Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: https://github.com/googleapis/googleapis/commit/88fd18d9d3b872b3d06a3d9392879f50b5bf3ce5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/accfa371f667439313335c64042b063c1c53102e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWNjZmEzNzFmNjY3NDM5MzEzMzM1YzY0MDQyYjA2M2MxYzUzMTAyZSJ9 --- 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 | 16 + owl-bot-staging/v1/package.json | 64 ++ .../google/cloud/webrisk/v1/webrisk.proto | 353 ++++++++++ ...ppet_metadata.google.cloud.webrisk.v1.json | 195 ++++++ ...b_risk_service.compute_threat_list_diff.js | 71 ++ .../v1/web_risk_service.create_submission.js | 64 ++ .../v1/web_risk_service.search_hashes.js | 63 ++ .../v1/web_risk_service.search_uris.js | 63 ++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 63 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../v1/src/v1/web_risk_service_client.ts | 632 ++++++++++++++++++ .../v1/web_risk_service_client_config.json | 46 ++ .../src/v1/web_risk_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 ++ .../v1/test/gapic_web_risk_service_v1.ts | 481 +++++++++++++ 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 | 16 + owl-bot-staging/v1beta1/package.json | 64 ++ .../cloud/webrisk/v1beta1/webrisk.proto | 303 +++++++++ ...metadata.google.cloud.webrisk.v1beta1.json | 151 +++++ ...rvice_v1_beta1.compute_threat_list_diff.js | 68 ++ ...web_risk_service_v1_beta1.search_hashes.js | 63 ++ .../web_risk_service_v1_beta1.search_uris.js | 63 ++ owl-bot-staging/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/gapic_metadata.json | 53 ++ owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 + .../web_risk_service_v1_beta1_client.ts | 505 ++++++++++++++ ...b_risk_service_v1_beta1_client_config.json | 41 ++ .../web_risk_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 ++ ...gapic_web_risk_service_v1_beta1_v1beta1.ts | 351 ++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 ++ 53 files changed, 4535 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/webrisk/v1/webrisk.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json create mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.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/web_risk_service_client.ts create mode 100644 owl-bot-staging/v1/src/v1/web_risk_service_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/web_risk_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_web_risk_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/webrisk/v1beta1/webrisk.proto create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.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/web_risk_service_v1_beta1_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/web_risk_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_web_risk_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..9d0daa4 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 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 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/web-risk', + 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..481c522 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 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..494e147 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 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..55d440e --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Webrisk: 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..befd23c --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 0000000..0241e6a --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/web-risk", + "version": "0.1.0", + "description": "Webrisk client for Node.js", + "repository": "googleapis/nodejs-webrisk", + "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 webrisk", + "webrisk", + "web risk 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": "^3.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto b/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto new file mode 100644 index 0000000..71b6b44 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto @@ -0,0 +1,353 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.webrisk.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/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebRisk.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/webrisk/v1;webrisk"; +option java_multiple_files = true; +option java_outer_classname = "WebRiskProto"; +option java_package = "com.google.webrisk.v1"; +option objc_class_prefix = "GCWR"; +option php_namespace = "Google\\Cloud\\WebRisk\\V1"; +option ruby_package = "Google::Cloud::WebRisk::V1"; + +// Web Risk API defines an interface to detect malicious URLs on your +// website and in client applications. +service WebRiskService { + option (google.api.default_host) = "webrisk.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets the most recent threat list diffs. These diffs should be applied to + // a local database of hashes to keep it up-to-date. If the local database is + // empty or excessively out-of-date, a complete snapshot of the database will + // be returned. This Method only updates a single ThreatList at a time. To + // update multiple ThreatList databases, this method needs to be called once + // for each list. + rpc ComputeThreatListDiff(ComputeThreatListDiffRequest) returns (ComputeThreatListDiffResponse) { + option (google.api.http) = { + get: "/v1/threatLists:computeDiff" + }; + option (google.api.method_signature) = "threat_type,version_token,constraints"; + } + + // This method is used to check whether a URI is on a given threatList. + // Multiple threatLists may be searched in a single query. + // The response will list all requested threatLists the URI was found to + // match. If the URI is not found on any of the requested ThreatList an + // empty response will be returned. + rpc SearchUris(SearchUrisRequest) returns (SearchUrisResponse) { + option (google.api.http) = { + get: "/v1/uris:search" + }; + option (google.api.method_signature) = "uri,threat_types"; + } + + // Gets the full hashes that match the requested hash prefix. + // This is used after a hash prefix is looked up in a threatList + // and there is a match. The client side threatList only holds partial hashes + // so the client must query this method to determine if there is a full + // hash match of a threat. + rpc SearchHashes(SearchHashesRequest) returns (SearchHashesResponse) { + option (google.api.http) = { + get: "/v1/hashes:search" + }; + option (google.api.method_signature) = "hash_prefix,threat_types"; + } + + // Creates a Submission of a URI suspected of containing phishing content to + // be reviewed. If the result verifies the existence of malicious phishing + // content, the site will be added to the [Google's Social Engineering + // lists](https://support.google.com/webmasters/answer/6350487/) in order to + // protect users that could get exposed to this threat in the future. Only + // projects with CREATE_SUBMISSION_USERS visibility can use this method. + rpc CreateSubmission(CreateSubmissionRequest) returns (Submission) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/submissions" + body: "submission" + }; + option (google.api.method_signature) = "parent,submission"; + } +} + +// Describes an API diff request. +message ComputeThreatListDiffRequest { + // The constraints for this diff. + message Constraints { + // The maximum size in number of entries. The diff will not contain more + // entries than this value. This should be a power of 2 between 2**10 and + // 2**20. If zero, no diff size limit is set. + int32 max_diff_entries = 1; + + // Sets the maximum number of entries that the client is willing to have + // in the local database. This should be a power of 2 between 2**10 and + // 2**20. If zero, no database size limit is set. + int32 max_database_entries = 2; + + // The compression types supported by the client. + repeated CompressionType supported_compressions = 3; + } + + // Required. The threat list to update. Only a single ThreatType should be specified. + ThreatType threat_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // The current version token of the client for the requested list (the + // client version that was received from the last successful diff). + // If the client does not have a version token (this is the first time calling + // ComputeThreatListDiff), this may be left empty and a full database + // snapshot will be returned. + bytes version_token = 2; + + // Required. The constraints associated with this request. + Constraints constraints = 3 [(google.api.field_behavior) = REQUIRED]; +} + +message ComputeThreatListDiffResponse { + // The expected state of a client's local database. + message Checksum { + // The SHA256 hash of the client state; that is, of the sorted list of all + // hashes present in the database. + bytes sha256 = 1; + } + + // The type of response sent to the client. + enum ResponseType { + // Unknown. + RESPONSE_TYPE_UNSPECIFIED = 0; + + // Partial updates are applied to the client's existing local database. + DIFF = 1; + + // Full updates resets the client's entire local database. This means + // that either the client had no state, was seriously out-of-date, + // or the client is believed to be corrupt. + RESET = 2; + } + + // The type of response. This may indicate that an action must be taken by the + // client when the response is received. + ResponseType response_type = 4; + + // A set of entries to add to a local threat type's list. + ThreatEntryAdditions additions = 5; + + // A set of entries to remove from a local threat type's list. + // This field may be empty. + ThreatEntryRemovals removals = 6; + + // The new opaque client version token. This should be retained by the client + // and passed into the next call of ComputeThreatListDiff as 'version_token'. + // A separate version token should be stored and used for each threatList. + bytes new_version_token = 7; + + // The expected SHA256 hash of the client state; that is, of the sorted list + // of all hashes present in the database after applying the provided diff. + // If the client state doesn't match the expected state, the client must + // discard this diff and retry later. + Checksum checksum = 8; + + // The soonest the client should wait before issuing any diff + // request. Querying sooner is unlikely to produce a meaningful diff. + // Waiting longer is acceptable considering the use case. + // If this field is not set clients may update as soon as they want. + google.protobuf.Timestamp recommended_next_diff = 2; +} + +// Request to check URI entries against threatLists. +message SearchUrisRequest { + // Required. The URI to be checked for matches. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; +} + +message SearchUrisResponse { + // Contains threat information on a matching uri. + message ThreatUri { + // The ThreatList this threat belongs to. + repeated ThreatType threat_types = 1; + + // The cache lifetime for the returned match. Clients must not cache this + // response past this timestamp to avoid false positives. + google.protobuf.Timestamp expire_time = 2; + } + + // The threat list matches. This may be empty if the URI is on no list. + ThreatUri threat = 1; +} + +// Request to return full hashes matched by the provided hash prefixes. +message SearchHashesRequest { + // A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + // hash. For JSON requests, this field is base64-encoded. + bytes hash_prefix = 1; + + // Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; +} + +message SearchHashesResponse { + // Contains threat information on a matching hash. + message ThreatHash { + // The ThreatList this threat belongs to. + // This must contain at least one entry. + repeated ThreatType threat_types = 1; + + // A 32 byte SHA256 hash. This field is in binary format. For JSON + // requests, hashes are base64-encoded. + bytes hash = 2; + + // The cache lifetime for the returned match. Clients must not cache this + // response past this timestamp to avoid false positives. + google.protobuf.Timestamp expire_time = 3; + } + + // The full hashes that matched the requested prefixes. + // The hash will be populated in the key. + repeated ThreatHash threats = 1; + + // For requested entities that did not match the threat list, how long to + // cache the response until. + google.protobuf.Timestamp negative_expire_time = 2; +} + +// Contains the set of entries to add to a local database. +// May contain a combination of compressed and raw data in a single response. +message ThreatEntryAdditions { + // The raw SHA256-formatted entries. + // Repeated to allow returning sets of hashes with different prefix sizes. + repeated RawHashes raw_hashes = 1; + + // The encoded 4-byte prefixes of SHA256-formatted entries, using a + // Golomb-Rice encoding. The hashes are converted to uint32, sorted in + // ascending order, then delta encoded and stored as encoded_data. + RiceDeltaEncoding rice_hashes = 2; +} + +// Contains the set of entries to remove from a local database. +message ThreatEntryRemovals { + // The raw removal indices for a local list. + RawIndices raw_indices = 1; + + // The encoded local, lexicographically-sorted list indices, using a + // Golomb-Rice encoding. Used for sending compressed removal indices. The + // removal indices (uint32) are sorted in ascending order, then delta encoded + // and stored as encoded_data. + RiceDeltaEncoding rice_indices = 2; +} + +// The type of threat. This maps dirrectly to the threat list a threat may +// belong to. +enum ThreatType { + // Unknown. + THREAT_TYPE_UNSPECIFIED = 0; + + // Malware targeting any platform. + MALWARE = 1; + + // Social engineering targeting any platform. + SOCIAL_ENGINEERING = 2; + + // Unwanted software targeting any platform. + UNWANTED_SOFTWARE = 3; +} + +// The ways in which threat entry sets can be compressed. +enum CompressionType { + // Unknown. + COMPRESSION_TYPE_UNSPECIFIED = 0; + + // Raw, uncompressed data. + RAW = 1; + + // Rice-Golomb encoded data. + RICE = 2; +} + +// A set of raw indices to remove from a local list. +message RawIndices { + // The indices to remove from a lexicographically-sorted local list. + repeated int32 indices = 1; +} + +// The uncompressed threat entries in hash format. +// Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 +// bytes, but some hashes are lengthened if they collide with the hash of a +// popular URI. +// +// Used for sending ThreatEntryAdditons to clients that do not support +// compression, or when sending non-4-byte hashes to clients that do support +// compression. +message RawHashes { + // The number of bytes for each prefix encoded below. This field can be + // anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). + // In practice this is almost always 4, except in exceptional circumstances. + int32 prefix_size = 1; + + // The hashes, in binary format, concatenated into one long string. Hashes are + // sorted in lexicographic order. For JSON API users, hashes are + // base64-encoded. + bytes raw_hashes = 2; +} + +// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or +// compressed removal indices. +message RiceDeltaEncoding { + // The offset of the first entry in the encoded data, or, if only a single + // integer was encoded, that single integer's value. If the field is empty or + // missing, assume zero. + int64 first_value = 1; + + // The Golomb-Rice parameter, which is a number between 2 and 28. This field + // is missing (that is, zero) if `num_entries` is zero. + int32 rice_parameter = 2; + + // The number of entries that are delta encoded in the encoded data. If only a + // single integer was encoded, this will be zero and the single value will be + // stored in `first_value`. + int32 entry_count = 3; + + // The encoded deltas that are encoded using the Golomb-Rice coder. + bytes encoded_data = 4; +} + +// Wraps a URI that might be displaying phishing content. +message Submission { + // Required. The URI that is being reported for phishing content to be analyzed. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request to send a potentially phishy URI to WebRisk. +message CreateSubmissionRequest { + // Required. The name of the project that is making the submission. This string is 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 submission that contains the content of the phishing report. + Submission submission = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json new file mode 100644 index 0000000..114dcfd --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json @@ -0,0 +1,195 @@ +{ + "clientLibrary": { + "name": "nodejs-webrisk", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.webrisk.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async", + "title": "WebRiskService computeThreatListDiff Sample", + "origin": "API_DEFINITION", + "description": " Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.", + "canonical": true, + "file": "web_risk_service.compute_threat_list_diff.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ComputeThreatListDiff", + "fullName": "google.cloud.webrisk.v1.WebRiskService.ComputeThreatListDiff", + "async": true, + "parameters": [ + { + "name": "threat_type", + "type": ".google.cloud.webrisk.v1.ThreatType" + }, + { + "name": "version_token", + "type": "TYPE_BYTES" + }, + { + "name": "constraints", + "type": ".google.cloud.webrisk.v1.ComputeThreatListDiffRequest.Constraints" + } + ], + "resultType": ".google.cloud.webrisk.v1.ComputeThreatListDiffResponse", + "client": { + "shortName": "WebRiskServiceClient", + "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" + }, + "method": { + "shortName": "ComputeThreatListDiff", + "fullName": "google.cloud.webrisk.v1.WebRiskService.ComputeThreatListDiff", + "service": { + "shortName": "WebRiskService", + "fullName": "google.cloud.webrisk.v1.WebRiskService" + } + } + } + }, + { + "regionTag": "webrisk_v1_generated_WebRiskService_SearchUris_async", + "title": "WebRiskService searchUris Sample", + "origin": "API_DEFINITION", + "description": " This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.", + "canonical": true, + "file": "web_risk_service.search_uris.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchUris", + "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchUris", + "async": true, + "parameters": [ + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "threat_types", + "type": "TYPE_ENUM[]" + } + ], + "resultType": ".google.cloud.webrisk.v1.SearchUrisResponse", + "client": { + "shortName": "WebRiskServiceClient", + "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" + }, + "method": { + "shortName": "SearchUris", + "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchUris", + "service": { + "shortName": "WebRiskService", + "fullName": "google.cloud.webrisk.v1.WebRiskService" + } + } + } + }, + { + "regionTag": "webrisk_v1_generated_WebRiskService_SearchHashes_async", + "title": "WebRiskService searchHashes Sample", + "origin": "API_DEFINITION", + "description": " Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.", + "canonical": true, + "file": "web_risk_service.search_hashes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchHashes", + "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchHashes", + "async": true, + "parameters": [ + { + "name": "hash_prefix", + "type": "TYPE_BYTES" + }, + { + "name": "threat_types", + "type": "TYPE_ENUM[]" + } + ], + "resultType": ".google.cloud.webrisk.v1.SearchHashesResponse", + "client": { + "shortName": "WebRiskServiceClient", + "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" + }, + "method": { + "shortName": "SearchHashes", + "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchHashes", + "service": { + "shortName": "WebRiskService", + "fullName": "google.cloud.webrisk.v1.WebRiskService" + } + } + } + }, + { + "regionTag": "webrisk_v1_generated_WebRiskService_CreateSubmission_async", + "title": "WebRiskService createSubmission Sample", + "origin": "API_DEFINITION", + "description": " Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only projects with CREATE_SUBMISSION_USERS visibility can use this method.", + "canonical": true, + "file": "web_risk_service.create_submission.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSubmission", + "fullName": "google.cloud.webrisk.v1.WebRiskService.CreateSubmission", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "submission", + "type": ".google.cloud.webrisk.v1.Submission" + } + ], + "resultType": ".google.cloud.webrisk.v1.Submission", + "client": { + "shortName": "WebRiskServiceClient", + "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" + }, + "method": { + "shortName": "CreateSubmission", + "fullName": "google.cloud.webrisk.v1.WebRiskService.CreateSubmission", + "service": { + "shortName": "WebRiskService", + "fullName": "google.cloud.webrisk.v1.WebRiskService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js new file mode 100644 index 0000000..597c7b1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js @@ -0,0 +1,71 @@ +// Copyright 2022 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'; + +function main(threatType, constraints) { + // [START webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The threat list to update. Only a single ThreatType should be specified. + */ + // const threatType = {} + /** + * The current version token of the client for the requested list (the + * client version that was received from the last successful diff). + * If the client does not have a version token (this is the first time calling + * ComputeThreatListDiff), this may be left empty and a full database + * snapshot will be returned. + */ + // const versionToken = 'Buffer.from('string')' + /** + * Required. The constraints associated with this request. + */ + // const constraints = {} + + // Imports the Webrisk library + const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; + + // Instantiates a client + const webriskClient = new WebRiskServiceClient(); + + async function callComputeThreatListDiff() { + // Construct request + const request = { + threatType, + constraints, + }; + + // Run request + const response = await webriskClient.computeThreatListDiff(request); + console.log(response); + } + + callComputeThreatListDiff(); + // [END webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_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/web_risk_service.create_submission.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js new file mode 100644 index 0000000..5f81d5c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js @@ -0,0 +1,64 @@ +// Copyright 2022 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'; + +function main(parent, submission) { + // [START webrisk_v1_generated_WebRiskService_CreateSubmission_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project that is making the submission. This string is in + * the format "projects/{project_number}". + */ + // const parent = 'abc123' + /** + * Required. The submission that contains the content of the phishing report. + */ + // const submission = {} + + // Imports the Webrisk library + const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; + + // Instantiates a client + const webriskClient = new WebRiskServiceClient(); + + async function callCreateSubmission() { + // Construct request + const request = { + parent, + submission, + }; + + // Run request + const response = await webriskClient.createSubmission(request); + console.log(response); + } + + callCreateSubmission(); + // [END webrisk_v1_generated_WebRiskService_CreateSubmission_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/web_risk_service.search_hashes.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js new file mode 100644 index 0000000..a43eb9d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js @@ -0,0 +1,63 @@ +// Copyright 2022 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'; + +function main(threatTypes) { + // [START webrisk_v1_generated_WebRiskService_SearchHashes_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + * hash. For JSON requests, this field is base64-encoded. + */ + // const hashPrefix = 'Buffer.from('string')' + /** + * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + */ + // const threatTypes = 1234 + + // Imports the Webrisk library + const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; + + // Instantiates a client + const webriskClient = new WebRiskServiceClient(); + + async function callSearchHashes() { + // Construct request + const request = { + threatTypes, + }; + + // Run request + const response = await webriskClient.searchHashes(request); + console.log(response); + } + + callSearchHashes(); + // [END webrisk_v1_generated_WebRiskService_SearchHashes_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/web_risk_service.search_uris.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.js new file mode 100644 index 0000000..1ca2ddf --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.js @@ -0,0 +1,63 @@ +// Copyright 2022 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'; + +function main(uri, threatTypes) { + // [START webrisk_v1_generated_WebRiskService_SearchUris_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The URI to be checked for matches. + */ + // const uri = 'abc123' + /** + * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + */ + // const threatTypes = 1234 + + // Imports the Webrisk library + const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; + + // Instantiates a client + const webriskClient = new WebRiskServiceClient(); + + async function callSearchUris() { + // Construct request + const request = { + uri, + threatTypes, + }; + + // Run request + const response = await webriskClient.searchUris(request); + console.log(response); + } + + callSearchUris(); + // [END webrisk_v1_generated_WebRiskService_SearchUris_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..cd03b1e --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 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 WebRiskServiceClient = v1.WebRiskServiceClient; +type WebRiskServiceClient = v1.WebRiskServiceClient; +export {v1, WebRiskServiceClient}; +export default {v1, WebRiskServiceClient}; +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..7934355 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,63 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.webrisk.v1", + "libraryPackage": "@google-cloud/web-risk", + "services": { + "WebRiskService": { + "clients": { + "grpc": { + "libraryClient": "WebRiskServiceClient", + "rpcs": { + "ComputeThreatListDiff": { + "methods": [ + "computeThreatListDiff" + ] + }, + "SearchUris": { + "methods": [ + "searchUris" + ] + }, + "SearchHashes": { + "methods": [ + "searchHashes" + ] + }, + "CreateSubmission": { + "methods": [ + "createSubmission" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WebRiskServiceClient", + "rpcs": { + "ComputeThreatListDiff": { + "methods": [ + "computeThreatListDiff" + ] + }, + "SearchUris": { + "methods": [ + "searchUris" + ] + }, + "SearchHashes": { + "methods": [ + "searchHashes" + ] + }, + "CreateSubmission": { + "methods": [ + "createSubmission" + ] + } + } + } + } + } + } +} 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..d74132c --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 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 {WebRiskServiceClient} from './web_risk_service_client'; diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_client.ts b/owl-bot-staging/v1/src/v1/web_risk_service_client.ts new file mode 100644 index 0000000..2cbfd12 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_risk_service_client.ts @@ -0,0 +1,632 @@ +// Copyright 2022 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/web_risk_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './web_risk_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Web Risk API defines an interface to detect malicious URLs on your + * website and in client applications. + * @class + * @memberof v1 + */ +export class WebRiskServiceClient { + 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}; + webRiskServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WebRiskServiceClient. + * + * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WebRiskServiceClient; + 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 = { + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.webrisk.v1.WebRiskService', 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.webRiskServiceStub) { + return this.webRiskServiceStub; + } + + // Put together the "service stub" for + // google.cloud.webrisk.v1.WebRiskService. + this.webRiskServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.webrisk.v1.WebRiskService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.webrisk.v1.WebRiskService, + 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 webRiskServiceStubMethods = + ['computeThreatListDiff', 'searchUris', 'searchHashes', 'createSubmission']; + for (const methodName of webRiskServiceStubMethods) { + const callPromise = this.webRiskServiceStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.webRiskServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'webrisk.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 'webrisk.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 -- + // ------------------- +/** + * Gets the most recent threat list diffs. These diffs should be applied to + * a local database of hashes to keep it up-to-date. If the local database is + * empty or excessively out-of-date, a complete snapshot of the database will + * be returned. This Method only updates a single ThreatList at a time. To + * update multiple ThreatList databases, this method needs to be called once + * for each list. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.webrisk.v1.ThreatType} request.threatType + * Required. The threat list to update. Only a single ThreatType should be specified. + * @param {Buffer} request.versionToken + * The current version token of the client for the requested list (the + * client version that was received from the last successful diff). + * If the client does not have a version token (this is the first time calling + * ComputeThreatListDiff), this may be left empty and a full database + * snapshot will be returned. + * @param {google.cloud.webrisk.v1.ComputeThreatListDiffRequest.Constraints} request.constraints + * Required. The constraints associated with this request. + * @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 [ComputeThreatListDiffResponse]{@link google.cloud.webrisk.v1.ComputeThreatListDiffResponse}. + * 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/web_risk_service.compute_threat_list_diff.js + * region_tag:webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async + */ + computeThreatListDiff( + request?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|undefined, {}|undefined + ]>; + computeThreatListDiff( + request: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): void; + computeThreatListDiff( + request: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, + callback: Callback< + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): void; + computeThreatListDiff( + request?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.computeThreatListDiff(request, options, callback); + } +/** + * This method is used to check whether a URI is on a given threatList. + * Multiple threatLists may be searched in a single query. + * The response will list all requested threatLists the URI was found to + * match. If the URI is not found on any of the requested ThreatList an + * empty response will be returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.uri + * Required. The URI to be checked for matches. + * @param {number[]} request.threatTypes + * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + * @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 [SearchUrisResponse]{@link google.cloud.webrisk.v1.SearchUrisResponse}. + * 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/web_risk_service.search_uris.js + * region_tag:webrisk_v1_generated_WebRiskService_SearchUris_async + */ + searchUris( + request?: protos.google.cloud.webrisk.v1.ISearchUrisRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|undefined, {}|undefined + ]>; + searchUris( + request: protos.google.cloud.webrisk.v1.ISearchUrisRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): void; + searchUris( + request: protos.google.cloud.webrisk.v1.ISearchUrisRequest, + callback: Callback< + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): void; + searchUris( + request?: protos.google.cloud.webrisk.v1.ISearchUrisRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1.ISearchUrisRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.searchUris(request, options, callback); + } +/** + * Gets the full hashes that match the requested hash prefix. + * This is used after a hash prefix is looked up in a threatList + * and there is a match. The client side threatList only holds partial hashes + * so the client must query this method to determine if there is a full + * hash match of a threat. + * + * @param {Object} request + * The request object that will be sent. + * @param {Buffer} request.hashPrefix + * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + * hash. For JSON requests, this field is base64-encoded. + * @param {number[]} request.threatTypes + * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. + * @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 [SearchHashesResponse]{@link google.cloud.webrisk.v1.SearchHashesResponse}. + * 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/web_risk_service.search_hashes.js + * region_tag:webrisk_v1_generated_WebRiskService_SearchHashes_async + */ + searchHashes( + request?: protos.google.cloud.webrisk.v1.ISearchHashesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|undefined, {}|undefined + ]>; + searchHashes( + request: protos.google.cloud.webrisk.v1.ISearchHashesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): void; + searchHashes( + request: protos.google.cloud.webrisk.v1.ISearchHashesRequest, + callback: Callback< + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): void; + searchHashes( + request?: protos.google.cloud.webrisk.v1.ISearchHashesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1.ISearchHashesRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.searchHashes(request, options, callback); + } +/** + * Creates a Submission of a URI suspected of containing phishing content to + * be reviewed. If the result verifies the existence of malicious phishing + * content, the site will be added to the [Google's Social Engineering + * lists](https://support.google.com/webmasters/answer/6350487/) in order to + * protect users that could get exposed to this threat in the future. Only + * projects with CREATE_SUBMISSION_USERS visibility can use this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that is making the submission. This string is in + * the format "projects/{project_number}". + * @param {google.cloud.webrisk.v1.Submission} request.submission + * Required. The submission that contains the content of the phishing report. + * @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 [Submission]{@link google.cloud.webrisk.v1.Submission}. + * 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/web_risk_service.create_submission.js + * region_tag:webrisk_v1_generated_WebRiskService_CreateSubmission_async + */ + createSubmission( + request?: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|undefined, {}|undefined + ]>; + createSubmission( + request: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, + {}|null|undefined>): void; + createSubmission( + request: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, + callback: Callback< + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, + {}|null|undefined>): void; + createSubmission( + request?: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1.ISubmission, + protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|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.createSubmission(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * 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 { + if (this.webRiskServiceStub && !this._terminated) { + return this.webRiskServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json b/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json new file mode 100644 index 0000000..b03b2aa --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.webrisk.v1.WebRiskService": { + "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": { + "ComputeThreatListDiff": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SearchUris": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SearchHashes": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateSubmission": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json b/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json new file mode 100644 index 0000000..beac976 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/webrisk/v1/webrisk.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..2bb0ded --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 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 webrisk = require('@google-cloud/web-risk'); + +function main() { + const webRiskServiceClient = new webrisk.WebRiskServiceClient(); +} + +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..d7c75f5 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 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 {WebRiskServiceClient} from '@google-cloud/web-risk'; + +// check that the client class type name can be used +function doStuffWithWebRiskServiceClient(client: WebRiskServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const webRiskServiceClient = new WebRiskServiceClient(); + doStuffWithWebRiskServiceClient(webRiskServiceClient); +} + +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..8ec4522 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 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_web_risk_service_v1.ts b/owl-bot-staging/v1/test/gapic_web_risk_service_v1.ts new file mode 100644 index 0000000..01a22b3 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_web_risk_service_v1.ts @@ -0,0 +1,481 @@ +// Copyright 2022 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 webriskserviceModule from '../src'; + +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); +} + +describe('v1.WebRiskServiceClient', () => { + it('has servicePath', () => { + const servicePath = webriskserviceModule.v1.WebRiskServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = webriskserviceModule.v1.WebRiskServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = webriskserviceModule.v1.WebRiskServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.webRiskServiceStub, undefined); + await client.initialize(); + assert(client.webRiskServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.webRiskServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.webRiskServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + 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 webriskserviceModule.v1.WebRiskServiceClient({ + 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('computeThreatListDiff', () => { + it('invokes computeThreatListDiff without error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse()); + client.innerApiCalls.computeThreatListDiff = stubSimpleCall(expectedResponse); + const [response] = await client.computeThreatListDiff(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes computeThreatListDiff without error using callback', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse()); + client.innerApiCalls.computeThreatListDiff = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.computeThreatListDiff( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes computeThreatListDiff with error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.computeThreatListDiff = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.computeThreatListDiff(request), expectedError); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes computeThreatListDiff with closed client', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.computeThreatListDiff(request), expectedError); + }); + }); + + describe('searchUris', () => { + it('invokes searchUris without error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisResponse()); + client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); + const [response] = await client.searchUris(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchUris without error using callback', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisResponse()); + client.innerApiCalls.searchUris = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchUris( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISearchUrisResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchUris with error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchUris = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchUris(request), expectedError); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchUris with closed client', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.searchUris(request), expectedError); + }); + }); + + describe('searchHashes', () => { + it('invokes searchHashes without error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesResponse()); + client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); + const [response] = await client.searchHashes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchHashes without error using callback', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesResponse()); + client.innerApiCalls.searchHashes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchHashes( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISearchHashesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchHashes with error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchHashes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchHashes(request), expectedError); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchHashes with closed client', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.searchHashes(request), expectedError); + }); + }); + + describe('createSubmission', () => { + it('invokes createSubmission without error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.Submission()); + client.innerApiCalls.createSubmission = stubSimpleCall(expectedResponse); + const [response] = await client.createSubmission(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createSubmission as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createSubmission without error using callback', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.Submission()); + client.innerApiCalls.createSubmission = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSubmission( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISubmission|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createSubmission as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createSubmission with error', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createSubmission = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSubmission(request), expectedError); + assert((client.innerApiCalls.createSubmission as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createSubmission with closed client', async () => { + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSubmission(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new webriskserviceModule.v1.WebRiskServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 0000000..c459176 --- /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: 'WebRiskService', + filename: './web-risk-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..9d0daa4 --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 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 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/web-risk', + 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..481c522 --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 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..494e147 --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 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..55d440e --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Webrisk: 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..befd23c --- /dev/null +++ b/owl-bot-staging/v1beta1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 0000000..9ae9d86 --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/web-risk", + "version": "0.1.0", + "description": "Webrisk client for Node.js", + "repository": "googleapis/nodejs-webrisk", + "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 webrisk", + "webrisk", + "web risk 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": "^3.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto b/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto new file mode 100644 index 0000000..0226425 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto @@ -0,0 +1,303 @@ +// 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.webrisk.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebRisk.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/webrisk/v1beta1;webrisk"; +option java_multiple_files = true; +option java_outer_classname = "WebRiskProto"; +option java_package = "com.google.webrisk.v1beta1"; +option objc_class_prefix = "GCWR"; +option php_namespace = "Google\\Cloud\\WebRisk\\V1beta1"; +option ruby_package = "Google::Cloud::WebRisk::V1beta1"; + +// Web Risk v1beta1 API defines an interface to detect malicious URLs on your +// website and in client applications. +service WebRiskServiceV1Beta1 { + option (google.api.default_host) = "webrisk.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Gets the most recent threat list diffs. + rpc ComputeThreatListDiff(ComputeThreatListDiffRequest) returns (ComputeThreatListDiffResponse) { + option (google.api.http) = { + get: "/v1beta1/threatLists:computeDiff" + }; + option (google.api.method_signature) = "threat_type,version_token,constraints"; + } + + // This method is used to check whether a URI is on a given threatList. + rpc SearchUris(SearchUrisRequest) returns (SearchUrisResponse) { + option (google.api.http) = { + get: "/v1beta1/uris:search" + }; + option (google.api.method_signature) = "uri,threat_types"; + } + + // Gets the full hashes that match the requested hash prefix. + // This is used after a hash prefix is looked up in a threatList + // and there is a match. The client side threatList only holds partial hashes + // so the client must query this method to determine if there is a full + // hash match of a threat. + rpc SearchHashes(SearchHashesRequest) returns (SearchHashesResponse) { + option (google.api.http) = { + get: "/v1beta1/hashes:search" + }; + option (google.api.method_signature) = "hash_prefix,threat_types"; + } +} + +// Describes an API diff request. +message ComputeThreatListDiffRequest { + // The constraints for this diff. + message Constraints { + // The maximum size in number of entries. The diff will not contain more + // entries than this value. This should be a power of 2 between 2**10 and + // 2**20. If zero, no diff size limit is set. + int32 max_diff_entries = 1; + + // Sets the maximum number of entries that the client is willing to have + // in the local database. This should be a power of 2 between 2**10 and + // 2**20. If zero, no database size limit is set. + int32 max_database_entries = 2; + + // The compression types supported by the client. + repeated CompressionType supported_compressions = 3; + } + + // The ThreatList to update. + ThreatType threat_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // The current version token of the client for the requested list (the + // client version that was received from the last successful diff). + bytes version_token = 2; + + // Required. The constraints associated with this request. + Constraints constraints = 3 [(google.api.field_behavior) = REQUIRED]; +} + +message ComputeThreatListDiffResponse { + // The expected state of a client's local database. + message Checksum { + // The SHA256 hash of the client state; that is, of the sorted list of all + // hashes present in the database. + bytes sha256 = 1; + } + + // The type of response sent to the client. + enum ResponseType { + // Unknown. + RESPONSE_TYPE_UNSPECIFIED = 0; + + // Partial updates are applied to the client's existing local database. + DIFF = 1; + + // Full updates resets the client's entire local database. This means + // that either the client had no state, was seriously out-of-date, + // or the client is believed to be corrupt. + RESET = 2; + } + + // The type of response. This may indicate that an action must be taken by the + // client when the response is received. + ResponseType response_type = 4; + + // A set of entries to add to a local threat type's list. + ThreatEntryAdditions additions = 5; + + // A set of entries to remove from a local threat type's list. + // This field may be empty. + ThreatEntryRemovals removals = 6; + + // The new opaque client version token. + bytes new_version_token = 7; + + // The expected SHA256 hash of the client state; that is, of the sorted list + // of all hashes present in the database after applying the provided diff. + // If the client state doesn't match the expected state, the client must + // disregard this diff and retry later. + Checksum checksum = 8; + + // The soonest the client should wait before issuing any diff + // request. Querying sooner is unlikely to produce a meaningful diff. + // Waiting longer is acceptable considering the use case. + // If this field is not set clients may update as soon as they want. + google.protobuf.Timestamp recommended_next_diff = 2; +} + +// Request to check URI entries against threatLists. +message SearchUrisRequest { + // Required. The URI to be checked for matches. + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ThreatLists to search in. + repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; +} + +message SearchUrisResponse { + // Contains threat information on a matching uri. + message ThreatUri { + // The ThreatList this threat belongs to. + repeated ThreatType threat_types = 1; + + // The cache lifetime for the returned match. Clients must not cache this + // response past this timestamp to avoid false positives. + google.protobuf.Timestamp expire_time = 2; + } + + // The threat list matches. This may be empty if the URI is on no list. + ThreatUri threat = 1; +} + +// Request to return full hashes matched by the provided hash prefixes. +message SearchHashesRequest { + // A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + // hash. For JSON requests, this field is base64-encoded. + bytes hash_prefix = 1; + + // Required. The ThreatLists to search in. + repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; +} + +message SearchHashesResponse { + // Contains threat information on a matching hash. + message ThreatHash { + // The ThreatList this threat belongs to. + // This must contain at least one entry. + repeated ThreatType threat_types = 1; + + // A 32 byte SHA256 hash. This field is in binary format. For JSON + // requests, hashes are base64-encoded. + bytes hash = 2; + + // The cache lifetime for the returned match. Clients must not cache this + // response past this timestamp to avoid false positives. + google.protobuf.Timestamp expire_time = 3; + } + + // The full hashes that matched the requested prefixes. + // The hash will be populated in the key. + repeated ThreatHash threats = 1; + + // For requested entities that did not match the threat list, how long to + // cache the response until. + google.protobuf.Timestamp negative_expire_time = 2; +} + +// Contains the set of entries to add to a local database. +// May contain a combination of compressed and raw data in a single response. +message ThreatEntryAdditions { + // The raw SHA256-formatted entries. + // Repeated to allow returning sets of hashes with different prefix sizes. + repeated RawHashes raw_hashes = 1; + + // The encoded 4-byte prefixes of SHA256-formatted entries, using a + // Golomb-Rice encoding. The hashes are converted to uint32, sorted in + // ascending order, then delta encoded and stored as encoded_data. + RiceDeltaEncoding rice_hashes = 2; +} + +// Contains the set of entries to remove from a local database. +message ThreatEntryRemovals { + // The raw removal indices for a local list. + RawIndices raw_indices = 1; + + // The encoded local, lexicographically-sorted list indices, using a + // Golomb-Rice encoding. Used for sending compressed removal indices. The + // removal indices (uint32) are sorted in ascending order, then delta encoded + // and stored as encoded_data. + RiceDeltaEncoding rice_indices = 2; +} + +// The type of threat. This maps dirrectly to the threat list a threat may +// belong to. +enum ThreatType { + // Unknown. + THREAT_TYPE_UNSPECIFIED = 0; + + // Malware targeting any platform. + MALWARE = 1; + + // Social engineering targeting any platform. + SOCIAL_ENGINEERING = 2; + + // Unwanted software targeting any platform. + UNWANTED_SOFTWARE = 3; +} + +// The ways in which threat entry sets can be compressed. +enum CompressionType { + // Unknown. + COMPRESSION_TYPE_UNSPECIFIED = 0; + + // Raw, uncompressed data. + RAW = 1; + + // Rice-Golomb encoded data. + RICE = 2; +} + +// A set of raw indices to remove from a local list. +message RawIndices { + // The indices to remove from a lexicographically-sorted local list. + repeated int32 indices = 1; +} + +// The uncompressed threat entries in hash format. +// Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 +// bytes, but some hashes are lengthened if they collide with the hash of a +// popular URI. +// +// Used for sending ThreatEntryAdditons to clients that do not support +// compression, or when sending non-4-byte hashes to clients that do support +// compression. +message RawHashes { + // The number of bytes for each prefix encoded below. This field can be + // anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). + int32 prefix_size = 1; + + // The hashes, in binary format, concatenated into one long string. Hashes are + // sorted in lexicographic order. For JSON API users, hashes are + // base64-encoded. + bytes raw_hashes = 2; +} + +// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or +// compressed removal indices. +message RiceDeltaEncoding { + // The offset of the first entry in the encoded data, or, if only a single + // integer was encoded, that single integer's value. If the field is empty or + // missing, assume zero. + int64 first_value = 1; + + // The Golomb-Rice parameter, which is a number between 2 and 28. This field + // is missing (that is, zero) if `num_entries` is zero. + int32 rice_parameter = 2; + + // The number of entries that are delta encoded in the encoded data. If only a + // single integer was encoded, this will be zero and the single value will be + // stored in `first_value`. + int32 entry_count = 3; + + // The encoded deltas that are encoded using the Golomb-Rice coder. + bytes encoded_data = 4; +} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json new file mode 100644 index 0000000..bfb79e8 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json @@ -0,0 +1,151 @@ +{ + "clientLibrary": { + "name": "nodejs-webrisk", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.webrisk.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async", + "title": "WebRiskServiceV1Beta1 computeThreatListDiff Sample", + "origin": "API_DEFINITION", + "description": " Gets the most recent threat list diffs.", + "canonical": true, + "file": "web_risk_service_v1_beta1.compute_threat_list_diff.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ComputeThreatListDiff", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.ComputeThreatListDiff", + "async": true, + "parameters": [ + { + "name": "threat_type", + "type": ".google.cloud.webrisk.v1beta1.ThreatType" + }, + { + "name": "version_token", + "type": "TYPE_BYTES" + }, + { + "name": "constraints", + "type": ".google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest.Constraints" + } + ], + "resultType": ".google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse", + "client": { + "shortName": "WebRiskServiceV1Beta1Client", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" + }, + "method": { + "shortName": "ComputeThreatListDiff", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.ComputeThreatListDiff", + "service": { + "shortName": "WebRiskServiceV1Beta1", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" + } + } + } + }, + { + "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async", + "title": "WebRiskServiceV1Beta1 searchUris Sample", + "origin": "API_DEFINITION", + "description": " This method is used to check whether a URI is on a given threatList.", + "canonical": true, + "file": "web_risk_service_v1_beta1.search_uris.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchUris", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchUris", + "async": true, + "parameters": [ + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "threat_types", + "type": "TYPE_ENUM[]" + } + ], + "resultType": ".google.cloud.webrisk.v1beta1.SearchUrisResponse", + "client": { + "shortName": "WebRiskServiceV1Beta1Client", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" + }, + "method": { + "shortName": "SearchUris", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchUris", + "service": { + "shortName": "WebRiskServiceV1Beta1", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" + } + } + } + }, + { + "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async", + "title": "WebRiskServiceV1Beta1 searchHashes Sample", + "origin": "API_DEFINITION", + "description": " Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.", + "canonical": true, + "file": "web_risk_service_v1_beta1.search_hashes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchHashes", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchHashes", + "async": true, + "parameters": [ + { + "name": "hash_prefix", + "type": "TYPE_BYTES" + }, + { + "name": "threat_types", + "type": "TYPE_ENUM[]" + } + ], + "resultType": ".google.cloud.webrisk.v1beta1.SearchHashesResponse", + "client": { + "shortName": "WebRiskServiceV1Beta1Client", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" + }, + "method": { + "shortName": "SearchHashes", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchHashes", + "service": { + "shortName": "WebRiskServiceV1Beta1", + "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js new file mode 100644 index 0000000..3c94725 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js @@ -0,0 +1,68 @@ +// Copyright 2022 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'; + +function main(threatType, constraints) { + // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The ThreatList to update. + */ + // const threatType = {} + /** + * The current version token of the client for the requested list (the + * client version that was received from the last successful diff). + */ + // const versionToken = 'Buffer.from('string')' + /** + * Required. The constraints associated with this request. + */ + // const constraints = {} + + // Imports the Webrisk library + const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; + + // Instantiates a client + const webriskClient = new WebRiskServiceV1Beta1Client(); + + async function callComputeThreatListDiff() { + // Construct request + const request = { + threatType, + constraints, + }; + + // Run request + const response = await webriskClient.computeThreatListDiff(request); + console.log(response); + } + + callComputeThreatListDiff(); + // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_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/web_risk_service_v1_beta1.search_hashes.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js new file mode 100644 index 0000000..833229a --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js @@ -0,0 +1,63 @@ +// Copyright 2022 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'; + +function main(threatTypes) { + // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + * hash. For JSON requests, this field is base64-encoded. + */ + // const hashPrefix = 'Buffer.from('string')' + /** + * Required. The ThreatLists to search in. + */ + // const threatTypes = 1234 + + // Imports the Webrisk library + const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; + + // Instantiates a client + const webriskClient = new WebRiskServiceV1Beta1Client(); + + async function callSearchHashes() { + // Construct request + const request = { + threatTypes, + }; + + // Run request + const response = await webriskClient.searchHashes(request); + console.log(response); + } + + callSearchHashes(); + // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_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/web_risk_service_v1_beta1.search_uris.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.js new file mode 100644 index 0000000..a0b6bac --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.js @@ -0,0 +1,63 @@ +// Copyright 2022 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'; + +function main(uri, threatTypes) { + // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The URI to be checked for matches. + */ + // const uri = 'abc123' + /** + * Required. The ThreatLists to search in. + */ + // const threatTypes = 1234 + + // Imports the Webrisk library + const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; + + // Instantiates a client + const webriskClient = new WebRiskServiceV1Beta1Client(); + + async function callSearchUris() { + // Construct request + const request = { + uri, + threatTypes, + }; + + // Run request + const response = await webriskClient.searchUris(request); + console.log(response); + } + + callSearchUris(); + // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_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..5ee3cd4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 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 WebRiskServiceV1Beta1Client = v1beta1.WebRiskServiceV1Beta1Client; +type WebRiskServiceV1Beta1Client = v1beta1.WebRiskServiceV1Beta1Client; +export {v1beta1, WebRiskServiceV1Beta1Client}; +export default {v1beta1, WebRiskServiceV1Beta1Client}; +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..9ed88dd --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,53 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.webrisk.v1beta1", + "libraryPackage": "@google-cloud/web-risk", + "services": { + "WebRiskServiceV1Beta1": { + "clients": { + "grpc": { + "libraryClient": "WebRiskServiceV1Beta1Client", + "rpcs": { + "ComputeThreatListDiff": { + "methods": [ + "computeThreatListDiff" + ] + }, + "SearchUris": { + "methods": [ + "searchUris" + ] + }, + "SearchHashes": { + "methods": [ + "searchHashes" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WebRiskServiceV1Beta1Client", + "rpcs": { + "ComputeThreatListDiff": { + "methods": [ + "computeThreatListDiff" + ] + }, + "SearchUris": { + "methods": [ + "searchUris" + ] + }, + "SearchHashes": { + "methods": [ + "searchHashes" + ] + } + } + } + } + } + } +} 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..6edca0f --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 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 {WebRiskServiceV1Beta1Client} from './web_risk_service_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts new file mode 100644 index 0000000..b557036 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts @@ -0,0 +1,505 @@ +// Copyright 2022 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} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/web_risk_service_v1_beta1_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './web_risk_service_v1_beta1_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Web Risk v1beta1 API defines an interface to detect malicious URLs on your + * website and in client applications. + * @class + * @memberof v1beta1 + */ +export class WebRiskServiceV1Beta1Client { + 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}; + webRiskServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WebRiskServiceV1Beta1Client. + * + * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WebRiskServiceV1Beta1Client; + 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1', 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.webRiskServiceV1Beta1Stub) { + return this.webRiskServiceV1Beta1Stub; + } + + // Put together the "service stub" for + // google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1. + this.webRiskServiceV1Beta1Stub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1, + 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 webRiskServiceV1Beta1StubMethods = + ['computeThreatListDiff', 'searchUris', 'searchHashes']; + for (const methodName of webRiskServiceV1Beta1StubMethods) { + const callPromise = this.webRiskServiceV1Beta1Stub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.webRiskServiceV1Beta1Stub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'webrisk.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 'webrisk.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 -- + // ------------------- +/** + * Gets the most recent threat list diffs. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.webrisk.v1beta1.ThreatType} request.threatType + * The ThreatList to update. + * @param {Buffer} request.versionToken + * The current version token of the client for the requested list (the + * client version that was received from the last successful diff). + * @param {google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest.Constraints} request.constraints + * Required. The constraints associated with this request. + * @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 [ComputeThreatListDiffResponse]{@link google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse}. + * 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/web_risk_service_v1_beta1.compute_threat_list_diff.js + * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async + */ + computeThreatListDiff( + request?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|undefined, {}|undefined + ]>; + computeThreatListDiff( + request: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): void; + computeThreatListDiff( + request: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): void; + computeThreatListDiff( + request?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, + protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.computeThreatListDiff(request, options, callback); + } +/** + * This method is used to check whether a URI is on a given threatList. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.uri + * Required. The URI to be checked for matches. + * @param {number[]} request.threatTypes + * Required. The ThreatLists to search in. + * @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 [SearchUrisResponse]{@link google.cloud.webrisk.v1beta1.SearchUrisResponse}. + * 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/web_risk_service_v1_beta1.search_uris.js + * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async + */ + searchUris( + request?: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|undefined, {}|undefined + ]>; + searchUris( + request: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): void; + searchUris( + request: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): void; + searchUris( + request?: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, + protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.searchUris(request, options, callback); + } +/** + * Gets the full hashes that match the requested hash prefix. + * This is used after a hash prefix is looked up in a threatList + * and there is a match. The client side threatList only holds partial hashes + * so the client must query this method to determine if there is a full + * hash match of a threat. + * + * @param {Object} request + * The request object that will be sent. + * @param {Buffer} request.hashPrefix + * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 + * hash. For JSON requests, this field is base64-encoded. + * @param {number[]} request.threatTypes + * Required. The ThreatLists to search in. + * @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 [SearchHashesResponse]{@link google.cloud.webrisk.v1beta1.SearchHashesResponse}. + * 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/web_risk_service_v1_beta1.search_hashes.js + * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async + */ + searchHashes( + request?: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|undefined, {}|undefined + ]>; + searchHashes( + request: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): void; + searchHashes( + request: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, + callback: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): void; + searchHashes( + request?: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, + protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|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 || {}; + this.initialize(); + return this.innerApiCalls.searchHashes(request, options, callback); + } + + + /** + * 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 { + if (this.webRiskServiceV1Beta1Stub && !this._terminated) { + return this.webRiskServiceV1Beta1Stub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json new file mode 100644 index 0000000..669c223 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json @@ -0,0 +1,41 @@ +{ + "interfaces": { + "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1": { + "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": { + "ComputeThreatListDiff": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SearchUris": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SearchHashes": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json new file mode 100644 index 0000000..9b9d465 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/webrisk/v1beta1/webrisk.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..2791d43 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 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 webrisk = require('@google-cloud/web-risk'); + +function main() { + const webRiskServiceV1Beta1Client = new webrisk.WebRiskServiceV1Beta1Client(); +} + +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..19bf121 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 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 {WebRiskServiceV1Beta1Client} from '@google-cloud/web-risk'; + +// check that the client class type name can be used +function doStuffWithWebRiskServiceV1Beta1Client(client: WebRiskServiceV1Beta1Client) { + client.close(); +} + +function main() { + // check that the client instance can be created + const webRiskServiceV1Beta1Client = new WebRiskServiceV1Beta1Client(); + doStuffWithWebRiskServiceV1Beta1Client(webRiskServiceV1Beta1Client); +} + +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..8ec4522 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 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_web_risk_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_web_risk_service_v1_beta1_v1beta1.ts new file mode 100644 index 0000000..ac8acd1 --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_web_risk_service_v1_beta1_v1beta1.ts @@ -0,0 +1,351 @@ +// Copyright 2022 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 webriskservicev1beta1Module from '../src'; + +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); +} + +describe('v1beta1.WebRiskServiceV1Beta1Client', () => { + it('has servicePath', () => { + const servicePath = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.webRiskServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.webRiskServiceV1Beta1Stub); + }); + + it('has close method for the initialized client', done => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.webRiskServiceV1Beta1Stub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.webRiskServiceV1Beta1Stub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + 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 webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + 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('computeThreatListDiff', () => { + it('invokes computeThreatListDiff without error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse()); + client.innerApiCalls.computeThreatListDiff = stubSimpleCall(expectedResponse); + const [response] = await client.computeThreatListDiff(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes computeThreatListDiff without error using callback', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse()); + client.innerApiCalls.computeThreatListDiff = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.computeThreatListDiff( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes computeThreatListDiff with error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.computeThreatListDiff = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.computeThreatListDiff(request), expectedError); + assert((client.innerApiCalls.computeThreatListDiff as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes computeThreatListDiff with closed client', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.computeThreatListDiff(request), expectedError); + }); + }); + + describe('searchUris', () => { + it('invokes searchUris without error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse()); + client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); + const [response] = await client.searchUris(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchUris without error using callback', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse()); + client.innerApiCalls.searchUris = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchUris( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchUris with error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchUris = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchUris(request), expectedError); + assert((client.innerApiCalls.searchUris as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchUris with closed client', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.searchUris(request), expectedError); + }); + }); + + describe('searchHashes', () => { + it('invokes searchHashes without error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse()); + client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); + const [response] = await client.searchHashes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchHashes without error using callback', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse()); + client.innerApiCalls.searchHashes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchHashes( + request, + (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchHashes with error', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchHashes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchHashes(request), expectedError); + assert((client.innerApiCalls.searchHashes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchHashes with closed client', async () => { + const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.searchHashes(request), expectedError); + }); + }); +}); 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..9179bba --- /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: 'WebRiskServiceV1Beta1', + filename: './web-risk-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 bf1afacba7cd3df43dbb12cfb9a74d75afa1a91c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 09:51:00 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= 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 | 16 - owl-bot-staging/v1/package.json | 64 -- .../google/cloud/webrisk/v1/webrisk.proto | 353 ---------- ...ppet_metadata.google.cloud.webrisk.v1.json | 195 ------ ...b_risk_service.compute_threat_list_diff.js | 71 -- .../v1/web_risk_service.create_submission.js | 64 -- .../v1/web_risk_service.search_hashes.js | 63 -- .../v1/web_risk_service.search_uris.js | 63 -- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 63 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../v1/src/v1/web_risk_service_client.ts | 632 ------------------ .../v1/web_risk_service_client_config.json | 46 -- .../src/v1/web_risk_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 -- .../v1/test/gapic_web_risk_service_v1.ts | 481 ------------- 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 | 16 - owl-bot-staging/v1beta1/package.json | 64 -- .../cloud/webrisk/v1beta1/webrisk.proto | 303 --------- ...metadata.google.cloud.webrisk.v1beta1.json | 151 ----- ...rvice_v1_beta1.compute_threat_list_diff.js | 68 -- ...web_risk_service_v1_beta1.search_hashes.js | 63 -- .../web_risk_service_v1_beta1.search_uris.js | 63 -- owl-bot-staging/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/gapic_metadata.json | 53 -- owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 - .../web_risk_service_v1_beta1_client.ts | 505 -------------- ...b_risk_service_v1_beta1_client_config.json | 41 -- .../web_risk_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 -- ...gapic_web_risk_service_v1_beta1_v1beta1.ts | 351 ---------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 -- src/v1/web_risk_service_client.ts | 11 +- .../web_risk_service_v1_beta1_client.ts | 11 +- 55 files changed, 10 insertions(+), 4547 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/webrisk/v1/webrisk.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json delete mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.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/web_risk_service_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/web_risk_service_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/web_risk_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_web_risk_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/webrisk/v1beta1/webrisk.proto delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.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/web_risk_service_v1_beta1_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/web_risk_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_web_risk_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 9d0daa4..0000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/web-risk', - 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 481c522..0000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 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 494e147..0000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 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 55d440e..0000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Webrisk: 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 befd23c..0000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 0241e6a..0000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/web-risk", - "version": "0.1.0", - "description": "Webrisk client for Node.js", - "repository": "googleapis/nodejs-webrisk", - "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 webrisk", - "webrisk", - "web risk 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": "^3.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto b/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto deleted file mode 100644 index 71b6b44..0000000 --- a/owl-bot-staging/v1/protos/google/cloud/webrisk/v1/webrisk.proto +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.webrisk.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/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.WebRisk.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/webrisk/v1;webrisk"; -option java_multiple_files = true; -option java_outer_classname = "WebRiskProto"; -option java_package = "com.google.webrisk.v1"; -option objc_class_prefix = "GCWR"; -option php_namespace = "Google\\Cloud\\WebRisk\\V1"; -option ruby_package = "Google::Cloud::WebRisk::V1"; - -// Web Risk API defines an interface to detect malicious URLs on your -// website and in client applications. -service WebRiskService { - option (google.api.default_host) = "webrisk.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Gets the most recent threat list diffs. These diffs should be applied to - // a local database of hashes to keep it up-to-date. If the local database is - // empty or excessively out-of-date, a complete snapshot of the database will - // be returned. This Method only updates a single ThreatList at a time. To - // update multiple ThreatList databases, this method needs to be called once - // for each list. - rpc ComputeThreatListDiff(ComputeThreatListDiffRequest) returns (ComputeThreatListDiffResponse) { - option (google.api.http) = { - get: "/v1/threatLists:computeDiff" - }; - option (google.api.method_signature) = "threat_type,version_token,constraints"; - } - - // This method is used to check whether a URI is on a given threatList. - // Multiple threatLists may be searched in a single query. - // The response will list all requested threatLists the URI was found to - // match. If the URI is not found on any of the requested ThreatList an - // empty response will be returned. - rpc SearchUris(SearchUrisRequest) returns (SearchUrisResponse) { - option (google.api.http) = { - get: "/v1/uris:search" - }; - option (google.api.method_signature) = "uri,threat_types"; - } - - // Gets the full hashes that match the requested hash prefix. - // This is used after a hash prefix is looked up in a threatList - // and there is a match. The client side threatList only holds partial hashes - // so the client must query this method to determine if there is a full - // hash match of a threat. - rpc SearchHashes(SearchHashesRequest) returns (SearchHashesResponse) { - option (google.api.http) = { - get: "/v1/hashes:search" - }; - option (google.api.method_signature) = "hash_prefix,threat_types"; - } - - // Creates a Submission of a URI suspected of containing phishing content to - // be reviewed. If the result verifies the existence of malicious phishing - // content, the site will be added to the [Google's Social Engineering - // lists](https://support.google.com/webmasters/answer/6350487/) in order to - // protect users that could get exposed to this threat in the future. Only - // projects with CREATE_SUBMISSION_USERS visibility can use this method. - rpc CreateSubmission(CreateSubmissionRequest) returns (Submission) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/submissions" - body: "submission" - }; - option (google.api.method_signature) = "parent,submission"; - } -} - -// Describes an API diff request. -message ComputeThreatListDiffRequest { - // The constraints for this diff. - message Constraints { - // The maximum size in number of entries. The diff will not contain more - // entries than this value. This should be a power of 2 between 2**10 and - // 2**20. If zero, no diff size limit is set. - int32 max_diff_entries = 1; - - // Sets the maximum number of entries that the client is willing to have - // in the local database. This should be a power of 2 between 2**10 and - // 2**20. If zero, no database size limit is set. - int32 max_database_entries = 2; - - // The compression types supported by the client. - repeated CompressionType supported_compressions = 3; - } - - // Required. The threat list to update. Only a single ThreatType should be specified. - ThreatType threat_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // The current version token of the client for the requested list (the - // client version that was received from the last successful diff). - // If the client does not have a version token (this is the first time calling - // ComputeThreatListDiff), this may be left empty and a full database - // snapshot will be returned. - bytes version_token = 2; - - // Required. The constraints associated with this request. - Constraints constraints = 3 [(google.api.field_behavior) = REQUIRED]; -} - -message ComputeThreatListDiffResponse { - // The expected state of a client's local database. - message Checksum { - // The SHA256 hash of the client state; that is, of the sorted list of all - // hashes present in the database. - bytes sha256 = 1; - } - - // The type of response sent to the client. - enum ResponseType { - // Unknown. - RESPONSE_TYPE_UNSPECIFIED = 0; - - // Partial updates are applied to the client's existing local database. - DIFF = 1; - - // Full updates resets the client's entire local database. This means - // that either the client had no state, was seriously out-of-date, - // or the client is believed to be corrupt. - RESET = 2; - } - - // The type of response. This may indicate that an action must be taken by the - // client when the response is received. - ResponseType response_type = 4; - - // A set of entries to add to a local threat type's list. - ThreatEntryAdditions additions = 5; - - // A set of entries to remove from a local threat type's list. - // This field may be empty. - ThreatEntryRemovals removals = 6; - - // The new opaque client version token. This should be retained by the client - // and passed into the next call of ComputeThreatListDiff as 'version_token'. - // A separate version token should be stored and used for each threatList. - bytes new_version_token = 7; - - // The expected SHA256 hash of the client state; that is, of the sorted list - // of all hashes present in the database after applying the provided diff. - // If the client state doesn't match the expected state, the client must - // discard this diff and retry later. - Checksum checksum = 8; - - // The soonest the client should wait before issuing any diff - // request. Querying sooner is unlikely to produce a meaningful diff. - // Waiting longer is acceptable considering the use case. - // If this field is not set clients may update as soon as they want. - google.protobuf.Timestamp recommended_next_diff = 2; -} - -// Request to check URI entries against threatLists. -message SearchUrisRequest { - // Required. The URI to be checked for matches. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; -} - -message SearchUrisResponse { - // Contains threat information on a matching uri. - message ThreatUri { - // The ThreatList this threat belongs to. - repeated ThreatType threat_types = 1; - - // The cache lifetime for the returned match. Clients must not cache this - // response past this timestamp to avoid false positives. - google.protobuf.Timestamp expire_time = 2; - } - - // The threat list matches. This may be empty if the URI is on no list. - ThreatUri threat = 1; -} - -// Request to return full hashes matched by the provided hash prefixes. -message SearchHashesRequest { - // A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - // hash. For JSON requests, this field is base64-encoded. - bytes hash_prefix = 1; - - // Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; -} - -message SearchHashesResponse { - // Contains threat information on a matching hash. - message ThreatHash { - // The ThreatList this threat belongs to. - // This must contain at least one entry. - repeated ThreatType threat_types = 1; - - // A 32 byte SHA256 hash. This field is in binary format. For JSON - // requests, hashes are base64-encoded. - bytes hash = 2; - - // The cache lifetime for the returned match. Clients must not cache this - // response past this timestamp to avoid false positives. - google.protobuf.Timestamp expire_time = 3; - } - - // The full hashes that matched the requested prefixes. - // The hash will be populated in the key. - repeated ThreatHash threats = 1; - - // For requested entities that did not match the threat list, how long to - // cache the response until. - google.protobuf.Timestamp negative_expire_time = 2; -} - -// Contains the set of entries to add to a local database. -// May contain a combination of compressed and raw data in a single response. -message ThreatEntryAdditions { - // The raw SHA256-formatted entries. - // Repeated to allow returning sets of hashes with different prefix sizes. - repeated RawHashes raw_hashes = 1; - - // The encoded 4-byte prefixes of SHA256-formatted entries, using a - // Golomb-Rice encoding. The hashes are converted to uint32, sorted in - // ascending order, then delta encoded and stored as encoded_data. - RiceDeltaEncoding rice_hashes = 2; -} - -// Contains the set of entries to remove from a local database. -message ThreatEntryRemovals { - // The raw removal indices for a local list. - RawIndices raw_indices = 1; - - // The encoded local, lexicographically-sorted list indices, using a - // Golomb-Rice encoding. Used for sending compressed removal indices. The - // removal indices (uint32) are sorted in ascending order, then delta encoded - // and stored as encoded_data. - RiceDeltaEncoding rice_indices = 2; -} - -// The type of threat. This maps dirrectly to the threat list a threat may -// belong to. -enum ThreatType { - // Unknown. - THREAT_TYPE_UNSPECIFIED = 0; - - // Malware targeting any platform. - MALWARE = 1; - - // Social engineering targeting any platform. - SOCIAL_ENGINEERING = 2; - - // Unwanted software targeting any platform. - UNWANTED_SOFTWARE = 3; -} - -// The ways in which threat entry sets can be compressed. -enum CompressionType { - // Unknown. - COMPRESSION_TYPE_UNSPECIFIED = 0; - - // Raw, uncompressed data. - RAW = 1; - - // Rice-Golomb encoded data. - RICE = 2; -} - -// A set of raw indices to remove from a local list. -message RawIndices { - // The indices to remove from a lexicographically-sorted local list. - repeated int32 indices = 1; -} - -// The uncompressed threat entries in hash format. -// Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 -// bytes, but some hashes are lengthened if they collide with the hash of a -// popular URI. -// -// Used for sending ThreatEntryAdditons to clients that do not support -// compression, or when sending non-4-byte hashes to clients that do support -// compression. -message RawHashes { - // The number of bytes for each prefix encoded below. This field can be - // anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). - // In practice this is almost always 4, except in exceptional circumstances. - int32 prefix_size = 1; - - // The hashes, in binary format, concatenated into one long string. Hashes are - // sorted in lexicographic order. For JSON API users, hashes are - // base64-encoded. - bytes raw_hashes = 2; -} - -// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or -// compressed removal indices. -message RiceDeltaEncoding { - // The offset of the first entry in the encoded data, or, if only a single - // integer was encoded, that single integer's value. If the field is empty or - // missing, assume zero. - int64 first_value = 1; - - // The Golomb-Rice parameter, which is a number between 2 and 28. This field - // is missing (that is, zero) if `num_entries` is zero. - int32 rice_parameter = 2; - - // The number of entries that are delta encoded in the encoded data. If only a - // single integer was encoded, this will be zero and the single value will be - // stored in `first_value`. - int32 entry_count = 3; - - // The encoded deltas that are encoded using the Golomb-Rice coder. - bytes encoded_data = 4; -} - -// Wraps a URI that might be displaying phishing content. -message Submission { - // Required. The URI that is being reported for phishing content to be analyzed. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request to send a potentially phishy URI to WebRisk. -message CreateSubmissionRequest { - // Required. The name of the project that is making the submission. This string is 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 submission that contains the content of the phishing report. - Submission submission = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json deleted file mode 100644 index 114dcfd..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.webrisk.v1.json +++ /dev/null @@ -1,195 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-webrisk", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.webrisk.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async", - "title": "WebRiskService computeThreatListDiff Sample", - "origin": "API_DEFINITION", - "description": " Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.", - "canonical": true, - "file": "web_risk_service.compute_threat_list_diff.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ComputeThreatListDiff", - "fullName": "google.cloud.webrisk.v1.WebRiskService.ComputeThreatListDiff", - "async": true, - "parameters": [ - { - "name": "threat_type", - "type": ".google.cloud.webrisk.v1.ThreatType" - }, - { - "name": "version_token", - "type": "TYPE_BYTES" - }, - { - "name": "constraints", - "type": ".google.cloud.webrisk.v1.ComputeThreatListDiffRequest.Constraints" - } - ], - "resultType": ".google.cloud.webrisk.v1.ComputeThreatListDiffResponse", - "client": { - "shortName": "WebRiskServiceClient", - "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" - }, - "method": { - "shortName": "ComputeThreatListDiff", - "fullName": "google.cloud.webrisk.v1.WebRiskService.ComputeThreatListDiff", - "service": { - "shortName": "WebRiskService", - "fullName": "google.cloud.webrisk.v1.WebRiskService" - } - } - } - }, - { - "regionTag": "webrisk_v1_generated_WebRiskService_SearchUris_async", - "title": "WebRiskService searchUris Sample", - "origin": "API_DEFINITION", - "description": " This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.", - "canonical": true, - "file": "web_risk_service.search_uris.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchUris", - "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchUris", - "async": true, - "parameters": [ - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "threat_types", - "type": "TYPE_ENUM[]" - } - ], - "resultType": ".google.cloud.webrisk.v1.SearchUrisResponse", - "client": { - "shortName": "WebRiskServiceClient", - "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" - }, - "method": { - "shortName": "SearchUris", - "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchUris", - "service": { - "shortName": "WebRiskService", - "fullName": "google.cloud.webrisk.v1.WebRiskService" - } - } - } - }, - { - "regionTag": "webrisk_v1_generated_WebRiskService_SearchHashes_async", - "title": "WebRiskService searchHashes Sample", - "origin": "API_DEFINITION", - "description": " Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.", - "canonical": true, - "file": "web_risk_service.search_hashes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchHashes", - "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchHashes", - "async": true, - "parameters": [ - { - "name": "hash_prefix", - "type": "TYPE_BYTES" - }, - { - "name": "threat_types", - "type": "TYPE_ENUM[]" - } - ], - "resultType": ".google.cloud.webrisk.v1.SearchHashesResponse", - "client": { - "shortName": "WebRiskServiceClient", - "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" - }, - "method": { - "shortName": "SearchHashes", - "fullName": "google.cloud.webrisk.v1.WebRiskService.SearchHashes", - "service": { - "shortName": "WebRiskService", - "fullName": "google.cloud.webrisk.v1.WebRiskService" - } - } - } - }, - { - "regionTag": "webrisk_v1_generated_WebRiskService_CreateSubmission_async", - "title": "WebRiskService createSubmission Sample", - "origin": "API_DEFINITION", - "description": " Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only projects with CREATE_SUBMISSION_USERS visibility can use this method.", - "canonical": true, - "file": "web_risk_service.create_submission.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSubmission", - "fullName": "google.cloud.webrisk.v1.WebRiskService.CreateSubmission", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "submission", - "type": ".google.cloud.webrisk.v1.Submission" - } - ], - "resultType": ".google.cloud.webrisk.v1.Submission", - "client": { - "shortName": "WebRiskServiceClient", - "fullName": "google.cloud.webrisk.v1.WebRiskServiceClient" - }, - "method": { - "shortName": "CreateSubmission", - "fullName": "google.cloud.webrisk.v1.WebRiskService.CreateSubmission", - "service": { - "shortName": "WebRiskService", - "fullName": "google.cloud.webrisk.v1.WebRiskService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js deleted file mode 100644 index 597c7b1..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.compute_threat_list_diff.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 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'; - -function main(threatType, constraints) { - // [START webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The threat list to update. Only a single ThreatType should be specified. - */ - // const threatType = {} - /** - * The current version token of the client for the requested list (the - * client version that was received from the last successful diff). - * If the client does not have a version token (this is the first time calling - * ComputeThreatListDiff), this may be left empty and a full database - * snapshot will be returned. - */ - // const versionToken = 'Buffer.from('string')' - /** - * Required. The constraints associated with this request. - */ - // const constraints = {} - - // Imports the Webrisk library - const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; - - // Instantiates a client - const webriskClient = new WebRiskServiceClient(); - - async function callComputeThreatListDiff() { - // Construct request - const request = { - threatType, - constraints, - }; - - // Run request - const response = await webriskClient.computeThreatListDiff(request); - console.log(response); - } - - callComputeThreatListDiff(); - // [END webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_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/web_risk_service.create_submission.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js deleted file mode 100644 index 5f81d5c..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.create_submission.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 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'; - -function main(parent, submission) { - // [START webrisk_v1_generated_WebRiskService_CreateSubmission_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project that is making the submission. This string is in - * the format "projects/{project_number}". - */ - // const parent = 'abc123' - /** - * Required. The submission that contains the content of the phishing report. - */ - // const submission = {} - - // Imports the Webrisk library - const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; - - // Instantiates a client - const webriskClient = new WebRiskServiceClient(); - - async function callCreateSubmission() { - // Construct request - const request = { - parent, - submission, - }; - - // Run request - const response = await webriskClient.createSubmission(request); - console.log(response); - } - - callCreateSubmission(); - // [END webrisk_v1_generated_WebRiskService_CreateSubmission_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/web_risk_service.search_hashes.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js deleted file mode 100644 index a43eb9d..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_hashes.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 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'; - -function main(threatTypes) { - // [START webrisk_v1_generated_WebRiskService_SearchHashes_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - * hash. For JSON requests, this field is base64-encoded. - */ - // const hashPrefix = 'Buffer.from('string')' - /** - * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - */ - // const threatTypes = 1234 - - // Imports the Webrisk library - const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; - - // Instantiates a client - const webriskClient = new WebRiskServiceClient(); - - async function callSearchHashes() { - // Construct request - const request = { - threatTypes, - }; - - // Run request - const response = await webriskClient.searchHashes(request); - console.log(response); - } - - callSearchHashes(); - // [END webrisk_v1_generated_WebRiskService_SearchHashes_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/web_risk_service.search_uris.js b/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.js deleted file mode 100644 index 1ca2ddf..0000000 --- a/owl-bot-staging/v1/samples/generated/v1/web_risk_service.search_uris.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 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'; - -function main(uri, threatTypes) { - // [START webrisk_v1_generated_WebRiskService_SearchUris_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The URI to be checked for matches. - */ - // const uri = 'abc123' - /** - * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - */ - // const threatTypes = 1234 - - // Imports the Webrisk library - const {WebRiskServiceClient} = require('@google-cloud/web-risk').v1; - - // Instantiates a client - const webriskClient = new WebRiskServiceClient(); - - async function callSearchUris() { - // Construct request - const request = { - uri, - threatTypes, - }; - - // Run request - const response = await webriskClient.searchUris(request); - console.log(response); - } - - callSearchUris(); - // [END webrisk_v1_generated_WebRiskService_SearchUris_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 cd03b1e..0000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 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 WebRiskServiceClient = v1.WebRiskServiceClient; -type WebRiskServiceClient = v1.WebRiskServiceClient; -export {v1, WebRiskServiceClient}; -export default {v1, WebRiskServiceClient}; -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 7934355..0000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.webrisk.v1", - "libraryPackage": "@google-cloud/web-risk", - "services": { - "WebRiskService": { - "clients": { - "grpc": { - "libraryClient": "WebRiskServiceClient", - "rpcs": { - "ComputeThreatListDiff": { - "methods": [ - "computeThreatListDiff" - ] - }, - "SearchUris": { - "methods": [ - "searchUris" - ] - }, - "SearchHashes": { - "methods": [ - "searchHashes" - ] - }, - "CreateSubmission": { - "methods": [ - "createSubmission" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "WebRiskServiceClient", - "rpcs": { - "ComputeThreatListDiff": { - "methods": [ - "computeThreatListDiff" - ] - }, - "SearchUris": { - "methods": [ - "searchUris" - ] - }, - "SearchHashes": { - "methods": [ - "searchHashes" - ] - }, - "CreateSubmission": { - "methods": [ - "createSubmission" - ] - } - } - } - } - } - } -} 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 d74132c..0000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 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 {WebRiskServiceClient} from './web_risk_service_client'; diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_client.ts b/owl-bot-staging/v1/src/v1/web_risk_service_client.ts deleted file mode 100644 index 2cbfd12..0000000 --- a/owl-bot-staging/v1/src/v1/web_risk_service_client.ts +++ /dev/null @@ -1,632 +0,0 @@ -// Copyright 2022 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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/web_risk_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './web_risk_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Web Risk API defines an interface to detect malicious URLs on your - * website and in client applications. - * @class - * @memberof v1 - */ -export class WebRiskServiceClient { - 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}; - webRiskServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of WebRiskServiceClient. - * - * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof WebRiskServiceClient; - 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 = { - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.webrisk.v1.WebRiskService', 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.webRiskServiceStub) { - return this.webRiskServiceStub; - } - - // Put together the "service stub" for - // google.cloud.webrisk.v1.WebRiskService. - this.webRiskServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.webrisk.v1.WebRiskService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.webrisk.v1.WebRiskService, - 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 webRiskServiceStubMethods = - ['computeThreatListDiff', 'searchUris', 'searchHashes', 'createSubmission']; - for (const methodName of webRiskServiceStubMethods) { - const callPromise = this.webRiskServiceStub.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 = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.webRiskServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'webrisk.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 'webrisk.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 -- - // ------------------- -/** - * Gets the most recent threat list diffs. These diffs should be applied to - * a local database of hashes to keep it up-to-date. If the local database is - * empty or excessively out-of-date, a complete snapshot of the database will - * be returned. This Method only updates a single ThreatList at a time. To - * update multiple ThreatList databases, this method needs to be called once - * for each list. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.webrisk.v1.ThreatType} request.threatType - * Required. The threat list to update. Only a single ThreatType should be specified. - * @param {Buffer} request.versionToken - * The current version token of the client for the requested list (the - * client version that was received from the last successful diff). - * If the client does not have a version token (this is the first time calling - * ComputeThreatListDiff), this may be left empty and a full database - * snapshot will be returned. - * @param {google.cloud.webrisk.v1.ComputeThreatListDiffRequest.Constraints} request.constraints - * Required. The constraints associated with this request. - * @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 [ComputeThreatListDiffResponse]{@link google.cloud.webrisk.v1.ComputeThreatListDiffResponse}. - * 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/web_risk_service.compute_threat_list_diff.js - * region_tag:webrisk_v1_generated_WebRiskService_ComputeThreatListDiff_async - */ - computeThreatListDiff( - request?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|undefined, {}|undefined - ]>; - computeThreatListDiff( - request: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): void; - computeThreatListDiff( - request: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, - callback: Callback< - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): void; - computeThreatListDiff( - request?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1.IComputeThreatListDiffRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.computeThreatListDiff(request, options, callback); - } -/** - * This method is used to check whether a URI is on a given threatList. - * Multiple threatLists may be searched in a single query. - * The response will list all requested threatLists the URI was found to - * match. If the URI is not found on any of the requested ThreatList an - * empty response will be returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.uri - * Required. The URI to be checked for matches. - * @param {number[]} request.threatTypes - * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - * @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 [SearchUrisResponse]{@link google.cloud.webrisk.v1.SearchUrisResponse}. - * 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/web_risk_service.search_uris.js - * region_tag:webrisk_v1_generated_WebRiskService_SearchUris_async - */ - searchUris( - request?: protos.google.cloud.webrisk.v1.ISearchUrisRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|undefined, {}|undefined - ]>; - searchUris( - request: protos.google.cloud.webrisk.v1.ISearchUrisRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): void; - searchUris( - request: protos.google.cloud.webrisk.v1.ISearchUrisRequest, - callback: Callback< - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): void; - searchUris( - request?: protos.google.cloud.webrisk.v1.ISearchUrisRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1.ISearchUrisRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.searchUris(request, options, callback); - } -/** - * Gets the full hashes that match the requested hash prefix. - * This is used after a hash prefix is looked up in a threatList - * and there is a match. The client side threatList only holds partial hashes - * so the client must query this method to determine if there is a full - * hash match of a threat. - * - * @param {Object} request - * The request object that will be sent. - * @param {Buffer} request.hashPrefix - * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - * hash. For JSON requests, this field is base64-encoded. - * @param {number[]} request.threatTypes - * Required. The ThreatLists to search in. Multiple ThreatLists may be specified. - * @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 [SearchHashesResponse]{@link google.cloud.webrisk.v1.SearchHashesResponse}. - * 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/web_risk_service.search_hashes.js - * region_tag:webrisk_v1_generated_WebRiskService_SearchHashes_async - */ - searchHashes( - request?: protos.google.cloud.webrisk.v1.ISearchHashesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|undefined, {}|undefined - ]>; - searchHashes( - request: protos.google.cloud.webrisk.v1.ISearchHashesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): void; - searchHashes( - request: protos.google.cloud.webrisk.v1.ISearchHashesRequest, - callback: Callback< - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): void; - searchHashes( - request?: protos.google.cloud.webrisk.v1.ISearchHashesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1.ISearchHashesRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.searchHashes(request, options, callback); - } -/** - * Creates a Submission of a URI suspected of containing phishing content to - * be reviewed. If the result verifies the existence of malicious phishing - * content, the site will be added to the [Google's Social Engineering - * lists](https://support.google.com/webmasters/answer/6350487/) in order to - * protect users that could get exposed to this threat in the future. Only - * projects with CREATE_SUBMISSION_USERS visibility can use this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that is making the submission. This string is in - * the format "projects/{project_number}". - * @param {google.cloud.webrisk.v1.Submission} request.submission - * Required. The submission that contains the content of the phishing report. - * @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 [Submission]{@link google.cloud.webrisk.v1.Submission}. - * 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/web_risk_service.create_submission.js - * region_tag:webrisk_v1_generated_WebRiskService_CreateSubmission_async - */ - createSubmission( - request?: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|undefined, {}|undefined - ]>; - createSubmission( - request: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, - {}|null|undefined>): void; - createSubmission( - request: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, - callback: Callback< - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, - {}|null|undefined>): void; - createSubmission( - request?: protos.google.cloud.webrisk.v1.ICreateSubmissionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1.ISubmission, - protos.google.cloud.webrisk.v1.ICreateSubmissionRequest|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.createSubmission(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * 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 { - if (this.webRiskServiceStub && !this._terminated) { - return this.webRiskServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json b/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json deleted file mode 100644 index b03b2aa..0000000 --- a/owl-bot-staging/v1/src/v1/web_risk_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.webrisk.v1.WebRiskService": { - "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": { - "ComputeThreatListDiff": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SearchUris": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SearchHashes": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateSubmission": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json b/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json deleted file mode 100644 index beac976..0000000 --- a/owl-bot-staging/v1/src/v1/web_risk_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/webrisk/v1/webrisk.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 2bb0ded..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 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 webrisk = require('@google-cloud/web-risk'); - -function main() { - const webRiskServiceClient = new webrisk.WebRiskServiceClient(); -} - -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 d7c75f5..0000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 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 {WebRiskServiceClient} from '@google-cloud/web-risk'; - -// check that the client class type name can be used -function doStuffWithWebRiskServiceClient(client: WebRiskServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const webRiskServiceClient = new WebRiskServiceClient(); - doStuffWithWebRiskServiceClient(webRiskServiceClient); -} - -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 8ec4522..0000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 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_web_risk_service_v1.ts b/owl-bot-staging/v1/test/gapic_web_risk_service_v1.ts deleted file mode 100644 index 01a22b3..0000000 --- a/owl-bot-staging/v1/test/gapic_web_risk_service_v1.ts +++ /dev/null @@ -1,481 +0,0 @@ -// Copyright 2022 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 webriskserviceModule from '../src'; - -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); -} - -describe('v1.WebRiskServiceClient', () => { - it('has servicePath', () => { - const servicePath = webriskserviceModule.v1.WebRiskServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = webriskserviceModule.v1.WebRiskServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = webriskserviceModule.v1.WebRiskServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.webRiskServiceStub, undefined); - await client.initialize(); - assert(client.webRiskServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.webRiskServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.webRiskServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - 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 webriskserviceModule.v1.WebRiskServiceClient({ - 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('computeThreatListDiff', () => { - it('invokes computeThreatListDiff without error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse()); - client.innerApiCalls.computeThreatListDiff = stubSimpleCall(expectedResponse); - const [response] = await client.computeThreatListDiff(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes computeThreatListDiff without error using callback', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse()); - client.innerApiCalls.computeThreatListDiff = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.computeThreatListDiff( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1.IComputeThreatListDiffResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes computeThreatListDiff with error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.computeThreatListDiff = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.computeThreatListDiff(request), expectedError); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes computeThreatListDiff with closed client', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.computeThreatListDiff(request), expectedError); - }); - }); - - describe('searchUris', () => { - it('invokes searchUris without error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisResponse()); - client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); - const [response] = await client.searchUris(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchUris without error using callback', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisResponse()); - client.innerApiCalls.searchUris = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchUris( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISearchUrisResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchUris with error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchUris = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchUris(request), expectedError); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchUris with closed client', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchUrisRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.searchUris(request), expectedError); - }); - }); - - describe('searchHashes', () => { - it('invokes searchHashes without error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesResponse()); - client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); - const [response] = await client.searchHashes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchHashes without error using callback', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesResponse()); - client.innerApiCalls.searchHashes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchHashes( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISearchHashesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchHashes with error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchHashes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchHashes(request), expectedError); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchHashes with closed client', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.SearchHashesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.searchHashes(request), expectedError); - }); - }); - - describe('createSubmission', () => { - it('invokes createSubmission without error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.Submission()); - client.innerApiCalls.createSubmission = stubSimpleCall(expectedResponse); - const [response] = await client.createSubmission(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createSubmission as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createSubmission without error using callback', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1.Submission()); - client.innerApiCalls.createSubmission = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSubmission( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1.ISubmission|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createSubmission as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createSubmission with error', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createSubmission = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createSubmission(request), expectedError); - assert((client.innerApiCalls.createSubmission as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createSubmission with closed client', async () => { - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1.CreateSubmissionRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createSubmission(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new webriskserviceModule.v1.WebRiskServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index c459176..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: 'WebRiskService', - filename: './web-risk-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 9d0daa4..0000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/web-risk', - 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 481c522..0000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 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 494e147..0000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 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 55d440e..0000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Webrisk: 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 befd23c..0000000 --- a/owl-bot-staging/v1beta1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index 9ae9d86..0000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/web-risk", - "version": "0.1.0", - "description": "Webrisk client for Node.js", - "repository": "googleapis/nodejs-webrisk", - "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 webrisk", - "webrisk", - "web risk 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": "^3.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto b/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto deleted file mode 100644 index 0226425..0000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/webrisk/v1beta1/webrisk.proto +++ /dev/null @@ -1,303 +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.webrisk.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.WebRisk.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/webrisk/v1beta1;webrisk"; -option java_multiple_files = true; -option java_outer_classname = "WebRiskProto"; -option java_package = "com.google.webrisk.v1beta1"; -option objc_class_prefix = "GCWR"; -option php_namespace = "Google\\Cloud\\WebRisk\\V1beta1"; -option ruby_package = "Google::Cloud::WebRisk::V1beta1"; - -// Web Risk v1beta1 API defines an interface to detect malicious URLs on your -// website and in client applications. -service WebRiskServiceV1Beta1 { - option (google.api.default_host) = "webrisk.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Gets the most recent threat list diffs. - rpc ComputeThreatListDiff(ComputeThreatListDiffRequest) returns (ComputeThreatListDiffResponse) { - option (google.api.http) = { - get: "/v1beta1/threatLists:computeDiff" - }; - option (google.api.method_signature) = "threat_type,version_token,constraints"; - } - - // This method is used to check whether a URI is on a given threatList. - rpc SearchUris(SearchUrisRequest) returns (SearchUrisResponse) { - option (google.api.http) = { - get: "/v1beta1/uris:search" - }; - option (google.api.method_signature) = "uri,threat_types"; - } - - // Gets the full hashes that match the requested hash prefix. - // This is used after a hash prefix is looked up in a threatList - // and there is a match. The client side threatList only holds partial hashes - // so the client must query this method to determine if there is a full - // hash match of a threat. - rpc SearchHashes(SearchHashesRequest) returns (SearchHashesResponse) { - option (google.api.http) = { - get: "/v1beta1/hashes:search" - }; - option (google.api.method_signature) = "hash_prefix,threat_types"; - } -} - -// Describes an API diff request. -message ComputeThreatListDiffRequest { - // The constraints for this diff. - message Constraints { - // The maximum size in number of entries. The diff will not contain more - // entries than this value. This should be a power of 2 between 2**10 and - // 2**20. If zero, no diff size limit is set. - int32 max_diff_entries = 1; - - // Sets the maximum number of entries that the client is willing to have - // in the local database. This should be a power of 2 between 2**10 and - // 2**20. If zero, no database size limit is set. - int32 max_database_entries = 2; - - // The compression types supported by the client. - repeated CompressionType supported_compressions = 3; - } - - // The ThreatList to update. - ThreatType threat_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // The current version token of the client for the requested list (the - // client version that was received from the last successful diff). - bytes version_token = 2; - - // Required. The constraints associated with this request. - Constraints constraints = 3 [(google.api.field_behavior) = REQUIRED]; -} - -message ComputeThreatListDiffResponse { - // The expected state of a client's local database. - message Checksum { - // The SHA256 hash of the client state; that is, of the sorted list of all - // hashes present in the database. - bytes sha256 = 1; - } - - // The type of response sent to the client. - enum ResponseType { - // Unknown. - RESPONSE_TYPE_UNSPECIFIED = 0; - - // Partial updates are applied to the client's existing local database. - DIFF = 1; - - // Full updates resets the client's entire local database. This means - // that either the client had no state, was seriously out-of-date, - // or the client is believed to be corrupt. - RESET = 2; - } - - // The type of response. This may indicate that an action must be taken by the - // client when the response is received. - ResponseType response_type = 4; - - // A set of entries to add to a local threat type's list. - ThreatEntryAdditions additions = 5; - - // A set of entries to remove from a local threat type's list. - // This field may be empty. - ThreatEntryRemovals removals = 6; - - // The new opaque client version token. - bytes new_version_token = 7; - - // The expected SHA256 hash of the client state; that is, of the sorted list - // of all hashes present in the database after applying the provided diff. - // If the client state doesn't match the expected state, the client must - // disregard this diff and retry later. - Checksum checksum = 8; - - // The soonest the client should wait before issuing any diff - // request. Querying sooner is unlikely to produce a meaningful diff. - // Waiting longer is acceptable considering the use case. - // If this field is not set clients may update as soon as they want. - google.protobuf.Timestamp recommended_next_diff = 2; -} - -// Request to check URI entries against threatLists. -message SearchUrisRequest { - // Required. The URI to be checked for matches. - string uri = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ThreatLists to search in. - repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; -} - -message SearchUrisResponse { - // Contains threat information on a matching uri. - message ThreatUri { - // The ThreatList this threat belongs to. - repeated ThreatType threat_types = 1; - - // The cache lifetime for the returned match. Clients must not cache this - // response past this timestamp to avoid false positives. - google.protobuf.Timestamp expire_time = 2; - } - - // The threat list matches. This may be empty if the URI is on no list. - ThreatUri threat = 1; -} - -// Request to return full hashes matched by the provided hash prefixes. -message SearchHashesRequest { - // A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - // hash. For JSON requests, this field is base64-encoded. - bytes hash_prefix = 1; - - // Required. The ThreatLists to search in. - repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED]; -} - -message SearchHashesResponse { - // Contains threat information on a matching hash. - message ThreatHash { - // The ThreatList this threat belongs to. - // This must contain at least one entry. - repeated ThreatType threat_types = 1; - - // A 32 byte SHA256 hash. This field is in binary format. For JSON - // requests, hashes are base64-encoded. - bytes hash = 2; - - // The cache lifetime for the returned match. Clients must not cache this - // response past this timestamp to avoid false positives. - google.protobuf.Timestamp expire_time = 3; - } - - // The full hashes that matched the requested prefixes. - // The hash will be populated in the key. - repeated ThreatHash threats = 1; - - // For requested entities that did not match the threat list, how long to - // cache the response until. - google.protobuf.Timestamp negative_expire_time = 2; -} - -// Contains the set of entries to add to a local database. -// May contain a combination of compressed and raw data in a single response. -message ThreatEntryAdditions { - // The raw SHA256-formatted entries. - // Repeated to allow returning sets of hashes with different prefix sizes. - repeated RawHashes raw_hashes = 1; - - // The encoded 4-byte prefixes of SHA256-formatted entries, using a - // Golomb-Rice encoding. The hashes are converted to uint32, sorted in - // ascending order, then delta encoded and stored as encoded_data. - RiceDeltaEncoding rice_hashes = 2; -} - -// Contains the set of entries to remove from a local database. -message ThreatEntryRemovals { - // The raw removal indices for a local list. - RawIndices raw_indices = 1; - - // The encoded local, lexicographically-sorted list indices, using a - // Golomb-Rice encoding. Used for sending compressed removal indices. The - // removal indices (uint32) are sorted in ascending order, then delta encoded - // and stored as encoded_data. - RiceDeltaEncoding rice_indices = 2; -} - -// The type of threat. This maps dirrectly to the threat list a threat may -// belong to. -enum ThreatType { - // Unknown. - THREAT_TYPE_UNSPECIFIED = 0; - - // Malware targeting any platform. - MALWARE = 1; - - // Social engineering targeting any platform. - SOCIAL_ENGINEERING = 2; - - // Unwanted software targeting any platform. - UNWANTED_SOFTWARE = 3; -} - -// The ways in which threat entry sets can be compressed. -enum CompressionType { - // Unknown. - COMPRESSION_TYPE_UNSPECIFIED = 0; - - // Raw, uncompressed data. - RAW = 1; - - // Rice-Golomb encoded data. - RICE = 2; -} - -// A set of raw indices to remove from a local list. -message RawIndices { - // The indices to remove from a lexicographically-sorted local list. - repeated int32 indices = 1; -} - -// The uncompressed threat entries in hash format. -// Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 -// bytes, but some hashes are lengthened if they collide with the hash of a -// popular URI. -// -// Used for sending ThreatEntryAdditons to clients that do not support -// compression, or when sending non-4-byte hashes to clients that do support -// compression. -message RawHashes { - // The number of bytes for each prefix encoded below. This field can be - // anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). - int32 prefix_size = 1; - - // The hashes, in binary format, concatenated into one long string. Hashes are - // sorted in lexicographic order. For JSON API users, hashes are - // base64-encoded. - bytes raw_hashes = 2; -} - -// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or -// compressed removal indices. -message RiceDeltaEncoding { - // The offset of the first entry in the encoded data, or, if only a single - // integer was encoded, that single integer's value. If the field is empty or - // missing, assume zero. - int64 first_value = 1; - - // The Golomb-Rice parameter, which is a number between 2 and 28. This field - // is missing (that is, zero) if `num_entries` is zero. - int32 rice_parameter = 2; - - // The number of entries that are delta encoded in the encoded data. If only a - // single integer was encoded, this will be zero and the single value will be - // stored in `first_value`. - int32 entry_count = 3; - - // The encoded deltas that are encoded using the Golomb-Rice coder. - bytes encoded_data = 4; -} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json deleted file mode 100644 index bfb79e8..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.webrisk.v1beta1.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-webrisk", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.webrisk.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async", - "title": "WebRiskServiceV1Beta1 computeThreatListDiff Sample", - "origin": "API_DEFINITION", - "description": " Gets the most recent threat list diffs.", - "canonical": true, - "file": "web_risk_service_v1_beta1.compute_threat_list_diff.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ComputeThreatListDiff", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.ComputeThreatListDiff", - "async": true, - "parameters": [ - { - "name": "threat_type", - "type": ".google.cloud.webrisk.v1beta1.ThreatType" - }, - { - "name": "version_token", - "type": "TYPE_BYTES" - }, - { - "name": "constraints", - "type": ".google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest.Constraints" - } - ], - "resultType": ".google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse", - "client": { - "shortName": "WebRiskServiceV1Beta1Client", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" - }, - "method": { - "shortName": "ComputeThreatListDiff", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.ComputeThreatListDiff", - "service": { - "shortName": "WebRiskServiceV1Beta1", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" - } - } - } - }, - { - "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async", - "title": "WebRiskServiceV1Beta1 searchUris Sample", - "origin": "API_DEFINITION", - "description": " This method is used to check whether a URI is on a given threatList.", - "canonical": true, - "file": "web_risk_service_v1_beta1.search_uris.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchUris", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchUris", - "async": true, - "parameters": [ - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "threat_types", - "type": "TYPE_ENUM[]" - } - ], - "resultType": ".google.cloud.webrisk.v1beta1.SearchUrisResponse", - "client": { - "shortName": "WebRiskServiceV1Beta1Client", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" - }, - "method": { - "shortName": "SearchUris", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchUris", - "service": { - "shortName": "WebRiskServiceV1Beta1", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" - } - } - } - }, - { - "regionTag": "webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async", - "title": "WebRiskServiceV1Beta1 searchHashes Sample", - "origin": "API_DEFINITION", - "description": " Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.", - "canonical": true, - "file": "web_risk_service_v1_beta1.search_hashes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchHashes", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchHashes", - "async": true, - "parameters": [ - { - "name": "hash_prefix", - "type": "TYPE_BYTES" - }, - { - "name": "threat_types", - "type": "TYPE_ENUM[]" - } - ], - "resultType": ".google.cloud.webrisk.v1beta1.SearchHashesResponse", - "client": { - "shortName": "WebRiskServiceV1Beta1Client", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1Client" - }, - "method": { - "shortName": "SearchHashes", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1.SearchHashes", - "service": { - "shortName": "WebRiskServiceV1Beta1", - "fullName": "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js deleted file mode 100644 index 3c94725..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.compute_threat_list_diff.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 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'; - -function main(threatType, constraints) { - // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The ThreatList to update. - */ - // const threatType = {} - /** - * The current version token of the client for the requested list (the - * client version that was received from the last successful diff). - */ - // const versionToken = 'Buffer.from('string')' - /** - * Required. The constraints associated with this request. - */ - // const constraints = {} - - // Imports the Webrisk library - const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; - - // Instantiates a client - const webriskClient = new WebRiskServiceV1Beta1Client(); - - async function callComputeThreatListDiff() { - // Construct request - const request = { - threatType, - constraints, - }; - - // Run request - const response = await webriskClient.computeThreatListDiff(request); - console.log(response); - } - - callComputeThreatListDiff(); - // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_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/web_risk_service_v1_beta1.search_hashes.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js deleted file mode 100644 index 833229a..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_hashes.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 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'; - -function main(threatTypes) { - // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - * hash. For JSON requests, this field is base64-encoded. - */ - // const hashPrefix = 'Buffer.from('string')' - /** - * Required. The ThreatLists to search in. - */ - // const threatTypes = 1234 - - // Imports the Webrisk library - const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; - - // Instantiates a client - const webriskClient = new WebRiskServiceV1Beta1Client(); - - async function callSearchHashes() { - // Construct request - const request = { - threatTypes, - }; - - // Run request - const response = await webriskClient.searchHashes(request); - console.log(response); - } - - callSearchHashes(); - // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_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/web_risk_service_v1_beta1.search_uris.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.js deleted file mode 100644 index a0b6bac..0000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/web_risk_service_v1_beta1.search_uris.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 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'; - -function main(uri, threatTypes) { - // [START webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The URI to be checked for matches. - */ - // const uri = 'abc123' - /** - * Required. The ThreatLists to search in. - */ - // const threatTypes = 1234 - - // Imports the Webrisk library - const {WebRiskServiceV1Beta1Client} = require('@google-cloud/web-risk').v1beta1; - - // Instantiates a client - const webriskClient = new WebRiskServiceV1Beta1Client(); - - async function callSearchUris() { - // Construct request - const request = { - uri, - threatTypes, - }; - - // Run request - const response = await webriskClient.searchUris(request); - console.log(response); - } - - callSearchUris(); - // [END webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_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 5ee3cd4..0000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 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 WebRiskServiceV1Beta1Client = v1beta1.WebRiskServiceV1Beta1Client; -type WebRiskServiceV1Beta1Client = v1beta1.WebRiskServiceV1Beta1Client; -export {v1beta1, WebRiskServiceV1Beta1Client}; -export default {v1beta1, WebRiskServiceV1Beta1Client}; -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 9ed88dd..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.webrisk.v1beta1", - "libraryPackage": "@google-cloud/web-risk", - "services": { - "WebRiskServiceV1Beta1": { - "clients": { - "grpc": { - "libraryClient": "WebRiskServiceV1Beta1Client", - "rpcs": { - "ComputeThreatListDiff": { - "methods": [ - "computeThreatListDiff" - ] - }, - "SearchUris": { - "methods": [ - "searchUris" - ] - }, - "SearchHashes": { - "methods": [ - "searchHashes" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "WebRiskServiceV1Beta1Client", - "rpcs": { - "ComputeThreatListDiff": { - "methods": [ - "computeThreatListDiff" - ] - }, - "SearchUris": { - "methods": [ - "searchUris" - ] - }, - "SearchHashes": { - "methods": [ - "searchHashes" - ] - } - } - } - } - } - } -} 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 6edca0f..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 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 {WebRiskServiceV1Beta1Client} from './web_risk_service_v1_beta1_client'; diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts deleted file mode 100644 index b557036..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client.ts +++ /dev/null @@ -1,505 +0,0 @@ -// Copyright 2022 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} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/web_risk_service_v1_beta1_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './web_risk_service_v1_beta1_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Web Risk v1beta1 API defines an interface to detect malicious URLs on your - * website and in client applications. - * @class - * @memberof v1beta1 - */ -export class WebRiskServiceV1Beta1Client { - 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}; - webRiskServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of WebRiskServiceV1Beta1Client. - * - * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof WebRiskServiceV1Beta1Client; - 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1', 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.webRiskServiceV1Beta1Stub) { - return this.webRiskServiceV1Beta1Stub; - } - - // Put together the "service stub" for - // google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1. - this.webRiskServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1, - 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 webRiskServiceV1Beta1StubMethods = - ['computeThreatListDiff', 'searchUris', 'searchHashes']; - for (const methodName of webRiskServiceV1Beta1StubMethods) { - const callPromise = this.webRiskServiceV1Beta1Stub.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 = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.webRiskServiceV1Beta1Stub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'webrisk.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 'webrisk.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 -- - // ------------------- -/** - * Gets the most recent threat list diffs. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.webrisk.v1beta1.ThreatType} request.threatType - * The ThreatList to update. - * @param {Buffer} request.versionToken - * The current version token of the client for the requested list (the - * client version that was received from the last successful diff). - * @param {google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest.Constraints} request.constraints - * Required. The constraints associated with this request. - * @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 [ComputeThreatListDiffResponse]{@link google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse}. - * 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/web_risk_service_v1_beta1.compute_threat_list_diff.js - * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_ComputeThreatListDiff_async - */ - computeThreatListDiff( - request?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|undefined, {}|undefined - ]>; - computeThreatListDiff( - request: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): void; - computeThreatListDiff( - request: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): void; - computeThreatListDiff( - request?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse, - protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.computeThreatListDiff(request, options, callback); - } -/** - * This method is used to check whether a URI is on a given threatList. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.uri - * Required. The URI to be checked for matches. - * @param {number[]} request.threatTypes - * Required. The ThreatLists to search in. - * @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 [SearchUrisResponse]{@link google.cloud.webrisk.v1beta1.SearchUrisResponse}. - * 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/web_risk_service_v1_beta1.search_uris.js - * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchUris_async - */ - searchUris( - request?: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|undefined, {}|undefined - ]>; - searchUris( - request: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): void; - searchUris( - request: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): void; - searchUris( - request?: protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse, - protos.google.cloud.webrisk.v1beta1.ISearchUrisRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.searchUris(request, options, callback); - } -/** - * Gets the full hashes that match the requested hash prefix. - * This is used after a hash prefix is looked up in a threatList - * and there is a match. The client side threatList only holds partial hashes - * so the client must query this method to determine if there is a full - * hash match of a threat. - * - * @param {Object} request - * The request object that will be sent. - * @param {Buffer} request.hashPrefix - * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 - * hash. For JSON requests, this field is base64-encoded. - * @param {number[]} request.threatTypes - * Required. The ThreatLists to search in. - * @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 [SearchHashesResponse]{@link google.cloud.webrisk.v1beta1.SearchHashesResponse}. - * 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/web_risk_service_v1_beta1.search_hashes.js - * region_tag:webrisk_v1beta1_generated_WebRiskServiceV1Beta1_SearchHashes_async - */ - searchHashes( - request?: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|undefined, {}|undefined - ]>; - searchHashes( - request: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): void; - searchHashes( - request: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, - callback: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): void; - searchHashes( - request?: protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse, - protos.google.cloud.webrisk.v1beta1.ISearchHashesRequest|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 || {}; - this.initialize(); - return this.innerApiCalls.searchHashes(request, options, callback); - } - - - /** - * 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 { - if (this.webRiskServiceV1Beta1Stub && !this._terminated) { - return this.webRiskServiceV1Beta1Stub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json deleted file mode 100644 index 669c223..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_client_config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "interfaces": { - "google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1": { - "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": { - "ComputeThreatListDiff": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SearchUris": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SearchHashes": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json deleted file mode 100644 index 9b9d465..0000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/web_risk_service_v1_beta1_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/webrisk/v1beta1/webrisk.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 2791d43..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 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 webrisk = require('@google-cloud/web-risk'); - -function main() { - const webRiskServiceV1Beta1Client = new webrisk.WebRiskServiceV1Beta1Client(); -} - -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 19bf121..0000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 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 {WebRiskServiceV1Beta1Client} from '@google-cloud/web-risk'; - -// check that the client class type name can be used -function doStuffWithWebRiskServiceV1Beta1Client(client: WebRiskServiceV1Beta1Client) { - client.close(); -} - -function main() { - // check that the client instance can be created - const webRiskServiceV1Beta1Client = new WebRiskServiceV1Beta1Client(); - doStuffWithWebRiskServiceV1Beta1Client(webRiskServiceV1Beta1Client); -} - -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 8ec4522..0000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 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_web_risk_service_v1_beta1_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_web_risk_service_v1_beta1_v1beta1.ts deleted file mode 100644 index ac8acd1..0000000 --- a/owl-bot-staging/v1beta1/test/gapic_web_risk_service_v1_beta1_v1beta1.ts +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2022 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 webriskservicev1beta1Module from '../src'; - -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); -} - -describe('v1beta1.WebRiskServiceV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.webRiskServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.webRiskServiceV1Beta1Stub); - }); - - it('has close method for the initialized client', done => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.webRiskServiceV1Beta1Stub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.webRiskServiceV1Beta1Stub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - 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 webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - 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('computeThreatListDiff', () => { - it('invokes computeThreatListDiff without error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse()); - client.innerApiCalls.computeThreatListDiff = stubSimpleCall(expectedResponse); - const [response] = await client.computeThreatListDiff(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes computeThreatListDiff without error using callback', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse()); - client.innerApiCalls.computeThreatListDiff = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.computeThreatListDiff( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.IComputeThreatListDiffResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes computeThreatListDiff with error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.computeThreatListDiff = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.computeThreatListDiff(request), expectedError); - assert((client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes computeThreatListDiff with closed client', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.computeThreatListDiff(request), expectedError); - }); - }); - - describe('searchUris', () => { - it('invokes searchUris without error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse()); - client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); - const [response] = await client.searchUris(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchUris without error using callback', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse()); - client.innerApiCalls.searchUris = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchUris( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.ISearchUrisResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchUris with error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchUris = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchUris(request), expectedError); - assert((client.innerApiCalls.searchUris as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchUris with closed client', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.searchUris(request), expectedError); - }); - }); - - describe('searchHashes', () => { - it('invokes searchHashes without error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse()); - client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); - const [response] = await client.searchHashes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchHashes without error using callback', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse()); - client.innerApiCalls.searchHashes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchHashes( - request, - (err?: Error|null, result?: protos.google.cloud.webrisk.v1beta1.ISearchHashesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchHashes with error', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchHashes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchHashes(request), expectedError); - assert((client.innerApiCalls.searchHashes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchHashes with closed client', async () => { - const client = new webriskservicev1beta1Module.v1beta1.WebRiskServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.searchHashes(request), expectedError); - }); - }); -}); 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 9179bba..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: 'WebRiskServiceV1Beta1', - filename: './web-risk-service-v1-beta1.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1/web_risk_service_client.ts b/src/v1/web_risk_service_client.ts index 29f30ee..663c367 100644 --- a/src/v1/web_risk_service_client.ts +++ b/src/v1/web_risk_service_client.ts @@ -62,7 +62,7 @@ export class WebRiskServiceClient { * * @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). + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] @@ -85,11 +85,10 @@ export class WebRiskServiceClient { * 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. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields. diff --git a/src/v1beta1/web_risk_service_v1_beta1_client.ts b/src/v1beta1/web_risk_service_v1_beta1_client.ts index 67e1c29..c62720e 100644 --- a/src/v1beta1/web_risk_service_v1_beta1_client.ts +++ b/src/v1beta1/web_risk_service_v1_beta1_client.ts @@ -61,7 +61,7 @@ export class WebRiskServiceV1Beta1Client { * * @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). + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] @@ -84,11 +84,10 @@ export class WebRiskServiceV1Beta1Client { * 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. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields.