diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 0000000..727d3b6 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Websecurityscanner: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 0000000..badee22 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/web-security-scanner", + "version": "0.1.0", + "description": "Websecurityscanner client for Node.js", + "repository": "googleapis/nodejs-websecurityscanner", + "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 websecurityscanner", + "websecurityscanner", + "web security scanner" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.14.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.1", + "@types/sinon": "^10.0.0", + "c8": "^7.7.2", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.6", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^10.0.0", + "ts-loader": "^9.2.2", + "typescript": "^4.2.4", + "webpack": "^5.37.1", + "webpack-cli": "^4.7.0" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/crawled_url.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/crawled_url.proto new file mode 100644 index 0000000..37724b8 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/crawled_url.proto @@ -0,0 +1,40 @@ +// 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.websecurityscanner.v1; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "CrawledUrlProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// A CrawledUrl resource represents a URL that was crawled during a ScanRun. Web +// Security Scanner Service crawls the web applications, following all links +// within the scope of sites, to find the URLs to test against. +message CrawledUrl { + // Output only. The http method of the request that was used to visit the URL, in + // uppercase. + string http_method = 1; + + // Output only. The URL that was crawled. + string url = 2; + + // Output only. The body of the request that was used to visit the URL. + string body = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding.proto new file mode 100644 index 0000000..32bd5d8 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding.proto @@ -0,0 +1,119 @@ +// 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.websecurityscanner.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1/finding_addon.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// A Finding resource represents a vulnerability instance identified during a +// ScanRun. +message Finding { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/Finding" + pattern: "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}" + }; + + // The severity level of a vulnerability. + enum Severity { + // No severity specified. The default value. + SEVERITY_UNSPECIFIED = 0; + + // Critical severity. + CRITICAL = 1; + + // High severity. + HIGH = 2; + + // Medium severity. + MEDIUM = 3; + + // Low severity. + LOW = 4; + } + + // Output only. The resource name of the Finding. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{scanRunId}/findings/{findingId}'. + // The finding IDs are generated by the system. + string name = 1; + + // Output only. The type of the Finding. + // Detailed and up-to-date information on findings can be found here: + // https://cloud.google.com/security-command-center/docs/how-to-remediate-web-security-scanner-findings + string finding_type = 2; + + // Output only. The severity level of the reported vulnerability. + Severity severity = 17 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The http method of the request that triggered the vulnerability, in + // uppercase. + string http_method = 3; + + // Output only. The URL produced by the server-side fuzzer and used in the request that + // triggered the vulnerability. + string fuzzed_url = 4; + + // Output only. The body of the request that triggered the vulnerability. + string body = 5; + + // Output only. The description of the vulnerability. + string description = 6; + + // Output only. The URL containing human-readable payload that user can leverage to + // reproduce the vulnerability. + string reproduction_url = 7; + + // Output only. If the vulnerability was originated from nested IFrame, the immediate + // parent IFrame is reported. + string frame_url = 8; + + // Output only. The URL where the browser lands when the vulnerability is detected. + string final_url = 9; + + // Output only. The tracking ID uniquely identifies a vulnerability instance across + // multiple ScanRuns. + string tracking_id = 10; + + // Output only. An addon containing information reported for a vulnerability with an HTML + // form, if any. + Form form = 16; + + // Output only. An addon containing information about outdated libraries. + OutdatedLibrary outdated_library = 11; + + // Output only. An addon containing detailed information regarding any resource causing the + // vulnerability such as JavaScript sources, image, audio files, etc. + ViolatingResource violating_resource = 12; + + // Output only. An addon containing information about vulnerable or missing HTTP headers. + VulnerableHeaders vulnerable_headers = 15; + + // Output only. An addon containing information about request parameters which were found + // to be vulnerable. + VulnerableParameters vulnerable_parameters = 13; + + // Output only. An addon containing information reported for an XSS, if any. + Xss xss = 14; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_addon.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_addon.proto new file mode 100644 index 0000000..4fb7ec1 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_addon.proto @@ -0,0 +1,147 @@ +// 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.websecurityscanner.v1; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingAddonProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// ! Information about a vulnerability with an HTML. +message Form { + // ! The URI where to send the form when it's submitted. + string action_uri = 1; + + // ! The names of form fields related to the vulnerability. + repeated string fields = 2; +} + +// Information reported for an outdated library. +message OutdatedLibrary { + // The name of the outdated library. + string library_name = 1; + + // The version number. + string version = 2; + + // URLs to learn more information about the vulnerabilities in the library. + repeated string learn_more_urls = 3; +} + +// Information regarding any resource causing the vulnerability such +// as JavaScript sources, image, audio files, etc. +message ViolatingResource { + // The MIME type of this resource. + string content_type = 1; + + // URL of this violating resource. + string resource_url = 2; +} + +// Information about vulnerable request parameters. +message VulnerableParameters { + // The vulnerable parameter names. + repeated string parameter_names = 1; +} + +// Information about vulnerable or missing HTTP Headers. +message VulnerableHeaders { + // Describes a HTTP Header. + message Header { + // Header name. + string name = 1; + + // Header value. + string value = 2; + } + + // List of vulnerable headers. + repeated Header headers = 1; + + // List of missing headers. + repeated Header missing_headers = 2; +} + +// Information reported for an XSS. +message Xss { + // Types of XSS attack vector. + enum AttackVector { + // Unknown attack vector. + ATTACK_VECTOR_UNSPECIFIED = 0; + + // The attack comes from fuzzing the browser's localStorage. + LOCAL_STORAGE = 1; + + // The attack comes from fuzzing the browser's sessionStorage. + SESSION_STORAGE = 2; + + // The attack comes from fuzzing the window's name property. + WINDOW_NAME = 3; + + // The attack comes from fuzzing the referrer property. + REFERRER = 4; + + // The attack comes from fuzzing an input element. + FORM_INPUT = 5; + + // The attack comes from fuzzing the browser's cookies. + COOKIE = 6; + + // The attack comes from hijacking the post messaging mechanism. + POST_MESSAGE = 7; + + // The attack comes from fuzzing parameters in the url. + GET_PARAMETERS = 8; + + // The attack comes from fuzzing the fragment in the url. + URL_FRAGMENT = 9; + + // The attack comes from fuzzing the HTML comments. + HTML_COMMENT = 10; + + // The attack comes from fuzzing the POST parameters. + POST_PARAMETERS = 11; + + // The attack comes from fuzzing the protocol. + PROTOCOL = 12; + + // The attack comes from the server side and is stored. + STORED_XSS = 13; + + // The attack is a Same-Origin Method Execution attack via a GET parameter. + SAME_ORIGIN = 14; + + // The attack payload is received from a third-party host via a URL that is + // user-controllable + USER_CONTROLLABLE_URL = 15; + } + + // Stack traces leading to the point where the XSS occurred. + repeated string stack_traces = 1; + + // An error message generated by a javascript breakage. + string error_message = 2; + + // The attack vector of the payload triggering this XSS. + AttackVector attack_vector = 3; + + // The reproduction url for the seeding POST request of a Stored XSS. + string stored_xss_seeding_url = 4; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_type_stats.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_type_stats.proto new file mode 100644 index 0000000..7eca01e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/finding_type_stats.proto @@ -0,0 +1,35 @@ +// 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.websecurityscanner.v1; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingTypeStatsProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// A FindingTypeStats resource represents stats regarding a specific FindingType +// of Findings under a given ScanRun. +message FindingTypeStats { + // Output only. The finding type associated with the stats. + string finding_type = 1; + + // Output only. The count of findings belonging to this finding type. + int32 finding_count = 2; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config.proto new file mode 100644 index 0000000..901d01e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config.proto @@ -0,0 +1,188 @@ +// 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.websecurityscanner.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanConfigProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// A ScanConfig resource contains the configurations to launch a scan. +message ScanConfig { + // Scan authentication configuration. + message Authentication { + // Describes authentication configuration that uses a Google account. + message GoogleAccount { + // Required. The user name of the Google account. + string username = 1; + + // Required. Input only. The password of the Google account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2; + } + + // Describes authentication configuration that uses a custom account. + message CustomAccount { + // Required. The user name of the custom account. + string username = 1; + + // Required. Input only. The password of the custom account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2; + + // Required. The login form URL of the website. + string login_url = 3; + } + + // Describes authentication configuration for Identity-Aware-Proxy (IAP). + message IapCredential { + // Describes authentication configuration when Web-Security-Scanner + // service account is added in Identity-Aware-Proxy (IAP) access policies. + message IapTestServiceAccountInfo { + // Required. Describes OAuth2 client id of resources protected by + // Identity-Aware-Proxy (IAP). + string target_audience_client_id = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Identity-Aware-Proxy (IAP) Authentication Configuration + oneof iap_credentials { + // Authentication configuration when Web-Security-Scanner service + // account is added in Identity-Aware-Proxy (IAP) access policies. + IapTestServiceAccountInfo iap_test_service_account_info = 1; + } + } + + // Required. + // Authentication configuration + oneof authentication { + // Authentication using a Google account. + GoogleAccount google_account = 1; + + // Authentication using a custom account. + CustomAccount custom_account = 2; + + // Authentication using Identity-Aware-Proxy (IAP). + IapCredential iap_credential = 4; + } + } + + // Scan schedule configuration. + message Schedule { + // A timestamp indicates when the next run will be scheduled. The value is + // refreshed by the server after each run. If unspecified, it will default + // to current server time, which means the scan will be scheduled to start + // immediately. + google.protobuf.Timestamp schedule_time = 1; + + // Required. The duration of time between executions in days. + int32 interval_duration_days = 2; + } + + // Type of user agents used for scanning. + enum UserAgent { + // The user agent is unknown. Service will default to CHROME_LINUX. + USER_AGENT_UNSPECIFIED = 0; + + // Chrome on Linux. This is the service default if unspecified. + CHROME_LINUX = 1; + + // Chrome on Android. + CHROME_ANDROID = 2; + + // Safari on IPhone. + SAFARI_IPHONE = 3; + } + + // Scan risk levels supported by Web Security Scanner. LOW impact + // scanning will minimize requests with the potential to modify data. To + // achieve the maximum scan coverage, NORMAL risk level is recommended. + enum RiskLevel { + // Use default, which is NORMAL. + RISK_LEVEL_UNSPECIFIED = 0; + + // Normal scanning (Recommended) + NORMAL = 1; + + // Lower impact scanning + LOW = 2; + } + + // Controls export of scan configurations and results to Security + // Command Center. + enum ExportToSecurityCommandCenter { + // Use default, which is ENABLED. + EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED = 0; + + // Export results of this scan to Security Command Center. + ENABLED = 1; + + // Do not export results of this scan to Security Command Center. + DISABLED = 2; + } + + // The resource name of the ScanConfig. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}'. The ScanConfig IDs are + // generated by the system. + string name = 1; + + // Required. The user provided display name of the ScanConfig. + string display_name = 2; + + // The maximum QPS during scanning. A valid value ranges from 5 to 20 + // inclusively. If the field is unspecified or its value is set 0, server will + // default to 15. Other values outside of [5, 20] range will be rejected with + // INVALID_ARGUMENT error. + int32 max_qps = 3; + + // Required. The starting URLs from which the scanner finds site pages. + repeated string starting_urls = 4; + + // The authentication configuration. If specified, service will use the + // authentication configuration during scanning. + Authentication authentication = 5; + + // The user agent used during scanning. + UserAgent user_agent = 6; + + // The excluded URL patterns as described in + // https://cloud.google.com/security-command-center/docs/how-to-use-web-security-scanner#excluding_urls + repeated string blacklist_patterns = 7; + + // The schedule of the ScanConfig. + Schedule schedule = 8; + + // Controls export of scan configurations and results to Security + // Command Center. + ExportToSecurityCommandCenter export_to_security_command_center = 10; + + // The risk level selected for the scan + RiskLevel risk_level = 12; + + // Whether the scan config is managed by Web Security Scanner, output + // only. + bool managed_scan = 13; + + // Whether the scan configuration has enabled static IP address scan feature. + // If enabled, the scanner will access applications from static IP addresses. + bool static_ip_scan = 14; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config_error.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config_error.proto new file mode 100644 index 0000000..5d54457 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_config_error.proto @@ -0,0 +1,189 @@ +// 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.websecurityscanner.v1; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanConfigErrorProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// Defines a custom error message used by CreateScanConfig and UpdateScanConfig +// APIs when scan configuration validation fails. It is also reported as part of +// a ScanRunErrorTrace message if scan validation fails due to a scan +// configuration error. +message ScanConfigError { + // Output only. + // Defines an error reason code. + // Next id: 44 + enum Code { + option allow_alias = true; + + // There is no error. + CODE_UNSPECIFIED = 0; + + // There is no error. + OK = 0; + + // Indicates an internal server error. + // Please DO NOT USE THIS ERROR CODE unless the root cause is truly unknown. + INTERNAL_ERROR = 1; + + // One of the seed URLs is an App Engine URL but we cannot validate the scan + // settings due to an App Engine API backend error. + APPENGINE_API_BACKEND_ERROR = 2; + + // One of the seed URLs is an App Engine URL but we cannot access the + // App Engine API to validate scan settings. + APPENGINE_API_NOT_ACCESSIBLE = 3; + + // One of the seed URLs is an App Engine URL but the Default Host of the + // App Engine is not set. + APPENGINE_DEFAULT_HOST_MISSING = 4; + + // Google corporate accounts can not be used for scanning. + CANNOT_USE_GOOGLE_COM_ACCOUNT = 6; + + // The account of the scan creator can not be used for scanning. + CANNOT_USE_OWNER_ACCOUNT = 7; + + // This scan targets Compute Engine, but we cannot validate scan settings + // due to a Compute Engine API backend error. + COMPUTE_API_BACKEND_ERROR = 8; + + // This scan targets Compute Engine, but we cannot access the Compute Engine + // API to validate the scan settings. + COMPUTE_API_NOT_ACCESSIBLE = 9; + + // The Custom Login URL does not belong to the current project. + CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 10; + + // The Custom Login URL is malformed (can not be parsed). + CUSTOM_LOGIN_URL_MALFORMED = 11; + + // The Custom Login URL is mapped to a non-routable IP address in DNS. + CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 12; + + // The Custom Login URL is mapped to an IP address which is not reserved for + // the current project. + CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS = 13; + + // The Custom Login URL has a non-routable IP address. + CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 14; + + // The Custom Login URL has an IP address which is not reserved for the + // current project. + CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS = 15; + + // Another scan with the same name (case-sensitive) already exists. + DUPLICATE_SCAN_NAME = 16; + + // A field is set to an invalid value. + INVALID_FIELD_VALUE = 18; + + // There was an error trying to authenticate to the scan target. + FAILED_TO_AUTHENTICATE_TO_TARGET = 19; + + // Finding type value is not specified in the list findings request. + FINDING_TYPE_UNSPECIFIED = 20; + + // Scan targets Compute Engine, yet current project was not whitelisted for + // Google Compute Engine Scanning Alpha access. + FORBIDDEN_TO_SCAN_COMPUTE = 21; + + // User tries to update managed scan + FORBIDDEN_UPDATE_TO_MANAGED_SCAN = 43; + + // The supplied filter is malformed. For example, it can not be parsed, does + // not have a filter type in expression, or the same filter type appears + // more than once. + MALFORMED_FILTER = 22; + + // The supplied resource name is malformed (can not be parsed). + MALFORMED_RESOURCE_NAME = 23; + + // The current project is not in an active state. + PROJECT_INACTIVE = 24; + + // A required field is not set. + REQUIRED_FIELD = 25; + + // Project id, scanconfig id, scanrun id, or finding id are not consistent + // with each other in resource name. + RESOURCE_NAME_INCONSISTENT = 26; + + // The scan being requested to start is already running. + SCAN_ALREADY_RUNNING = 27; + + // The scan that was requested to be stopped is not running. + SCAN_NOT_RUNNING = 28; + + // One of the seed URLs does not belong to the current project. + SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 29; + + // One of the seed URLs is malformed (can not be parsed). + SEED_URL_MALFORMED = 30; + + // One of the seed URLs is mapped to a non-routable IP address in DNS. + SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 31; + + // One of the seed URLs is mapped to an IP address which is not reserved + // for the current project. + SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS = 32; + + // One of the seed URLs has on-routable IP address. + SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 33; + + // One of the seed URLs has an IP address that is not reserved + // for the current project. + SEED_URL_HAS_UNRESERVED_IP_ADDRESS = 35; + + // The Web Security Scanner service account is not configured under the + // project. + SERVICE_ACCOUNT_NOT_CONFIGURED = 36; + + // A project has reached the maximum number of scans. + TOO_MANY_SCANS = 37; + + // Resolving the details of the current project fails. + UNABLE_TO_RESOLVE_PROJECT_INFO = 38; + + // One or more blacklist patterns were in the wrong format. + UNSUPPORTED_BLACKLIST_PATTERN_FORMAT = 39; + + // The supplied filter is not supported. + UNSUPPORTED_FILTER = 40; + + // The supplied finding type is not supported. For example, we do not + // provide findings of the given finding type. + UNSUPPORTED_FINDING_TYPE = 41; + + // The URL scheme of one or more of the supplied URLs is not supported. + UNSUPPORTED_URL_SCHEME = 42; + } + + // Output only. Indicates the reason code for a configuration failure. + Code code = 1; + + // Output only. Indicates the full name of the ScanConfig field that triggers this error, + // for example "scan_config.max_qps". This field is provided for + // troubleshooting purposes only and its actual value can change in the + // future. + string field_name = 2; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run.proto new file mode 100644 index 0000000..465c6cb --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run.proto @@ -0,0 +1,110 @@ +// 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.websecurityscanner.v1; + +import "google/cloud/websecurityscanner/v1/scan_run_error_trace.proto"; +import "google/cloud/websecurityscanner/v1/scan_run_warning_trace.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// A ScanRun is a output-only resource representing an actual run of the scan. +// Next id: 12 +message ScanRun { + // Types of ScanRun execution state. + enum ExecutionState { + // Represents an invalid state caused by internal server error. This value + // should never be returned. + EXECUTION_STATE_UNSPECIFIED = 0; + + // The scan is waiting in the queue. + QUEUED = 1; + + // The scan is in progress. + SCANNING = 2; + + // The scan is either finished or stopped by user. + FINISHED = 3; + } + + // Types of ScanRun result state. + enum ResultState { + // Default value. This value is returned when the ScanRun is not yet + // finished. + RESULT_STATE_UNSPECIFIED = 0; + + // The scan finished without errors. + SUCCESS = 1; + + // The scan finished with errors. + ERROR = 2; + + // The scan was terminated by user. + KILLED = 3; + } + + // Output only. The resource name of the ScanRun. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + // The ScanRun IDs are generated by the system. + string name = 1; + + // Output only. The execution state of the ScanRun. + ExecutionState execution_state = 2; + + // Output only. The result state of the ScanRun. This field is only available after the + // execution state reaches "FINISHED". + ResultState result_state = 3; + + // Output only. The time at which the ScanRun started. + google.protobuf.Timestamp start_time = 4; + + // Output only. The time at which the ScanRun reached termination state - that the ScanRun + // is either finished or stopped by user. + google.protobuf.Timestamp end_time = 5; + + // Output only. The number of URLs crawled during this ScanRun. If the scan is in progress, + // the value represents the number of URLs crawled up to now. + int64 urls_crawled_count = 6; + + // Output only. The number of URLs tested during this ScanRun. If the scan is in progress, + // the value represents the number of URLs tested up to now. The number of + // URLs tested is usually larger than the number URLS crawled because + // typically a crawled URL is tested with multiple test payloads. + int64 urls_tested_count = 7; + + // Output only. Whether the scan run has found any vulnerabilities. + bool has_vulnerabilities = 8; + + // Output only. The percentage of total completion ranging from 0 to 100. + // If the scan is in queue, the value is 0. + // If the scan is running, the value ranges from 0 to 100. + // If the scan is finished, the value is 100. + int32 progress_percent = 9; + + // Output only. If result_state is an ERROR, this field provides the primary reason for + // scan's termination and more details, if such are available. + ScanRunErrorTrace error_trace = 10; + + // Output only. A list of warnings, if such are encountered during this scan run. + repeated ScanRunWarningTrace warning_traces = 11; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_error_trace.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_error_trace.proto new file mode 100644 index 0000000..5234eee --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_error_trace.proto @@ -0,0 +1,75 @@ +// 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.websecurityscanner.v1; + +import "google/cloud/websecurityscanner/v1/scan_config_error.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunErrorTraceProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// Output only. +// Defines an error trace message for a ScanRun. +message ScanRunErrorTrace { + // Output only. + // Defines an error reason code. + // Next id: 7 + enum Code { + // Default value is never used. + CODE_UNSPECIFIED = 0; + + // Indicates that the scan run failed due to an internal server error. + INTERNAL_ERROR = 1; + + // Indicates a scan configuration error, usually due to outdated ScanConfig + // settings, such as starting_urls or the DNS configuration. + SCAN_CONFIG_ISSUE = 2; + + // Indicates an authentication error, usually due to outdated ScanConfig + // authentication settings. + AUTHENTICATION_CONFIG_ISSUE = 3; + + // Indicates a scan operation timeout, usually caused by a very large site. + TIMED_OUT_WHILE_SCANNING = 4; + + // Indicates that a scan encountered excessive redirects, either to + // authentication or some other page outside of the scan scope. + TOO_MANY_REDIRECTS = 5; + + // Indicates that a scan encountered numerous errors from the web site + // pages. When available, most_common_http_error_code field indicates the + // most common HTTP error code encountered during the scan. + TOO_MANY_HTTP_ERRORS = 6; + } + + // Output only. Indicates the error reason code. + Code code = 1; + + // Output only. If the scan encounters SCAN_CONFIG_ISSUE error, this field has the error + // message encountered during scan configuration validation that is performed + // before each scan run. + ScanConfigError scan_config_error = 2; + + // Output only. If the scan encounters TOO_MANY_HTTP_ERRORS, this field indicates the most + // common HTTP error code, if such is available. For example, if this code is + // 404, the scan has encountered too many NOT_FOUND responses. + int32 most_common_http_error_code = 3; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_warning_trace.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_warning_trace.proto new file mode 100644 index 0000000..43a5017 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/scan_run_warning_trace.proto @@ -0,0 +1,58 @@ +// 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.websecurityscanner.v1; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunWarningTraceProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// Output only. +// Defines a warning trace message for ScanRun. Warning traces provide customers +// with useful information that helps make the scanning process more effective. +message ScanRunWarningTrace { + // Output only. + // Defines a warning message code. + // Next id: 6 + enum Code { + // Default value is never used. + CODE_UNSPECIFIED = 0; + + // Indicates that a scan discovered an unexpectedly low number of URLs. This + // is sometimes caused by complex navigation features or by using a single + // URL for numerous pages. + INSUFFICIENT_CRAWL_RESULTS = 1; + + // Indicates that a scan discovered too many URLs to test, or excessive + // redundant URLs. + TOO_MANY_CRAWL_RESULTS = 2; + + // Indicates that too many tests have been generated for the scan. Customer + // should try reducing the number of starting URLs, increasing the QPS rate, + // or narrowing down the scope of the scan using the excluded patterns. + TOO_MANY_FUZZ_TASKS = 3; + + // Indicates that a scan is blocked by IAP. + BLOCKED_BY_IAP = 4; + } + + // Output only. Indicates the warning code. + Code code = 1; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/web_security_scanner.proto b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/web_security_scanner.proto new file mode 100644 index 0000000..5f1bfcd --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/websecurityscanner/v1/web_security_scanner.proto @@ -0,0 +1,337 @@ +// 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.websecurityscanner.v1; + +import "google/api/annotations.proto"; +import "google/cloud/websecurityscanner/v1/crawled_url.proto"; +import "google/cloud/websecurityscanner/v1/finding.proto"; +import "google/cloud/websecurityscanner/v1/finding_type_stats.proto"; +import "google/cloud/websecurityscanner/v1/scan_config.proto"; +import "google/cloud/websecurityscanner/v1/scan_run.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/api/client.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "WebSecurityScannerProto"; +option java_package = "com.google.cloud.websecurityscanner.v1"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1"; + +// Web Security Scanner Service identifies security vulnerabilities in web +// applications hosted on Google Cloud. It crawls your application, and +// attempts to exercise as many user inputs and event handlers as possible. +service WebSecurityScanner { + option (google.api.default_host) = "websecurityscanner.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new ScanConfig. + rpc CreateScanConfig(CreateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/scanConfigs" + body: "scan_config" + }; + } + + // Deletes an existing ScanConfig and its child resources. + rpc DeleteScanConfig(DeleteScanConfigRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/scanConfigs/*}" + }; + } + + // Gets a ScanConfig. + rpc GetScanConfig(GetScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + get: "/v1/{name=projects/*/scanConfigs/*}" + }; + } + + // Lists ScanConfigs under a given project. + rpc ListScanConfigs(ListScanConfigsRequest) returns (ListScanConfigsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/scanConfigs" + }; + } + + // Updates a ScanConfig. This method support partial update of a ScanConfig. + rpc UpdateScanConfig(UpdateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + patch: "/v1/{scan_config.name=projects/*/scanConfigs/*}" + body: "scan_config" + }; + } + + // Start a ScanRun according to the given ScanConfig. + rpc StartScanRun(StartScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1/{name=projects/*/scanConfigs/*}:start" + body: "*" + }; + } + + // Gets a ScanRun. + rpc GetScanRun(GetScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + get: "/v1/{name=projects/*/scanConfigs/*/scanRuns/*}" + }; + } + + // Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + // stop time. + rpc ListScanRuns(ListScanRunsRequest) returns (ListScanRunsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/scanConfigs/*}/scanRuns" + }; + } + + // Stops a ScanRun. The stopped ScanRun is returned. + rpc StopScanRun(StopScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1/{name=projects/*/scanConfigs/*/scanRuns/*}:stop" + body: "*" + }; + } + + // List CrawledUrls under a given ScanRun. + rpc ListCrawledUrls(ListCrawledUrlsRequest) returns (ListCrawledUrlsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls" + }; + } + + // Gets a Finding. + rpc GetFinding(GetFindingRequest) returns (Finding) { + option (google.api.http) = { + get: "/v1/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}" + }; + } + + // List Findings under a given ScanRun. + rpc ListFindings(ListFindingsRequest) returns (ListFindingsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings" + }; + } + + // List all FindingTypeStats under a given ScanRun. + rpc ListFindingTypeStats(ListFindingTypeStatsRequest) returns (ListFindingTypeStatsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats" + }; + } +} + +// Request for the `CreateScanConfig` method. +message CreateScanConfigRequest { + // Required. The parent resource name where the scan is created, which should be a + // project resource name in the format 'projects/{projectId}'. + string parent = 1; + + // Required. The ScanConfig to be created. + ScanConfig scan_config = 2; +} + +// Request for the `DeleteScanConfig` method. +message DeleteScanConfigRequest { + // Required. The resource name of the ScanConfig to be deleted. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1; +} + +// Request for the `GetScanConfig` method. +message GetScanConfigRequest { + // Required. The resource name of the ScanConfig to be returned. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1; +} + +// Request for the `ListScanConfigs` method. +message ListScanConfigsRequest { + // Required. The parent resource name, which should be a project resource name in the + // format 'projects/{projectId}'. + string parent = 1; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanConfigs to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Request for the `UpdateScanConfigRequest` method. +message UpdateScanConfigRequest { + // Required. The ScanConfig to be updated. The name field must be set to identify the + // resource to be updated. The values of fields not covered by the mask + // will be ignored. + ScanConfig scan_config = 2; + + // Required. The update mask applies to the resource. For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask update_mask = 3; +} + +// Response for the `ListScanConfigs` method. +message ListScanConfigsResponse { + // The list of ScanConfigs returned. + repeated ScanConfig scan_configs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StartScanRun` method. +message StartScanRunRequest { + // Required. The resource name of the ScanConfig to be used. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1; +} + +// Request for the `GetScanRun` method. +message GetScanRunRequest { + // Required. The resource name of the ScanRun to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1; +} + +// Request for the `ListScanRuns` method. +message ListScanRunsRequest { + // Required. The parent resource name, which should be a scan resource name in the + // format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string parent = 1; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanRuns to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListScanRuns` method. +message ListScanRunsResponse { + // The list of ScanRuns returned. + repeated ScanRun scan_runs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StopScanRun` method. +message StopScanRunRequest { + // Required. The resource name of the ScanRun to be stopped. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1; +} + +// Request for the `ListCrawledUrls` method. +message ListCrawledUrlsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of CrawledUrls to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListCrawledUrls` method. +message ListCrawledUrlsResponse { + // The list of CrawledUrls returned. + repeated CrawledUrl crawled_urls = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `GetFinding` method. +message GetFindingRequest { + // Required. The resource name of the Finding to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + string name = 1; +} + +// Request for the `ListFindings` method. +message ListFindingsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1; + + // The filter expression. The expression must be in the format: + // . + // Supported field: 'finding_type'. + // Supported operator: '='. + string filter = 2; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 3; + + // The maximum number of Findings to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 4; +} + +// Response for the `ListFindings` method. +message ListFindingsResponse { + // The list of Findings returned. + repeated Finding findings = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `ListFindingTypeStats` method. +message ListFindingTypeStatsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1; +} + +// Response for the `ListFindingTypeStats` method. +message ListFindingTypeStatsResponse { + // The list of FindingTypeStats returned. + repeated FindingTypeStats finding_type_stats = 1; +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 0000000..549f7ea --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const WebSecurityScannerClient = v1.WebSecurityScannerClient; +type WebSecurityScannerClient = v1.WebSecurityScannerClient; +export {v1, WebSecurityScannerClient}; +export default {v1, WebSecurityScannerClient}; +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..6c589c5 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,169 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.websecurityscanner.v1", + "libraryPackage": "@google-cloud/web-security-scanner", + "services": { + "WebSecurityScanner": { + "clients": { + "grpc": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + } + } + } + } +} 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..797d676 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {WebSecurityScannerClient} from './web_security_scanner_client'; diff --git a/owl-bot-staging/v1/src/v1/web_security_scanner_client.ts b/owl-bot-staging/v1/src/v1/web_security_scanner_client.ts new file mode 100644 index 0000000..42ca175 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_security_scanner_client.ts @@ -0,0 +1,1817 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/web_security_scanner_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './web_security_scanner_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Web Security Scanner Service identifies security vulnerabilities in web + * applications hosted on Google Cloud. It crawls your application, and + * attempts to exercise as many user inputs and event handlers as possible. + * @class + * @memberof v1 + */ +export class WebSecurityScannerClient { + private _terminated = false; + private _opts: ClientOptions; + 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: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + webSecurityScannerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WebSecurityScannerClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WebSecurityScannerClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + 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 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 = { + findingPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listScanConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanConfigs'), + listScanRuns: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanRuns'), + listCrawledUrls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'crawledUrls'), + listFindings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'findings') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.websecurityscanner.v1.WebSecurityScanner', 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 = {}; + } + + /** + * 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.webSecurityScannerStub) { + return this.webSecurityScannerStub; + } + + // Put together the "service stub" for + // google.cloud.websecurityscanner.v1.WebSecurityScanner. + this.webSecurityScannerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.websecurityscanner.v1.WebSecurityScanner') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.websecurityscanner.v1.WebSecurityScanner, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const webSecurityScannerStubMethods = + ['createScanConfig', 'deleteScanConfig', 'getScanConfig', 'listScanConfigs', 'updateScanConfig', 'startScanRun', 'getScanRun', 'listScanRuns', 'stopScanRun', 'listCrawledUrls', 'getFinding', 'listFindings', 'listFindingTypeStats']; + for (const methodName of webSecurityScannerStubMethods) { + const callPromise = this.webSecurityScannerStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.webSecurityScannerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'websecurityscanner.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 'websecurityscanner.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 -- + // ------------------- + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|undefined, {}|undefined + ]>; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name where the scan is created, which should be a + * project resource name in the format 'projects/{projectId}'. + * @param {google.cloud.websecurityscanner.v1.ScanConfig} request.scanConfig + * Required. The ScanConfig to be created. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createScanConfig(request); + */ + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.ICreateScanConfigRequest|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.createScanConfig(request, options, callback); + } + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|undefined, {}|undefined + ]>; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an existing ScanConfig and its child resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be deleted. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteScanConfig(request); + */ + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1.IDeleteScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteScanConfig(request, options, callback); + } + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|undefined, {}|undefined + ]>; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be returned. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanConfig(request); + */ + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IGetScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanConfig(request, options, callback); + } + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|undefined, {}|undefined + ]>; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates a ScanConfig. This method support partial update of a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.websecurityscanner.v1.ScanConfig} request.scanConfig + * Required. The ScanConfig to be updated. The name field must be set to identify the + * resource to be updated. The values of fields not covered by the mask + * will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The update mask applies to the resource. For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateScanConfig(request); + */ + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig, + protos.google.cloud.websecurityscanner.v1.IUpdateScanConfigRequest|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({ + 'scan_config.name': request.scanConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateScanConfig(request, options, callback); + } + startScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|undefined, {}|undefined + ]>; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Start a ScanRun according to the given ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be used. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.startScanRun(request); + */ + startScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStartScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.startScanRun(request, options, callback); + } + getScanRun( + request: protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|undefined, {}|undefined + ]>; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanRun(request); + */ + getScanRun( + request: protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IGetScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanRun(request, options, callback); + } + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|undefined, {}|undefined + ]>; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Stops a ScanRun. The stopped ScanRun is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be stopped. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.stopScanRun(request); + */ + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun, + protos.google.cloud.websecurityscanner.v1.IStopScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.stopScanRun(request, options, callback); + } + getFinding( + request: protos.google.cloud.websecurityscanner.v1.IGetFindingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|undefined, {}|undefined + ]>; + getFinding( + request: protos.google.cloud.websecurityscanner.v1.IGetFindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; + getFinding( + request: protos.google.cloud.websecurityscanner.v1.IGetFindingRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a Finding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Finding to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + * @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 [Finding]{@link google.cloud.websecurityscanner.v1.Finding}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getFinding(request); + */ + getFinding( + request: protos.google.cloud.websecurityscanner.v1.IGetFindingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IFinding, + protos.google.cloud.websecurityscanner.v1.IGetFindingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getFinding(request, options, callback); + } + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|undefined, {}|undefined + ]>; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; +/** + * List all FindingTypeStats under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ListFindingTypeStatsResponse]{@link google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.listFindingTypeStats(request); + */ + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsRequest|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.listFindingTypeStats(request, options, callback); + } + + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig[], + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse + ]>; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanConfig>): void; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanConfig>): void; +/** + * Lists ScanConfigs under a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanConfig>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanConfig>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanConfig[], + protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListScanConfigsResponse + ]>|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.listScanConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigsStream( + request?: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.createStream( + this.innerApiCalls.listScanConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanConfig]{@link google.cloud.websecurityscanner.v1.ScanConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanConfigsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanConfigsAsync( + request?: protos.google.cloud.websecurityscanner.v1.IListScanConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.asyncIterate( + this.innerApiCalls['listScanConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun[], + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse + ]>; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanRun>): void; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanRun>): void; +/** + * Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + * stop time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanRun>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IScanRun>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IScanRun[], + protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListScanRunsResponse + ]>|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.listScanRuns(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRunsStream( + request?: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.createStream( + this.innerApiCalls.listScanRuns as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanRuns`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanRun]{@link google.cloud.websecurityscanner.v1.ScanRun}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanRunsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanRunsAsync( + request?: protos.google.cloud.websecurityscanner.v1.IListScanRunsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.asyncIterate( + this.innerApiCalls['listScanRuns'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse + ]>; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.ICrawledUrl>): void; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.ICrawledUrl>): void; +/** + * List CrawledUrls under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [CrawledUrl]{@link google.cloud.websecurityscanner.v1.CrawledUrl}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.ICrawledUrl>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.ICrawledUrl>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsResponse + ]>|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.listCrawledUrls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [CrawledUrl]{@link google.cloud.websecurityscanner.v1.CrawledUrl} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrlsStream( + request?: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.createStream( + this.innerApiCalls.listCrawledUrls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCrawledUrls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [CrawledUrl]{@link google.cloud.websecurityscanner.v1.CrawledUrl}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCrawledUrlsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCrawledUrlsAsync( + request?: protos.google.cloud.websecurityscanner.v1.IListCrawledUrlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.asyncIterate( + this.innerApiCalls['listCrawledUrls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listFindings( + request: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IFinding[], + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse + ]>; + listFindings( + request: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IFinding>): void; + listFindings( + request: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IFinding>): void; +/** + * List Findings under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Finding]{@link google.cloud.websecurityscanner.v1.Finding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindings( + request: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IFinding>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1.IFinding>): + Promise<[ + protos.google.cloud.websecurityscanner.v1.IFinding[], + protos.google.cloud.websecurityscanner.v1.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1.IListFindingsResponse + ]>|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.listFindings(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Finding]{@link google.cloud.websecurityscanner.v1.Finding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindingsStream( + request?: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.createStream( + this.innerApiCalls.listFindings as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Finding]{@link google.cloud.websecurityscanner.v1.Finding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listFindingsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listFindingsAsync( + request?: protos.google.cloud.websecurityscanner.v1.IListFindingsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.asyncIterate( + this.innerApiCalls['listFindings'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified finding resource name string. + * + * @param {string} project + * @param {string} scan_config + * @param {string} scan_run + * @param {string} finding + * @returns {string} Resource name string. + */ + findingPath(project:string,scanConfig:string,scanRun:string,finding:string) { + return this.pathTemplates.findingPathTemplate.render({ + project: project, + scan_config: scanConfig, + scan_run: scanRun, + finding: finding, + }); + } + + /** + * Parse the project from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).project; + } + + /** + * Parse the scan_config from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_config; + } + + /** + * Parse the scan_run from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_run. + */ + matchScanRunFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_run; + } + + /** + * Parse the finding from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the finding. + */ + matchFindingFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).finding; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.webSecurityScannerStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/web_security_scanner_client_config.json b/owl-bot-staging/v1/src/v1/web_security_scanner_client_config.json new file mode 100644 index 0000000..2e226cb --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_security_scanner_client_config.json @@ -0,0 +1,91 @@ +{ + "interfaces": { + "google.cloud.websecurityscanner.v1.WebSecurityScanner": { + "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": { + "CreateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanConfigs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanRuns": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "StopScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCrawledUrls": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetFinding": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindings": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindingTypeStats": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/web_security_scanner_proto_list.json b/owl-bot-staging/v1/src/v1/web_security_scanner_proto_list.json new file mode 100644 index 0000000..d036fd8 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/web_security_scanner_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/websecurityscanner/v1/crawled_url.proto", + "../../protos/google/cloud/websecurityscanner/v1/finding.proto", + "../../protos/google/cloud/websecurityscanner/v1/finding_addon.proto", + "../../protos/google/cloud/websecurityscanner/v1/finding_type_stats.proto", + "../../protos/google/cloud/websecurityscanner/v1/scan_config.proto", + "../../protos/google/cloud/websecurityscanner/v1/scan_config_error.proto", + "../../protos/google/cloud/websecurityscanner/v1/scan_run.proto", + "../../protos/google/cloud/websecurityscanner/v1/scan_run_error_trace.proto", + "../../protos/google/cloud/websecurityscanner/v1/scan_run_warning_trace.proto", + "../../protos/google/cloud/websecurityscanner/v1/web_security_scanner.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..2f2db00 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const websecurityscanner = require('@google-cloud/web-security-scanner'); + +function main() { + const webSecurityScannerClient = new websecurityscanner.WebSecurityScannerClient(); +} + +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..67b8adc --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {WebSecurityScannerClient} from '@google-cloud/web-security-scanner'; + +// check that the client class type name can be used +function doStuffWithWebSecurityScannerClient(client: WebSecurityScannerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const webSecurityScannerClient = new WebSecurityScannerClient(); + doStuffWithWebSecurityScannerClient(webSecurityScannerClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_web_security_scanner_v1.ts b/owl-bot-staging/v1/test/gapic_web_security_scanner_v1.ts new file mode 100644 index 0000000..feb5ac8 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_web_security_scanner_v1.ts @@ -0,0 +1,1871 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as websecurityscannerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.WebSecurityScannerClient', () => { + it('has servicePath', () => { + const servicePath = websecurityscannerModule.v1.WebSecurityScannerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = websecurityscannerModule.v1.WebSecurityScannerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = websecurityscannerModule.v1.WebSecurityScannerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.webSecurityScannerStub, undefined); + await client.initialize(); + assert(client.webSecurityScannerStub); + }); + + it('has close method', () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + 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 websecurityscannerModule.v1.WebSecurityScannerClient({ + 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('createScanConfig', () => { + it('invokes createScanConfig without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createScanConfig with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createScanConfig(request), expectedError); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteScanConfig', () => { + it('invokes deleteScanConfig without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScanConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteScanConfig with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteScanConfig(request), expectedError); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanConfig', () => { + it('invokes getScanConfig without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanConfig with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanConfig(request), expectedError); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateScanConfig', () => { + it('invokes updateScanConfig without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateScanConfig with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateScanConfig(request), expectedError); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('startScanRun', () => { + it('invokes startScanRun without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.startScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes startScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes startScanRun with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.startScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.startScanRun(request), expectedError); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanRun', () => { + it('invokes getScanRun without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.getScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanRun with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanRun(request), expectedError); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('stopScanRun', () => { + it('invokes stopScanRun without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.stopScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes stopScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes stopScanRun with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.stopScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stopScanRun(request), expectedError); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getFinding', () => { + it('invokes getFinding without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()); + client.innerApiCalls.getFinding = stubSimpleCall(expectedResponse); + const [response] = await client.getFinding(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getFinding without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()); + client.innerApiCalls.getFinding = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFinding( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IFinding|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getFinding with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getFinding = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFinding(request), expectedError); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listFindingTypeStats', () => { + it('invokes listFindingTypeStats without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(expectedResponse); + const [response] = await client.listFindingTypeStats(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingTypeStats without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindingTypeStats( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IListFindingTypeStatsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindingTypeStats with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindingTypeStats(request), expectedError); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listScanConfigs', () => { + it('invokes listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listScanConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigs without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanConfigs(request), expectedError); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigsStream without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanConfigsStream with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1.IScanConfig[] = []; + const iterable = client.listScanConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1.IScanConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listScanRuns', () => { + it('invokes listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCall(expectedResponse); + const [response] = await client.listScanRuns(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRuns without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanRuns( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IScanRun[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanRuns = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanRuns(request), expectedError); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRunsStream without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + ]; + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanRunsStream with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ScanRun()), + ]; + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1.IScanRun[] = []; + const iterable = client.listScanRunsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanRunsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1.IScanRun[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCrawledUrls', () => { + it('invokes listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCall(expectedResponse); + const [response] = await client.listCrawledUrls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrls without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCrawledUrls( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.ICrawledUrl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCrawledUrls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCrawledUrls(request), expectedError); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrlsStream without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCrawledUrlsStream with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1.ICrawledUrl[] = []; + const iterable = client.listCrawledUrlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCrawledUrlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1.ICrawledUrl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listFindings', () => { + it('invokes listFindings without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCall(expectedResponse); + const [response] = await client.listFindings(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindings without error using callback', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindings( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1.IFinding[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindings with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindings(request), expectedError); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingsStream without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + ]; + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listFindingsStream with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings without error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.Finding()), + ]; + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1.IFinding[] = []; + const iterable = client.listFindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings with error', async () => { + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1.IFinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('finding', () => { + const fakePath = "/rendered/path/finding"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + scan_run: "scanRunValue", + finding: "findingValue", + }; + const client = new websecurityscannerModule.v1.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.findingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.findingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('findingPath', () => { + const result = client.findingPath("projectValue", "scanConfigValue", "scanRunValue", "findingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.findingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromFindingName', () => { + const result = client.matchProjectFromFindingName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromFindingName', () => { + const result = client.matchScanConfigFromFindingName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanRunFromFindingName', () => { + const result = client.matchScanRunFromFindingName(fakePath); + assert.strictEqual(result, "scanRunValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFindingFromFindingName', () => { + const result = client.matchFindingFromFindingName(fakePath); + assert.strictEqual(result, "findingValue"); + assert((client.pathTemplates.findingPathTemplate.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..ad3467d --- /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: 'WebSecurityScanner', + filename: './web-security-scanner.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/v1alpha/README.md b/owl-bot-staging/v1alpha/README.md new file mode 100644 index 0000000..727d3b6 --- /dev/null +++ b/owl-bot-staging/v1alpha/README.md @@ -0,0 +1 @@ +Websecurityscanner: Nodejs Client diff --git a/owl-bot-staging/v1alpha/linkinator.config.json b/owl-bot-staging/v1alpha/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1alpha/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1alpha/package.json b/owl-bot-staging/v1alpha/package.json new file mode 100644 index 0000000..badee22 --- /dev/null +++ b/owl-bot-staging/v1alpha/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/web-security-scanner", + "version": "0.1.0", + "description": "Websecurityscanner client for Node.js", + "repository": "googleapis/nodejs-websecurityscanner", + "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 websecurityscanner", + "websecurityscanner", + "web security scanner" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.14.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.1", + "@types/sinon": "^10.0.0", + "c8": "^7.7.2", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.6", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^10.0.0", + "ts-loader": "^9.2.2", + "typescript": "^4.2.4", + "webpack": "^5.37.1", + "webpack-cli": "^4.7.0" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/crawled_url.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/crawled_url.proto new file mode 100644 index 0000000..c22f427 --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/crawled_url.proto @@ -0,0 +1,38 @@ +// 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.websecurityscanner.v1alpha; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "CrawledUrlProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// A CrawledUrl resource represents a URL that was crawled during a ScanRun. Web +// Security Scanner Service crawls the web applications, following all links +// within the scope of sites, to find the URLs to test against. +message CrawledUrl { + // Output only. The http method of the request that was used to visit the URL, in + // uppercase. + string http_method = 1; + + // Output only. The URL that was crawled. + string url = 2; + + // Output only. The body of the request that was used to visit the URL. + string body = 3; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding.proto new file mode 100644 index 0000000..c02020f --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding.proto @@ -0,0 +1,152 @@ +// 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.websecurityscanner.v1alpha; + +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1alpha/finding_addon.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// A Finding resource represents a vulnerability instance identified during a +// ScanRun. +message Finding { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/Finding" + pattern: "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}" + }; + + // Types of Findings. + enum FindingType { + // The invalid finding type. + FINDING_TYPE_UNSPECIFIED = 0; + + // A page that was served over HTTPS also resources over HTTP. A + // man-in-the-middle attacker could tamper with the HTTP resource and gain + // full access to the website that loads the resource or to monitor the + // actions taken by the user. + MIXED_CONTENT = 1; + + // The version of an included library is known to contain a security issue. + // The scanner checks the version of library in use against a known list of + // vulnerable libraries. False positives are possible if the version + // detection fails or if the library has been manually patched. + OUTDATED_LIBRARY = 2; + + // This type of vulnerability occurs when the value of a request parameter + // is reflected at the beginning of the response, for example, in requests + // using JSONP. Under certain circumstances, an attacker may be able to + // supply an alphanumeric-only Flash file in the vulnerable parameter + // causing the browser to execute the Flash file as if it originated on the + // vulnerable server. + ROSETTA_FLASH = 5; + + // A cross-site scripting (XSS) bug is found via JavaScript callback. For + // detailed explanations on XSS, see + // https://www.google.com/about/appsecurity/learning/xss/. + XSS_CALLBACK = 3; + + // A potential cross-site scripting (XSS) bug due to JavaScript breakage. + // In some circumstances, the application under test might modify the test + // string before it is parsed by the browser. When the browser attempts to + // runs this modified test string, it will likely break and throw a + // JavaScript execution error, thus an injection issue is occurring. + // However, it may not be exploitable. Manual verification is needed to see + // if the test string modifications can be evaded and confirm that the issue + // is in fact an XSS vulnerability. For detailed explanations on XSS, see + // https://www.google.com/about/appsecurity/learning/xss/. + XSS_ERROR = 4; + + // An application appears to be transmitting a password field in clear text. + // An attacker can eavesdrop network traffic and sniff the password field. + CLEAR_TEXT_PASSWORD = 6; + + // An application returns sensitive content with an invalid content type, + // or without an 'X-Content-Type-Options: nosniff' header. + INVALID_CONTENT_TYPE = 7; + + // A cross-site scripting (XSS) vulnerability in AngularJS module that + // occurs when a user-provided string is interpolated by Angular. + XSS_ANGULAR_CALLBACK = 8; + + // A malformed or invalid valued header. + INVALID_HEADER = 9; + + // Misspelled security header name. + MISSPELLED_SECURITY_HEADER_NAME = 10; + + // Mismatching values in a duplicate security header. + MISMATCHING_SECURITY_HEADER_VALUES = 11; + } + + // The resource name of the Finding. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{scanRunId}/findings/{findingId}'. + // The finding IDs are generated by the system. + string name = 1; + + // The type of the Finding. + FindingType finding_type = 2; + + // The http method of the request that triggered the vulnerability, in + // uppercase. + string http_method = 3; + + // The URL produced by the server-side fuzzer and used in the request that + // triggered the vulnerability. + string fuzzed_url = 4; + + // The body of the request that triggered the vulnerability. + string body = 5; + + // The description of the vulnerability. + string description = 6; + + // The URL containing human-readable payload that user can leverage to + // reproduce the vulnerability. + string reproduction_url = 7; + + // If the vulnerability was originated from nested IFrame, the immediate + // parent IFrame is reported. + string frame_url = 8; + + // The URL where the browser lands when the vulnerability is detected. + string final_url = 9; + + // The tracking ID uniquely identifies a vulnerability instance across + // multiple ScanRuns. + string tracking_id = 10; + + // An addon containing information about outdated libraries. + OutdatedLibrary outdated_library = 11; + + // An addon containing detailed information regarding any resource causing the + // vulnerability such as JavaScript sources, image, audio files, etc. + ViolatingResource violating_resource = 12; + + // An addon containing information about vulnerable or missing HTTP headers. + VulnerableHeaders vulnerable_headers = 15; + + // An addon containing information about request parameters which were found + // to be vulnerable. + VulnerableParameters vulnerable_parameters = 13; + + // An addon containing information reported for an XSS, if any. + Xss xss = 14; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_addon.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_addon.proto new file mode 100644 index 0000000..3fafdb4 --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_addon.proto @@ -0,0 +1,78 @@ +// 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.websecurityscanner.v1alpha; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingAddonProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// Information reported for an outdated library. +message OutdatedLibrary { + // The name of the outdated library. + string library_name = 1; + + // The version number. + string version = 2; + + // URLs to learn more information about the vulnerabilities in the library. + repeated string learn_more_urls = 3; +} + +// Information regarding any resource causing the vulnerability such +// as JavaScript sources, image, audio files, etc. +message ViolatingResource { + // The MIME type of this resource. + string content_type = 1; + + // URL of this violating resource. + string resource_url = 2; +} + +// Information about vulnerable request parameters. +message VulnerableParameters { + // The vulnerable parameter names. + repeated string parameter_names = 1; +} + +// Information about vulnerable or missing HTTP Headers. +message VulnerableHeaders { + // Describes a HTTP Header. + message Header { + // Header name. + string name = 1; + + // Header value. + string value = 2; + } + + // List of vulnerable headers. + repeated Header headers = 1; + + // List of missing headers. + repeated Header missing_headers = 2; +} + +// Information reported for an XSS. +message Xss { + // Stack traces leading to the point where the XSS occurred. + repeated string stack_traces = 1; + + // An error message generated by a javascript breakage. + string error_message = 2; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_type_stats.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_type_stats.proto new file mode 100644 index 0000000..e46b330 --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/finding_type_stats.proto @@ -0,0 +1,35 @@ +// 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.websecurityscanner.v1alpha; + +import "google/cloud/websecurityscanner/v1alpha/finding.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingTypeStatsProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// A FindingTypeStats resource represents stats regarding a specific FindingType +// of Findings under a given ScanRun. +message FindingTypeStats { + // The finding type associated with the stats. + Finding.FindingType finding_type = 1; + + // The count of findings belonging to this finding type. + int32 finding_count = 2; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_config.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_config.proto new file mode 100644 index 0000000..5497b1a --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_config.proto @@ -0,0 +1,157 @@ +// 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.websecurityscanner.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1alpha/scan_run.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanConfigProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// A ScanConfig resource contains the configurations to launch a scan. +// next id: 12 +message ScanConfig { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + pattern: "projects/{project}/scanConfigs/{scan_config}" + }; + + // Scan authentication configuration. + message Authentication { + // Describes authentication configuration that uses a Google account. + message GoogleAccount { + // Required. The user name of the Google account. + string username = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Input only. The password of the Google account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = INPUT_ONLY + ]; + } + + // Describes authentication configuration that uses a custom account. + message CustomAccount { + // Required. The user name of the custom account. + string username = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Input only. The password of the custom account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Required. The login form URL of the website. + string login_url = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. + // Authentication configuration + oneof authentication { + // Authentication using a Google account. + GoogleAccount google_account = 1; + + // Authentication using a custom account. + CustomAccount custom_account = 2; + } + } + + // Scan schedule configuration. + message Schedule { + // A timestamp indicates when the next run will be scheduled. The value is + // refreshed by the server after each run. If unspecified, it will default + // to current server time, which means the scan will be scheduled to start + // immediately. + google.protobuf.Timestamp schedule_time = 1; + + // Required. The duration of time between executions in days. + int32 interval_duration_days = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Type of user agents used for scanning. + enum UserAgent { + // The user agent is unknown. Service will default to CHROME_LINUX. + USER_AGENT_UNSPECIFIED = 0; + + // Chrome on Linux. This is the service default if unspecified. + CHROME_LINUX = 1; + + // Chrome on Android. + CHROME_ANDROID = 2; + + // Safari on IPhone. + SAFARI_IPHONE = 3; + } + + // Cloud platforms supported by Cloud Web Security Scanner. + enum TargetPlatform { + // The target platform is unknown. Requests with this enum value will be + // rejected with INVALID_ARGUMENT error. + TARGET_PLATFORM_UNSPECIFIED = 0; + + // Google App Engine service. + APP_ENGINE = 1; + + // Google Compute Engine service. + COMPUTE = 2; + } + + // The resource name of the ScanConfig. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}'. The ScanConfig IDs are + // generated by the system. + string name = 1; + + // Required. The user provided display name of the ScanConfig. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The maximum QPS during scanning. A valid value ranges from 5 to 20 + // inclusively. If the field is unspecified or its value is set 0, server will + // default to 15. Other values outside of [5, 20] range will be rejected with + // INVALID_ARGUMENT error. + int32 max_qps = 3; + + // Required. The starting URLs from which the scanner finds site pages. + repeated string starting_urls = 4 [(google.api.field_behavior) = REQUIRED]; + + // The authentication configuration. If specified, service will use the + // authentication configuration during scanning. + Authentication authentication = 5; + + // The user agent used during scanning. + UserAgent user_agent = 6; + + // The blacklist URL patterns as described in + // https://cloud.google.com/security-scanner/docs/excluded-urls + repeated string blacklist_patterns = 7; + + // The schedule of the ScanConfig. + Schedule schedule = 8; + + // Set of Cloud Platforms targeted by the scan. If empty, APP_ENGINE will be + // used as a default. + repeated TargetPlatform target_platforms = 9; + + // Latest ScanRun if available. + ScanRun latest_run = 11; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_run.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_run.proto new file mode 100644 index 0000000..79c5419 --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/scan_run.proto @@ -0,0 +1,104 @@ +// 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.websecurityscanner.v1alpha; + +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// A ScanRun is a output-only resource representing an actual run of the scan. +message ScanRun { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/ScanRun" + pattern: "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}" + }; + + // Types of ScanRun execution state. + enum ExecutionState { + // Represents an invalid state caused by internal server error. This value + // should never be returned. + EXECUTION_STATE_UNSPECIFIED = 0; + + // The scan is waiting in the queue. + QUEUED = 1; + + // The scan is in progress. + SCANNING = 2; + + // The scan is either finished or stopped by user. + FINISHED = 3; + } + + // Types of ScanRun result state. + enum ResultState { + // Default value. This value is returned when the ScanRun is not yet + // finished. + RESULT_STATE_UNSPECIFIED = 0; + + // The scan finished without errors. + SUCCESS = 1; + + // The scan finished with errors. + ERROR = 2; + + // The scan was terminated by user. + KILLED = 3; + } + + // The resource name of the ScanRun. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + // The ScanRun IDs are generated by the system. + string name = 1; + + // The execution state of the ScanRun. + ExecutionState execution_state = 2; + + // The result state of the ScanRun. This field is only available after the + // execution state reaches "FINISHED". + ResultState result_state = 3; + + // The time at which the ScanRun started. + google.protobuf.Timestamp start_time = 4; + + // The time at which the ScanRun reached termination state - that the ScanRun + // is either finished or stopped by user. + google.protobuf.Timestamp end_time = 5; + + // The number of URLs crawled during this ScanRun. If the scan is in progress, + // the value represents the number of URLs crawled up to now. + int64 urls_crawled_count = 6; + + // The number of URLs tested during this ScanRun. If the scan is in progress, + // the value represents the number of URLs tested up to now. The number of + // URLs tested is usually larger than the number URLS crawled because + // typically a crawled URL is tested with multiple test payloads. + int64 urls_tested_count = 7; + + // Whether the scan run has found any vulnerabilities. + bool has_vulnerabilities = 8; + + // The percentage of total completion ranging from 0 to 100. + // If the scan is in queue, the value is 0. + // If the scan is running, the value ranges from 0 to 100. + // If the scan is finished, the value is 100. + int32 progress_percent = 9; +} diff --git a/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/web_security_scanner.proto b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/web_security_scanner.proto new file mode 100644 index 0000000..f34bd74 --- /dev/null +++ b/owl-bot-staging/v1alpha/protos/google/cloud/websecurityscanner/v1alpha/web_security_scanner.proto @@ -0,0 +1,410 @@ +// 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.websecurityscanner.v1alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1alpha/crawled_url.proto"; +import "google/cloud/websecurityscanner/v1alpha/finding.proto"; +import "google/cloud/websecurityscanner/v1alpha/finding_type_stats.proto"; +import "google/cloud/websecurityscanner/v1alpha/scan_config.proto"; +import "google/cloud/websecurityscanner/v1alpha/scan_run.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1alpha;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "WebSecurityScannerProto"; +option java_package = "com.google.cloud.websecurityscanner.v1alpha"; + +// Cloud Web Security Scanner Service identifies security vulnerabilities in web +// applications hosted on Google Cloud Platform. It crawls your application, and +// attempts to exercise as many user inputs and event handlers as possible. +service WebSecurityScanner { + option (google.api.default_host) = "websecurityscanner.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new ScanConfig. + rpc CreateScanConfig(CreateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + post: "/v1alpha/{parent=projects/*}/scanConfigs" + body: "scan_config" + }; + option (google.api.method_signature) = "parent,scan_config"; + } + + // Deletes an existing ScanConfig and its child resources. + rpc DeleteScanConfig(DeleteScanConfigRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1alpha/{name=projects/*/scanConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a ScanConfig. + rpc GetScanConfig(GetScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/scanConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists ScanConfigs under a given project. + rpc ListScanConfigs(ListScanConfigsRequest) returns (ListScanConfigsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*}/scanConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a ScanConfig. This method support partial update of a ScanConfig. + rpc UpdateScanConfig(UpdateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + patch: "/v1alpha/{scan_config.name=projects/*/scanConfigs/*}" + body: "scan_config" + }; + option (google.api.method_signature) = "scan_config,update_mask"; + } + + // Start a ScanRun according to the given ScanConfig. + rpc StartScanRun(StartScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1alpha/{name=projects/*/scanConfigs/*}:start" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a ScanRun. + rpc GetScanRun(GetScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + // stop time. + rpc ListScanRuns(ListScanRunsRequest) returns (ListScanRunsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/scanConfigs/*}/scanRuns" + }; + option (google.api.method_signature) = "parent"; + } + + // Stops a ScanRun. The stopped ScanRun is returned. + rpc StopScanRun(StopScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*}:stop" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // List CrawledUrls under a given ScanRun. + rpc ListCrawledUrls(ListCrawledUrlsRequest) returns (ListCrawledUrlsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a Finding. + rpc GetFinding(GetFindingRequest) returns (Finding) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List Findings under a given ScanRun. + rpc ListFindings(ListFindingsRequest) returns (ListFindingsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings" + }; + option (google.api.method_signature) = "parent,filter"; + } + + // List all FindingTypeStats under a given ScanRun. + rpc ListFindingTypeStats(ListFindingTypeStatsRequest) returns (ListFindingTypeStatsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for the `CreateScanConfig` method. +message CreateScanConfigRequest { + // Required. The parent resource name where the scan is created, which should be a + // project resource name in the format 'projects/{projectId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The ScanConfig to be created. + ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `DeleteScanConfig` method. +message DeleteScanConfigRequest { + // Required. The resource name of the ScanConfig to be deleted. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `GetScanConfig` method. +message GetScanConfigRequest { + // Required. The resource name of the ScanConfig to be returned. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `ListScanConfigs` method. +message ListScanConfigsRequest { + // Required. The parent resource name, which should be a project resource name in the + // format 'projects/{projectId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanConfigs to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Request for the `UpdateScanConfigRequest` method. +message UpdateScanConfigRequest { + // Required. The ScanConfig to be updated. The name field must be set to identify the + // resource to be updated. The values of fields not covered by the mask + // will be ignored. + ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The update mask applies to the resource. For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask update_mask = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for the `ListScanConfigs` method. +message ListScanConfigsResponse { + // The list of ScanConfigs returned. + repeated ScanConfig scan_configs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StartScanRun` method. +message StartScanRunRequest { + // Required. The resource name of the ScanConfig to be used. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `GetScanRun` method. +message GetScanRunRequest { + // Required. The resource name of the ScanRun to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Request for the `ListScanRuns` method. +message ListScanRunsRequest { + // Required. The parent resource name, which should be a scan resource name in the + // format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanRuns to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListScanRuns` method. +message ListScanRunsResponse { + // The list of ScanRuns returned. + repeated ScanRun scan_runs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StopScanRun` method. +message StopScanRunRequest { + // Required. The resource name of the ScanRun to be stopped. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Request for the `ListCrawledUrls` method. +message ListCrawledUrlsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of CrawledUrls to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListCrawledUrls` method. +message ListCrawledUrlsResponse { + // The list of CrawledUrls returned. + repeated CrawledUrl crawled_urls = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `GetFinding` method. +message GetFindingRequest { + // Required. The resource name of the Finding to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/Finding" + } + ]; +} + +// Request for the `ListFindings` method. +message ListFindingsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; + + // Required. The filter expression. The expression must be in the format: + // . + // Supported field: 'finding_type'. + // Supported operator: '='. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 3; + + // The maximum number of Findings to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 4; +} + +// Response for the `ListFindings` method. +message ListFindingsResponse { + // The list of Findings returned. + repeated Finding findings = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `ListFindingTypeStats` method. +message ListFindingTypeStatsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Response for the `ListFindingTypeStats` method. +message ListFindingTypeStatsResponse { + // The list of FindingTypeStats returned. + repeated FindingTypeStats finding_type_stats = 1; +} diff --git a/owl-bot-staging/v1alpha/src/index.ts b/owl-bot-staging/v1alpha/src/index.ts new file mode 100644 index 0000000..c95c3e0 --- /dev/null +++ b/owl-bot-staging/v1alpha/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1alpha from './v1alpha'; +const WebSecurityScannerClient = v1alpha.WebSecurityScannerClient; +type WebSecurityScannerClient = v1alpha.WebSecurityScannerClient; +export {v1alpha, WebSecurityScannerClient}; +export default {v1alpha, WebSecurityScannerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1alpha/src/v1alpha/gapic_metadata.json b/owl-bot-staging/v1alpha/src/v1alpha/gapic_metadata.json new file mode 100644 index 0000000..72e2c6b --- /dev/null +++ b/owl-bot-staging/v1alpha/src/v1alpha/gapic_metadata.json @@ -0,0 +1,169 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.websecurityscanner.v1alpha", + "libraryPackage": "@google-cloud/web-security-scanner", + "services": { + "WebSecurityScanner": { + "clients": { + "grpc": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1alpha/src/v1alpha/index.ts b/owl-bot-staging/v1alpha/src/v1alpha/index.ts new file mode 100644 index 0000000..797d676 --- /dev/null +++ b/owl-bot-staging/v1alpha/src/v1alpha/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {WebSecurityScannerClient} from './web_security_scanner_client'; diff --git a/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client.ts b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client.ts new file mode 100644 index 0000000..21d220b --- /dev/null +++ b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client.ts @@ -0,0 +1,1934 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1alpha/web_security_scanner_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './web_security_scanner_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Cloud Web Security Scanner Service identifies security vulnerabilities in web + * applications hosted on Google Cloud Platform. It crawls your application, and + * attempts to exercise as many user inputs and event handlers as possible. + * @class + * @memberof v1alpha + */ +export class WebSecurityScannerClient { + private _terminated = false; + private _opts: ClientOptions; + 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: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + webSecurityScannerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WebSecurityScannerClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WebSecurityScannerClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + 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 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 = { + findingPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + scanConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}' + ), + scanRunPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listScanConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanConfigs'), + listScanRuns: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanRuns'), + listCrawledUrls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'crawledUrls'), + listFindings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'findings') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.websecurityscanner.v1alpha.WebSecurityScanner', 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 = {}; + } + + /** + * 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.webSecurityScannerStub) { + return this.webSecurityScannerStub; + } + + // Put together the "service stub" for + // google.cloud.websecurityscanner.v1alpha.WebSecurityScanner. + this.webSecurityScannerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.websecurityscanner.v1alpha.WebSecurityScanner') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.websecurityscanner.v1alpha.WebSecurityScanner, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const webSecurityScannerStubMethods = + ['createScanConfig', 'deleteScanConfig', 'getScanConfig', 'listScanConfigs', 'updateScanConfig', 'startScanRun', 'getScanRun', 'listScanRuns', 'stopScanRun', 'listCrawledUrls', 'getFinding', 'listFindings', 'listFindingTypeStats']; + for (const methodName of webSecurityScannerStubMethods) { + const callPromise = this.webSecurityScannerStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.webSecurityScannerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'websecurityscanner.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 'websecurityscanner.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 -- + // ------------------- + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|undefined, {}|undefined + ]>; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name where the scan is created, which should be a + * project resource name in the format 'projects/{projectId}'. + * @param {google.cloud.websecurityscanner.v1alpha.ScanConfig} request.scanConfig + * Required. The ScanConfig to be created. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createScanConfig(request); + */ + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.ICreateScanConfigRequest|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.createScanConfig(request, options, callback); + } + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|undefined, {}|undefined + ]>; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an existing ScanConfig and its child resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be deleted. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteScanConfig(request); + */ + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1alpha.IDeleteScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteScanConfig(request, options, callback); + } + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|undefined, {}|undefined + ]>; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be returned. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanConfig(request); + */ + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanConfig(request, options, callback); + } + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|undefined, {}|undefined + ]>; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates a ScanConfig. This method support partial update of a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.websecurityscanner.v1alpha.ScanConfig} request.scanConfig + * Required. The ScanConfig to be updated. The name field must be set to identify the + * resource to be updated. The values of fields not covered by the mask + * will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The update mask applies to the resource. For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateScanConfig(request); + */ + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig, + protos.google.cloud.websecurityscanner.v1alpha.IUpdateScanConfigRequest|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({ + 'scan_config.name': request.scanConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateScanConfig(request, options, callback); + } + startScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|undefined, {}|undefined + ]>; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Start a ScanRun according to the given ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be used. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.startScanRun(request); + */ + startScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStartScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.startScanRun(request, options, callback); + } + getScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|undefined, {}|undefined + ]>; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanRun(request); + */ + getScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IGetScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanRun(request, options, callback); + } + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|undefined, {}|undefined + ]>; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Stops a ScanRun. The stopped ScanRun is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be stopped. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.stopScanRun(request); + */ + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun, + protos.google.cloud.websecurityscanner.v1alpha.IStopScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.stopScanRun(request, options, callback); + } + getFinding( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|undefined, {}|undefined + ]>; + getFinding( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; + getFinding( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a Finding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Finding to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + * @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 [Finding]{@link google.cloud.websecurityscanner.v1alpha.Finding}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getFinding(request); + */ + getFinding( + request: protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IFinding, + protos.google.cloud.websecurityscanner.v1alpha.IGetFindingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getFinding(request, options, callback); + } + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|undefined, {}|undefined + ]>; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; +/** + * List all FindingTypeStats under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ListFindingTypeStatsResponse]{@link google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.listFindingTypeStats(request); + */ + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsRequest|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.listFindingTypeStats(request, options, callback); + } + + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig[], + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse + ]>; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig>): void; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig>): void; +/** + * Lists ScanConfigs under a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanConfig[], + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsResponse + ]>|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.listScanConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigsStream( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.createStream( + this.innerApiCalls.listScanConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanConfig]{@link google.cloud.websecurityscanner.v1alpha.ScanConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanConfigsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanConfigsAsync( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListScanConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.asyncIterate( + this.innerApiCalls['listScanConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun[], + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse + ]>; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanRun>): void; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanRun>): void; +/** + * Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + * stop time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanRun>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IScanRun>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IScanRun[], + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsResponse + ]>|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.listScanRuns(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRunsStream( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.createStream( + this.innerApiCalls.listScanRuns as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanRuns`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanRun]{@link google.cloud.websecurityscanner.v1alpha.ScanRun}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanRunsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanRunsAsync( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListScanRunsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.asyncIterate( + this.innerApiCalls['listScanRuns'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse + ]>; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl>): void; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl>): void; +/** + * List CrawledUrls under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [CrawledUrl]{@link google.cloud.websecurityscanner.v1alpha.CrawledUrl}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsResponse + ]>|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.listCrawledUrls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [CrawledUrl]{@link google.cloud.websecurityscanner.v1alpha.CrawledUrl} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrlsStream( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.createStream( + this.innerApiCalls.listCrawledUrls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCrawledUrls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [CrawledUrl]{@link google.cloud.websecurityscanner.v1alpha.CrawledUrl}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCrawledUrlsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCrawledUrlsAsync( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListCrawledUrlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.asyncIterate( + this.innerApiCalls['listCrawledUrls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listFindings( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IFinding[], + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse + ]>; + listFindings( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IFinding>): void; + listFindings( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IFinding>): void; +/** + * List Findings under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Finding]{@link google.cloud.websecurityscanner.v1alpha.Finding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindings( + request: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IFinding>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1alpha.IFinding>): + Promise<[ + protos.google.cloud.websecurityscanner.v1alpha.IFinding[], + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1alpha.IListFindingsResponse + ]>|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.listFindings(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Finding]{@link google.cloud.websecurityscanner.v1alpha.Finding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindingsStream( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.createStream( + this.innerApiCalls.listFindings as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Finding]{@link google.cloud.websecurityscanner.v1alpha.Finding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listFindingsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listFindingsAsync( + request?: protos.google.cloud.websecurityscanner.v1alpha.IListFindingsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.asyncIterate( + this.innerApiCalls['listFindings'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified finding resource name string. + * + * @param {string} project + * @param {string} scan_config + * @param {string} scan_run + * @param {string} finding + * @returns {string} Resource name string. + */ + findingPath(project:string,scanConfig:string,scanRun:string,finding:string) { + return this.pathTemplates.findingPathTemplate.render({ + project: project, + scan_config: scanConfig, + scan_run: scanRun, + finding: finding, + }); + } + + /** + * Parse the project from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).project; + } + + /** + * Parse the scan_config from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_config; + } + + /** + * Parse the scan_run from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_run. + */ + matchScanRunFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_run; + } + + /** + * Parse the finding from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the finding. + */ + matchFindingFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).finding; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified scanConfig resource name string. + * + * @param {string} project + * @param {string} scan_config + * @returns {string} Resource name string. + */ + scanConfigPath(project:string,scanConfig:string) { + return this.pathTemplates.scanConfigPathTemplate.render({ + project: project, + scan_config: scanConfig, + }); + } + + /** + * Parse the project from ScanConfig resource. + * + * @param {string} scanConfigName + * A fully-qualified path representing ScanConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScanConfigName(scanConfigName: string) { + return this.pathTemplates.scanConfigPathTemplate.match(scanConfigName).project; + } + + /** + * Parse the scan_config from ScanConfig resource. + * + * @param {string} scanConfigName + * A fully-qualified path representing ScanConfig resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromScanConfigName(scanConfigName: string) { + return this.pathTemplates.scanConfigPathTemplate.match(scanConfigName).scan_config; + } + + /** + * Return a fully-qualified scanRun resource name string. + * + * @param {string} project + * @param {string} scan_config + * @param {string} scan_run + * @returns {string} Resource name string. + */ + scanRunPath(project:string,scanConfig:string,scanRun:string) { + return this.pathTemplates.scanRunPathTemplate.render({ + project: project, + scan_config: scanConfig, + scan_run: scanRun, + }); + } + + /** + * Parse the project from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).project; + } + + /** + * Parse the scan_config from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).scan_config; + } + + /** + * Parse the scan_run from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the scan_run. + */ + matchScanRunFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).scan_run; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.webSecurityScannerStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client_config.json b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client_config.json new file mode 100644 index 0000000..288b9b0 --- /dev/null +++ b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_client_config.json @@ -0,0 +1,91 @@ +{ + "interfaces": { + "google.cloud.websecurityscanner.v1alpha.WebSecurityScanner": { + "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": { + "CreateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanConfigs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanRuns": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "StopScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCrawledUrls": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetFinding": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindings": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindingTypeStats": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_proto_list.json b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_proto_list.json new file mode 100644 index 0000000..1696775 --- /dev/null +++ b/owl-bot-staging/v1alpha/src/v1alpha/web_security_scanner_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/websecurityscanner/v1alpha/crawled_url.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/finding.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/finding_addon.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/finding_type_stats.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/scan_config.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/scan_run.proto", + "../../protos/google/cloud/websecurityscanner/v1alpha/web_security_scanner.proto" +] diff --git a/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..2f2db00 --- /dev/null +++ b/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const websecurityscanner = require('@google-cloud/web-security-scanner'); + +function main() { + const webSecurityScannerClient = new websecurityscanner.WebSecurityScannerClient(); +} + +main(); diff --git a/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..67b8adc --- /dev/null +++ b/owl-bot-staging/v1alpha/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {WebSecurityScannerClient} from '@google-cloud/web-security-scanner'; + +// check that the client class type name can be used +function doStuffWithWebSecurityScannerClient(client: WebSecurityScannerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const webSecurityScannerClient = new WebSecurityScannerClient(); + doStuffWithWebSecurityScannerClient(webSecurityScannerClient); +} + +main(); diff --git a/owl-bot-staging/v1alpha/system-test/install.ts b/owl-bot-staging/v1alpha/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1alpha/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1alpha/test/gapic_web_security_scanner_v1alpha.ts b/owl-bot-staging/v1alpha/test/gapic_web_security_scanner_v1alpha.ts new file mode 100644 index 0000000..197e2ac --- /dev/null +++ b/owl-bot-staging/v1alpha/test/gapic_web_security_scanner_v1alpha.ts @@ -0,0 +1,1985 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as websecurityscannerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1alpha.WebSecurityScannerClient', () => { + it('has servicePath', () => { + const servicePath = websecurityscannerModule.v1alpha.WebSecurityScannerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = websecurityscannerModule.v1alpha.WebSecurityScannerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = websecurityscannerModule.v1alpha.WebSecurityScannerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.webSecurityScannerStub, undefined); + await client.initialize(); + assert(client.webSecurityScannerStub); + }); + + it('has close method', () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + 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 websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + 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('createScanConfig', () => { + it('invokes createScanConfig without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createScanConfig with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createScanConfig(request), expectedError); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteScanConfig', () => { + it('invokes deleteScanConfig without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScanConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteScanConfig with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteScanConfig(request), expectedError); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanConfig', () => { + it('invokes getScanConfig without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanConfig with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanConfig(request), expectedError); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateScanConfig', () => { + it('invokes updateScanConfig without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateScanConfig with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateScanConfig(request), expectedError); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('startScanRun', () => { + it('invokes startScanRun without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.startScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes startScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes startScanRun with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.startScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.startScanRun(request), expectedError); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanRun', () => { + it('invokes getScanRun without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.getScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanRun with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanRun(request), expectedError); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('stopScanRun', () => { + it('invokes stopScanRun without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.stopScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes stopScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes stopScanRun with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.stopScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stopScanRun(request), expectedError); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getFinding', () => { + it('invokes getFinding without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()); + client.innerApiCalls.getFinding = stubSimpleCall(expectedResponse); + const [response] = await client.getFinding(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getFinding without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()); + client.innerApiCalls.getFinding = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFinding( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IFinding|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getFinding with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getFinding = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFinding(request), expectedError); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listFindingTypeStats', () => { + it('invokes listFindingTypeStats without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(expectedResponse); + const [response] = await client.listFindingTypeStats(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingTypeStats without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindingTypeStats( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IListFindingTypeStatsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindingTypeStats with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindingTypeStats(request), expectedError); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listScanConfigs', () => { + it('invokes listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listScanConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigs without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanConfigs(request), expectedError); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigsStream without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanConfigsStream with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig[] = []; + const iterable = client.listScanConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.IScanConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listScanRuns', () => { + it('invokes listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCall(expectedResponse); + const [response] = await client.listScanRuns(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRuns without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanRuns( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IScanRun[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanRuns = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanRuns(request), expectedError); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRunsStream without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + ]; + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanRunsStream with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ScanRun()), + ]; + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1alpha.IScanRun[] = []; + const iterable = client.listScanRunsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanRunsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.IScanRun[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCrawledUrls', () => { + it('invokes listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCall(expectedResponse); + const [response] = await client.listCrawledUrls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrls without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCrawledUrls( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCrawledUrls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCrawledUrls(request), expectedError); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrlsStream without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCrawledUrlsStream with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl[] = []; + const iterable = client.listCrawledUrlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCrawledUrlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.ICrawledUrl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listFindings', () => { + it('invokes listFindings without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCall(expectedResponse); + const [response] = await client.listFindings(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindings without error using callback', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindings( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1alpha.IFinding[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindings with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindings(request), expectedError); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingsStream without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + ]; + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listFindingsStream with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1alpha.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings without error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.Finding()), + ]; + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1alpha.IFinding[] = []; + const iterable = client.listFindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings with error', async () => { + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1alpha.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1alpha.IFinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('finding', () => { + const fakePath = "/rendered/path/finding"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + scan_run: "scanRunValue", + finding: "findingValue", + }; + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.findingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.findingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('findingPath', () => { + const result = client.findingPath("projectValue", "scanConfigValue", "scanRunValue", "findingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.findingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromFindingName', () => { + const result = client.matchProjectFromFindingName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromFindingName', () => { + const result = client.matchScanConfigFromFindingName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanRunFromFindingName', () => { + const result = client.matchScanRunFromFindingName(fakePath); + assert.strictEqual(result, "scanRunValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFindingFromFindingName', () => { + const result = client.matchFindingFromFindingName(fakePath); + assert.strictEqual(result, "findingValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('scanConfig', () => { + const fakePath = "/rendered/path/scanConfig"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + }; + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.scanConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.scanConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('scanConfigPath', () => { + const result = client.scanConfigPath("projectValue", "scanConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.scanConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScanConfigName', () => { + const result = client.matchProjectFromScanConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.scanConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromScanConfigName', () => { + const result = client.matchScanConfigFromScanConfigName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.scanConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('scanRun', () => { + const fakePath = "/rendered/path/scanRun"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + scan_run: "scanRunValue", + }; + const client = new websecurityscannerModule.v1alpha.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.scanRunPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.scanRunPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('scanRunPath', () => { + const result = client.scanRunPath("projectValue", "scanConfigValue", "scanRunValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.scanRunPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScanRunName', () => { + const result = client.matchProjectFromScanRunName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromScanRunName', () => { + const result = client.matchScanConfigFromScanRunName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanRunFromScanRunName', () => { + const result = client.matchScanRunFromScanRunName(fakePath); + assert.strictEqual(result, "scanRunValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1alpha/tsconfig.json b/owl-bot-staging/v1alpha/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1alpha/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/v1alpha/webpack.config.js b/owl-bot-staging/v1alpha/webpack.config.js new file mode 100644 index 0000000..ad3467d --- /dev/null +++ b/owl-bot-staging/v1alpha/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: 'WebSecurityScanner', + filename: './web-security-scanner.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/v1beta/README.md b/owl-bot-staging/v1beta/README.md new file mode 100644 index 0000000..727d3b6 --- /dev/null +++ b/owl-bot-staging/v1beta/README.md @@ -0,0 +1 @@ +Websecurityscanner: Nodejs Client diff --git a/owl-bot-staging/v1beta/linkinator.config.json b/owl-bot-staging/v1beta/linkinator.config.json new file mode 100644 index 0000000..29a223b --- /dev/null +++ b/owl-bot-staging/v1beta/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta/package.json b/owl-bot-staging/v1beta/package.json new file mode 100644 index 0000000..badee22 --- /dev/null +++ b/owl-bot-staging/v1beta/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/web-security-scanner", + "version": "0.1.0", + "description": "Websecurityscanner client for Node.js", + "repository": "googleapis/nodejs-websecurityscanner", + "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 websecurityscanner", + "websecurityscanner", + "web security scanner" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.14.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.1", + "@types/sinon": "^10.0.0", + "c8": "^7.7.2", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.6", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^10.0.0", + "ts-loader": "^9.2.2", + "typescript": "^4.2.4", + "webpack": "^5.37.1", + "webpack-cli": "^4.7.0" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/crawled_url.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/crawled_url.proto new file mode 100644 index 0000000..cbfead4 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/crawled_url.proto @@ -0,0 +1,41 @@ +// 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.websecurityscanner.v1beta; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "CrawledUrlProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// A CrawledUrl resource represents a URL that was crawled during a ScanRun. Web +// Security Scanner Service crawls the web applications, following all links +// within the scope of sites, to find the URLs to test against. +message CrawledUrl { + // The http method of the request that was used to visit the URL, in + // uppercase. + string http_method = 1; + + // The URL that was crawled. + string url = 2; + + // The body of the request that was used to visit the URL. + string body = 3; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding.proto new file mode 100644 index 0000000..999e092 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding.proto @@ -0,0 +1,98 @@ +// 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.websecurityscanner.v1beta; + +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1beta/finding_addon.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// A Finding resource represents a vulnerability instance identified during a +// ScanRun. +message Finding { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/Finding" + pattern: "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}" + }; + + // The resource name of the Finding. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanruns/{scanRunId}/findings/{findingId}'. + // The finding IDs are generated by the system. + string name = 1; + + // The type of the Finding. + // Detailed and up-to-date information on findings can be found here: + // https://cloud.google.com/security-scanner/docs/scan-result-details + string finding_type = 2; + + // The http method of the request that triggered the vulnerability, in + // uppercase. + string http_method = 3; + + // The URL produced by the server-side fuzzer and used in the request that + // triggered the vulnerability. + string fuzzed_url = 4; + + // The body of the request that triggered the vulnerability. + string body = 5; + + // The description of the vulnerability. + string description = 6; + + // The URL containing human-readable payload that user can leverage to + // reproduce the vulnerability. + string reproduction_url = 7; + + // If the vulnerability was originated from nested IFrame, the immediate + // parent IFrame is reported. + string frame_url = 8; + + // The URL where the browser lands when the vulnerability is detected. + string final_url = 9; + + // The tracking ID uniquely identifies a vulnerability instance across + // multiple ScanRuns. + string tracking_id = 10; + + // An addon containing information reported for a vulnerability with an HTML + // form, if any. + Form form = 16; + + // An addon containing information about outdated libraries. + OutdatedLibrary outdated_library = 11; + + // An addon containing detailed information regarding any resource causing the + // vulnerability such as JavaScript sources, image, audio files, etc. + ViolatingResource violating_resource = 12; + + // An addon containing information about vulnerable or missing HTTP headers. + VulnerableHeaders vulnerable_headers = 15; + + // An addon containing information about request parameters which were found + // to be vulnerable. + VulnerableParameters vulnerable_parameters = 13; + + // An addon containing information reported for an XSS, if any. + Xss xss = 14; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_addon.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_addon.proto new file mode 100644 index 0000000..c29f6ca --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_addon.proto @@ -0,0 +1,90 @@ +// 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.websecurityscanner.v1beta; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingAddonProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// ! Information about a vulnerability with an HTML. +message Form { + // ! The URI where to send the form when it's submitted. + string action_uri = 1; + + // ! The names of form fields related to the vulnerability. + repeated string fields = 2; +} + +// Information reported for an outdated library. +message OutdatedLibrary { + // The name of the outdated library. + string library_name = 1; + + // The version number. + string version = 2; + + // URLs to learn more information about the vulnerabilities in the library. + repeated string learn_more_urls = 3; +} + +// Information regarding any resource causing the vulnerability such +// as JavaScript sources, image, audio files, etc. +message ViolatingResource { + // The MIME type of this resource. + string content_type = 1; + + // URL of this violating resource. + string resource_url = 2; +} + +// Information about vulnerable request parameters. +message VulnerableParameters { + // The vulnerable parameter names. + repeated string parameter_names = 1; +} + +// Information about vulnerable or missing HTTP Headers. +message VulnerableHeaders { + // Describes a HTTP Header. + message Header { + // Header name. + string name = 1; + + // Header value. + string value = 2; + } + + // List of vulnerable headers. + repeated Header headers = 1; + + // List of missing headers. + repeated Header missing_headers = 2; +} + +// Information reported for an XSS. +message Xss { + // Stack traces leading to the point where the XSS occurred. + repeated string stack_traces = 1; + + // An error message generated by a javascript breakage. + string error_message = 2; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_type_stats.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_type_stats.proto new file mode 100644 index 0000000..9b21576 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/finding_type_stats.proto @@ -0,0 +1,36 @@ +// 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.websecurityscanner.v1beta; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "FindingTypeStatsProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// A FindingTypeStats resource represents stats regarding a specific FindingType +// of Findings under a given ScanRun. +message FindingTypeStats { + // The finding type associated with the stats. + string finding_type = 1; + + // The count of findings belonging to this finding type. + int32 finding_count = 2; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config.proto new file mode 100644 index 0000000..b25c619 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config.proto @@ -0,0 +1,193 @@ +// 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.websecurityscanner.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1beta/scan_run.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanConfigProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// A ScanConfig resource contains the configurations to launch a scan. +message ScanConfig { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + pattern: "projects/{project}/scanConfigs/{scan_config}" + }; + + // Scan authentication configuration. + message Authentication { + // Describes authentication configuration that uses a Google account. + message GoogleAccount { + // Required. The user name of the Google account. + string username = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Input only. The password of the Google account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = INPUT_ONLY + ]; + } + + // Describes authentication configuration that uses a custom account. + message CustomAccount { + // Required. The user name of the custom account. + string username = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Input only. The password of the custom account. The credential is stored encrypted + // and not returned in any response nor included in audit logs. + string password = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Required. The login form URL of the website. + string login_url = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. + // Authentication configuration + oneof authentication { + // Authentication using a Google account. + GoogleAccount google_account = 1; + + // Authentication using a custom account. + CustomAccount custom_account = 2; + } + } + + // Scan schedule configuration. + message Schedule { + // A timestamp indicates when the next run will be scheduled. The value is + // refreshed by the server after each run. If unspecified, it will default + // to current server time, which means the scan will be scheduled to start + // immediately. + google.protobuf.Timestamp schedule_time = 1; + + // Required. The duration of time between executions in days. + int32 interval_duration_days = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // Type of user agents used for scanning. + enum UserAgent { + // The user agent is unknown. Service will default to CHROME_LINUX. + USER_AGENT_UNSPECIFIED = 0; + + // Chrome on Linux. This is the service default if unspecified. + CHROME_LINUX = 1; + + // Chrome on Android. + CHROME_ANDROID = 2; + + // Safari on IPhone. + SAFARI_IPHONE = 3; + } + + // Cloud platforms supported by Cloud Web Security Scanner. + enum TargetPlatform { + // The target platform is unknown. Requests with this enum value will be + // rejected with INVALID_ARGUMENT error. + TARGET_PLATFORM_UNSPECIFIED = 0; + + // Google App Engine service. + APP_ENGINE = 1; + + // Google Compute Engine service. + COMPUTE = 2; + } + + // Scan risk levels supported by Cloud Web Security Scanner. LOW impact + // scanning will minimize requests with the potential to modify data. To + // achieve the maximum scan coverage, NORMAL risk level is recommended. + enum RiskLevel { + // Use default, which is NORMAL. + RISK_LEVEL_UNSPECIFIED = 0; + + // Normal scanning (Recommended) + NORMAL = 1; + + // Lower impact scanning + LOW = 2; + } + + // Controls export of scan configurations and results to Cloud Security + // Command Center. + enum ExportToSecurityCommandCenter { + // Use default, which is ENABLED. + EXPORT_TO_SECURITY_COMMAND_CENTER_UNSPECIFIED = 0; + + // Export results of this scan to Cloud Security Command Center. + ENABLED = 1; + + // Do not export results of this scan to Cloud Security Command Center. + DISABLED = 2; + } + + // The resource name of the ScanConfig. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}'. The ScanConfig IDs are + // generated by the system. + string name = 1; + + // Required. The user provided display name of the ScanConfig. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The maximum QPS during scanning. A valid value ranges from 5 to 20 + // inclusively. If the field is unspecified or its value is set 0, server will + // default to 15. Other values outside of [5, 20] range will be rejected with + // INVALID_ARGUMENT error. + int32 max_qps = 3; + + // Required. The starting URLs from which the scanner finds site pages. + repeated string starting_urls = 4 [(google.api.field_behavior) = REQUIRED]; + + // The authentication configuration. If specified, service will use the + // authentication configuration during scanning. + Authentication authentication = 5; + + // The user agent used during scanning. + UserAgent user_agent = 6; + + // The blacklist URL patterns as described in + // https://cloud.google.com/security-scanner/docs/excluded-urls + repeated string blacklist_patterns = 7; + + // The schedule of the ScanConfig. + Schedule schedule = 8; + + // Set of Cloud Platforms targeted by the scan. If empty, APP_ENGINE will be + // used as a default. + repeated TargetPlatform target_platforms = 9; + + // Controls export of scan configurations and results to Cloud Security + // Command Center. + ExportToSecurityCommandCenter export_to_security_command_center = 10; + + // Latest ScanRun if available. + ScanRun latest_run = 11; + + // The risk level selected for the scan + RiskLevel risk_level = 12; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config_error.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config_error.proto new file mode 100644 index 0000000..3920b74 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_config_error.proto @@ -0,0 +1,190 @@ +// 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.websecurityscanner.v1beta; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanConfigErrorProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// Defines a custom error message used by CreateScanConfig and UpdateScanConfig +// APIs when scan configuration validation fails. It is also reported as part of +// a ScanRunErrorTrace message if scan validation fails due to a scan +// configuration error. +message ScanConfigError { + // Output only. + // Defines an error reason code. + // Next id: 44 + enum Code { + option allow_alias = true; + + // There is no error. + CODE_UNSPECIFIED = 0; + + // There is no error. + OK = 0; + + // Indicates an internal server error. + // Please DO NOT USE THIS ERROR CODE unless the root cause is truly unknown. + INTERNAL_ERROR = 1; + + // One of the seed URLs is an App Engine URL but we cannot validate the scan + // settings due to an App Engine API backend error. + APPENGINE_API_BACKEND_ERROR = 2; + + // One of the seed URLs is an App Engine URL but we cannot access the + // App Engine API to validate scan settings. + APPENGINE_API_NOT_ACCESSIBLE = 3; + + // One of the seed URLs is an App Engine URL but the Default Host of the + // App Engine is not set. + APPENGINE_DEFAULT_HOST_MISSING = 4; + + // Google corporate accounts can not be used for scanning. + CANNOT_USE_GOOGLE_COM_ACCOUNT = 6; + + // The account of the scan creator can not be used for scanning. + CANNOT_USE_OWNER_ACCOUNT = 7; + + // This scan targets Compute Engine, but we cannot validate scan settings + // due to a Compute Engine API backend error. + COMPUTE_API_BACKEND_ERROR = 8; + + // This scan targets Compute Engine, but we cannot access the Compute Engine + // API to validate the scan settings. + COMPUTE_API_NOT_ACCESSIBLE = 9; + + // The Custom Login URL does not belong to the current project. + CUSTOM_LOGIN_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 10; + + // The Custom Login URL is malformed (can not be parsed). + CUSTOM_LOGIN_URL_MALFORMED = 11; + + // The Custom Login URL is mapped to a non-routable IP address in DNS. + CUSTOM_LOGIN_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 12; + + // The Custom Login URL is mapped to an IP address which is not reserved for + // the current project. + CUSTOM_LOGIN_URL_MAPPED_TO_UNRESERVED_ADDRESS = 13; + + // The Custom Login URL has a non-routable IP address. + CUSTOM_LOGIN_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 14; + + // The Custom Login URL has an IP address which is not reserved for the + // current project. + CUSTOM_LOGIN_URL_HAS_UNRESERVED_IP_ADDRESS = 15; + + // Another scan with the same name (case-sensitive) already exists. + DUPLICATE_SCAN_NAME = 16; + + // A field is set to an invalid value. + INVALID_FIELD_VALUE = 18; + + // There was an error trying to authenticate to the scan target. + FAILED_TO_AUTHENTICATE_TO_TARGET = 19; + + // Finding type value is not specified in the list findings request. + FINDING_TYPE_UNSPECIFIED = 20; + + // Scan targets Compute Engine, yet current project was not whitelisted for + // Google Compute Engine Scanning Alpha access. + FORBIDDEN_TO_SCAN_COMPUTE = 21; + + // User tries to update managed scan + FORBIDDEN_UPDATE_TO_MANAGED_SCAN = 43; + + // The supplied filter is malformed. For example, it can not be parsed, does + // not have a filter type in expression, or the same filter type appears + // more than once. + MALFORMED_FILTER = 22; + + // The supplied resource name is malformed (can not be parsed). + MALFORMED_RESOURCE_NAME = 23; + + // The current project is not in an active state. + PROJECT_INACTIVE = 24; + + // A required field is not set. + REQUIRED_FIELD = 25; + + // Project id, scanconfig id, scanrun id, or finding id are not consistent + // with each other in resource name. + RESOURCE_NAME_INCONSISTENT = 26; + + // The scan being requested to start is already running. + SCAN_ALREADY_RUNNING = 27; + + // The scan that was requested to be stopped is not running. + SCAN_NOT_RUNNING = 28; + + // One of the seed URLs does not belong to the current project. + SEED_URL_DOES_NOT_BELONG_TO_CURRENT_PROJECT = 29; + + // One of the seed URLs is malformed (can not be parsed). + SEED_URL_MALFORMED = 30; + + // One of the seed URLs is mapped to a non-routable IP address in DNS. + SEED_URL_MAPPED_TO_NON_ROUTABLE_ADDRESS = 31; + + // One of the seed URLs is mapped to an IP address which is not reserved + // for the current project. + SEED_URL_MAPPED_TO_UNRESERVED_ADDRESS = 32; + + // One of the seed URLs has on-routable IP address. + SEED_URL_HAS_NON_ROUTABLE_IP_ADDRESS = 33; + + // One of the seed URLs has an IP address that is not reserved + // for the current project. + SEED_URL_HAS_UNRESERVED_IP_ADDRESS = 35; + + // The Cloud Security Scanner service account is not configured under the + // project. + SERVICE_ACCOUNT_NOT_CONFIGURED = 36; + + // A project has reached the maximum number of scans. + TOO_MANY_SCANS = 37; + + // Resolving the details of the current project fails. + UNABLE_TO_RESOLVE_PROJECT_INFO = 38; + + // One or more blacklist patterns were in the wrong format. + UNSUPPORTED_BLACKLIST_PATTERN_FORMAT = 39; + + // The supplied filter is not supported. + UNSUPPORTED_FILTER = 40; + + // The supplied finding type is not supported. For example, we do not + // provide findings of the given finding type. + UNSUPPORTED_FINDING_TYPE = 41; + + // The URL scheme of one or more of the supplied URLs is not supported. + UNSUPPORTED_URL_SCHEME = 42; + } + + // Indicates the reason code for a configuration failure. + Code code = 1; + + // Indicates the full name of the ScanConfig field that triggers this error, + // for example "scan_config.max_qps". This field is provided for + // troubleshooting purposes only and its actual value can change in the + // future. + string field_name = 2; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run.proto new file mode 100644 index 0000000..48800d2 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run.proto @@ -0,0 +1,117 @@ +// 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.websecurityscanner.v1beta; + +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1beta/scan_run_error_trace.proto"; +import "google/cloud/websecurityscanner/v1beta/scan_run_warning_trace.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// A ScanRun is a output-only resource representing an actual run of the scan. +// Next id: 12 +message ScanRun { + option (google.api.resource) = { + type: "websecurityscanner.googleapis.com/ScanRun" + pattern: "projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}" + }; + + // Types of ScanRun execution state. + enum ExecutionState { + // Represents an invalid state caused by internal server error. This value + // should never be returned. + EXECUTION_STATE_UNSPECIFIED = 0; + + // The scan is waiting in the queue. + QUEUED = 1; + + // The scan is in progress. + SCANNING = 2; + + // The scan is either finished or stopped by user. + FINISHED = 3; + } + + // Types of ScanRun result state. + enum ResultState { + // Default value. This value is returned when the ScanRun is not yet + // finished. + RESULT_STATE_UNSPECIFIED = 0; + + // The scan finished without errors. + SUCCESS = 1; + + // The scan finished with errors. + ERROR = 2; + + // The scan was terminated by user. + KILLED = 3; + } + + // The resource name of the ScanRun. The name follows the format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + // The ScanRun IDs are generated by the system. + string name = 1; + + // The execution state of the ScanRun. + ExecutionState execution_state = 2; + + // The result state of the ScanRun. This field is only available after the + // execution state reaches "FINISHED". + ResultState result_state = 3; + + // The time at which the ScanRun started. + google.protobuf.Timestamp start_time = 4; + + // The time at which the ScanRun reached termination state - that the ScanRun + // is either finished or stopped by user. + google.protobuf.Timestamp end_time = 5; + + // The number of URLs crawled during this ScanRun. If the scan is in progress, + // the value represents the number of URLs crawled up to now. + int64 urls_crawled_count = 6; + + // The number of URLs tested during this ScanRun. If the scan is in progress, + // the value represents the number of URLs tested up to now. The number of + // URLs tested is usually larger than the number URLS crawled because + // typically a crawled URL is tested with multiple test payloads. + int64 urls_tested_count = 7; + + // Whether the scan run has found any vulnerabilities. + bool has_vulnerabilities = 8; + + // The percentage of total completion ranging from 0 to 100. + // If the scan is in queue, the value is 0. + // If the scan is running, the value ranges from 0 to 100. + // If the scan is finished, the value is 100. + int32 progress_percent = 9; + + // If result_state is an ERROR, this field provides the primary reason for + // scan's termination and more details, if such are available. + ScanRunErrorTrace error_trace = 10; + + // A list of warnings, if such are encountered during this scan run. + repeated ScanRunWarningTrace warning_traces = 11; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_error_trace.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_error_trace.proto new file mode 100644 index 0000000..acbdef2 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_error_trace.proto @@ -0,0 +1,76 @@ +// 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.websecurityscanner.v1beta; + +import "google/cloud/websecurityscanner/v1beta/scan_config_error.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunErrorTraceProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// Output only. +// Defines an error trace message for a ScanRun. +message ScanRunErrorTrace { + // Output only. + // Defines an error reason code. + // Next id: 7 + enum Code { + // Default value is never used. + CODE_UNSPECIFIED = 0; + + // Indicates that the scan run failed due to an internal server error. + INTERNAL_ERROR = 1; + + // Indicates a scan configuration error, usually due to outdated ScanConfig + // settings, such as starting_urls or the DNS configuration. + SCAN_CONFIG_ISSUE = 2; + + // Indicates an authentication error, usually due to outdated ScanConfig + // authentication settings. + AUTHENTICATION_CONFIG_ISSUE = 3; + + // Indicates a scan operation timeout, usually caused by a very large site. + TIMED_OUT_WHILE_SCANNING = 4; + + // Indicates that a scan encountered excessive redirects, either to + // authentication or some other page outside of the scan scope. + TOO_MANY_REDIRECTS = 5; + + // Indicates that a scan encountered numerous errors from the web site + // pages. When available, most_common_http_error_code field indicates the + // most common HTTP error code encountered during the scan. + TOO_MANY_HTTP_ERRORS = 6; + } + + // Indicates the error reason code. + Code code = 1; + + // If the scan encounters SCAN_CONFIG_ISSUE error, this field has the error + // message encountered during scan configuration validation that is performed + // before each scan run. + ScanConfigError scan_config_error = 2; + + // If the scan encounters TOO_MANY_HTTP_ERRORS, this field indicates the most + // common HTTP error code, if such is available. For example, if this code is + // 404, the scan has encountered too many NOT_FOUND responses. + int32 most_common_http_error_code = 3; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_warning_trace.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_warning_trace.proto new file mode 100644 index 0000000..6ee6b34 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/scan_run_warning_trace.proto @@ -0,0 +1,59 @@ +// 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.websecurityscanner.v1beta; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "ScanRunWarningTraceProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// Output only. +// Defines a warning trace message for ScanRun. Warning traces provide customers +// with useful information that helps make the scanning process more effective. +message ScanRunWarningTrace { + // Output only. + // Defines a warning message code. + // Next id: 6 + enum Code { + // Default value is never used. + CODE_UNSPECIFIED = 0; + + // Indicates that a scan discovered an unexpectedly low number of URLs. This + // is sometimes caused by complex navigation features or by using a single + // URL for numerous pages. + INSUFFICIENT_CRAWL_RESULTS = 1; + + // Indicates that a scan discovered too many URLs to test, or excessive + // redundant URLs. + TOO_MANY_CRAWL_RESULTS = 2; + + // Indicates that too many tests have been generated for the scan. Customer + // should try reducing the number of starting URLs, increasing the QPS rate, + // or narrowing down the scope of the scan using the excluded patterns. + TOO_MANY_FUZZ_TASKS = 3; + + // Indicates that a scan is blocked by IAP. + BLOCKED_BY_IAP = 4; + } + + // Indicates the warning code. + Code code = 1; +} diff --git a/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/web_security_scanner.proto b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/web_security_scanner.proto new file mode 100644 index 0000000..79be175 --- /dev/null +++ b/owl-bot-staging/v1beta/protos/google/cloud/websecurityscanner/v1beta/web_security_scanner.proto @@ -0,0 +1,413 @@ +// 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.websecurityscanner.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/websecurityscanner/v1beta/crawled_url.proto"; +import "google/cloud/websecurityscanner/v1beta/finding.proto"; +import "google/cloud/websecurityscanner/v1beta/finding_type_stats.proto"; +import "google/cloud/websecurityscanner/v1beta/scan_config.proto"; +import "google/cloud/websecurityscanner/v1beta/scan_run.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.WebSecurityScanner.V1Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/websecurityscanner/v1beta;websecurityscanner"; +option java_multiple_files = true; +option java_outer_classname = "WebSecurityScannerProto"; +option java_package = "com.google.cloud.websecurityscanner.v1beta"; +option php_namespace = "Google\\Cloud\\WebSecurityScanner\\V1beta"; +option ruby_package = "Google::Cloud::WebSecurityScanner::V1beta"; + +// Cloud Web Security Scanner Service identifies security vulnerabilities in web +// applications hosted on Google Cloud Platform. It crawls your application, and +// attempts to exercise as many user inputs and event handlers as possible. +service WebSecurityScanner { + option (google.api.default_host) = "websecurityscanner.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new ScanConfig. + rpc CreateScanConfig(CreateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*}/scanConfigs" + body: "scan_config" + }; + option (google.api.method_signature) = "parent,scan_config"; + } + + // Deletes an existing ScanConfig and its child resources. + rpc DeleteScanConfig(DeleteScanConfigRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/scanConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a ScanConfig. + rpc GetScanConfig(GetScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/scanConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists ScanConfigs under a given project. + rpc ListScanConfigs(ListScanConfigsRequest) returns (ListScanConfigsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*}/scanConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a ScanConfig. This method support partial update of a ScanConfig. + rpc UpdateScanConfig(UpdateScanConfigRequest) returns (ScanConfig) { + option (google.api.http) = { + patch: "/v1beta/{scan_config.name=projects/*/scanConfigs/*}" + body: "scan_config" + }; + option (google.api.method_signature) = "scan_config,update_mask"; + } + + // Start a ScanRun according to the given ScanConfig. + rpc StartScanRun(StartScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/scanConfigs/*}:start" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a ScanRun. + rpc GetScanRun(GetScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + // stop time. + rpc ListScanRuns(ListScanRunsRequest) returns (ListScanRunsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/scanConfigs/*}/scanRuns" + }; + option (google.api.method_signature) = "parent"; + } + + // Stops a ScanRun. The stopped ScanRun is returned. + rpc StopScanRun(StopScanRunRequest) returns (ScanRun) { + option (google.api.http) = { + post: "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*}:stop" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // List CrawledUrls under a given ScanRun. + rpc ListCrawledUrls(ListCrawledUrlsRequest) returns (ListCrawledUrlsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/crawledUrls" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a Finding. + rpc GetFinding(GetFindingRequest) returns (Finding) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/scanConfigs/*/scanRuns/*/findings/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List Findings under a given ScanRun. + rpc ListFindings(ListFindingsRequest) returns (ListFindingsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findings" + }; + option (google.api.method_signature) = "parent,filter"; + } + + // List all FindingTypeStats under a given ScanRun. + rpc ListFindingTypeStats(ListFindingTypeStatsRequest) returns (ListFindingTypeStatsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/scanConfigs/*/scanRuns/*}/findingTypeStats" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for the `CreateScanConfig` method. +message CreateScanConfigRequest { + // Required. The parent resource name where the scan is created, which should be a + // project resource name in the format 'projects/{projectId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The ScanConfig to be created. + ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for the `DeleteScanConfig` method. +message DeleteScanConfigRequest { + // Required. The resource name of the ScanConfig to be deleted. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `GetScanConfig` method. +message GetScanConfigRequest { + // Required. The resource name of the ScanConfig to be returned. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `ListScanConfigs` method. +message ListScanConfigsRequest { + // Required. The parent resource name, which should be a project resource name in the + // format 'projects/{projectId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanConfigs to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Request for the `UpdateScanConfigRequest` method. +message UpdateScanConfigRequest { + // Required. The ScanConfig to be updated. The name field must be set to identify the + // resource to be updated. The values of fields not covered by the mask + // will be ignored. + ScanConfig scan_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The update mask applies to the resource. For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask update_mask = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for the `ListScanConfigs` method. +message ListScanConfigsResponse { + // The list of ScanConfigs returned. + repeated ScanConfig scan_configs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StartScanRun` method. +message StartScanRunRequest { + // Required. The resource name of the ScanConfig to be used. The name follows the + // format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; +} + +// Request for the `GetScanRun` method. +message GetScanRunRequest { + // Required. The resource name of the ScanRun to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Request for the `ListScanRuns` method. +message ListScanRunsRequest { + // Required. The parent resource name, which should be a scan resource name in the + // format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanConfig" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of ScanRuns to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListScanRuns` method. +message ListScanRunsResponse { + // The list of ScanRuns returned. + repeated ScanRun scan_runs = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `StopScanRun` method. +message StopScanRunRequest { + // Required. The resource name of the ScanRun to be stopped. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Request for the `ListCrawledUrls` method. +message ListCrawledUrlsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 2; + + // The maximum number of CrawledUrls to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 3; +} + +// Response for the `ListCrawledUrls` method. +message ListCrawledUrlsResponse { + // The list of CrawledUrls returned. + repeated CrawledUrl crawled_urls = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `GetFinding` method. +message GetFindingRequest { + // Required. The resource name of the Finding to be returned. The name follows the + // format of + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/Finding" + } + ]; +} + +// Request for the `ListFindings` method. +message ListFindingsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; + + // Required. The filter expression. The expression must be in the format: + // . + // Supported field: 'finding_type'. + // Supported operator: '='. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous List request. + // If unspecified, the first page of results is returned. + string page_token = 3; + + // The maximum number of Findings to return, can be limited by server. + // If not specified or not positive, the implementation will select a + // reasonable value. + int32 page_size = 4; +} + +// Response for the `ListFindings` method. +message ListFindingsResponse { + // The list of Findings returned. + repeated Finding findings = 1; + + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 2; +} + +// Request for the `ListFindingTypeStats` method. +message ListFindingTypeStatsRequest { + // Required. The parent resource name, which should be a scan run resource name in the + // format + // 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "websecurityscanner.googleapis.com/ScanRun" + } + ]; +} + +// Response for the `ListFindingTypeStats` method. +message ListFindingTypeStatsResponse { + // The list of FindingTypeStats returned. + repeated FindingTypeStats finding_type_stats = 1; +} diff --git a/owl-bot-staging/v1beta/src/index.ts b/owl-bot-staging/v1beta/src/index.ts new file mode 100644 index 0000000..d28bc04 --- /dev/null +++ b/owl-bot-staging/v1beta/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta from './v1beta'; +const WebSecurityScannerClient = v1beta.WebSecurityScannerClient; +type WebSecurityScannerClient = v1beta.WebSecurityScannerClient; +export {v1beta, WebSecurityScannerClient}; +export default {v1beta, WebSecurityScannerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 0000000..c531caa --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,169 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.websecurityscanner.v1beta", + "libraryPackage": "@google-cloud/web-security-scanner", + "services": { + "WebSecurityScanner": { + "clients": { + "grpc": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "WebSecurityScannerClient", + "rpcs": { + "CreateScanConfig": { + "methods": [ + "createScanConfig" + ] + }, + "DeleteScanConfig": { + "methods": [ + "deleteScanConfig" + ] + }, + "GetScanConfig": { + "methods": [ + "getScanConfig" + ] + }, + "UpdateScanConfig": { + "methods": [ + "updateScanConfig" + ] + }, + "StartScanRun": { + "methods": [ + "startScanRun" + ] + }, + "GetScanRun": { + "methods": [ + "getScanRun" + ] + }, + "StopScanRun": { + "methods": [ + "stopScanRun" + ] + }, + "GetFinding": { + "methods": [ + "getFinding" + ] + }, + "ListFindingTypeStats": { + "methods": [ + "listFindingTypeStats" + ] + }, + "ListScanConfigs": { + "methods": [ + "listScanConfigs", + "listScanConfigsStream", + "listScanConfigsAsync" + ] + }, + "ListScanRuns": { + "methods": [ + "listScanRuns", + "listScanRunsStream", + "listScanRunsAsync" + ] + }, + "ListCrawledUrls": { + "methods": [ + "listCrawledUrls", + "listCrawledUrlsStream", + "listCrawledUrlsAsync" + ] + }, + "ListFindings": { + "methods": [ + "listFindings", + "listFindingsStream", + "listFindingsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/index.ts b/owl-bot-staging/v1beta/src/v1beta/index.ts new file mode 100644 index 0000000..797d676 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/index.ts @@ -0,0 +1,19 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {WebSecurityScannerClient} from './web_security_scanner_client'; diff --git a/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client.ts b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client.ts new file mode 100644 index 0000000..d6d55a5 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client.ts @@ -0,0 +1,1934 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/web_security_scanner_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './web_security_scanner_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Cloud Web Security Scanner Service identifies security vulnerabilities in web + * applications hosted on Google Cloud Platform. It crawls your application, and + * attempts to exercise as many user inputs and event handlers as possible. + * @class + * @memberof v1beta + */ +export class WebSecurityScannerClient { + private _terminated = false; + private _opts: ClientOptions; + 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: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + webSecurityScannerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of WebSecurityScannerClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof WebSecurityScannerClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + 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 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 = { + findingPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + scanConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}' + ), + scanRunPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listScanConfigs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanConfigs'), + listScanRuns: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scanRuns'), + listCrawledUrls: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'crawledUrls'), + listFindings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'findings') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.websecurityscanner.v1beta.WebSecurityScanner', 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 = {}; + } + + /** + * 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.webSecurityScannerStub) { + return this.webSecurityScannerStub; + } + + // Put together the "service stub" for + // google.cloud.websecurityscanner.v1beta.WebSecurityScanner. + this.webSecurityScannerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.websecurityscanner.v1beta.WebSecurityScanner') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.websecurityscanner.v1beta.WebSecurityScanner, + this._opts) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const webSecurityScannerStubMethods = + ['createScanConfig', 'deleteScanConfig', 'getScanConfig', 'listScanConfigs', 'updateScanConfig', 'startScanRun', 'getScanRun', 'listScanRuns', 'stopScanRun', 'listCrawledUrls', 'getFinding', 'listFindings', 'listFindingTypeStats']; + for (const methodName of webSecurityScannerStubMethods) { + const callPromise = this.webSecurityScannerStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.webSecurityScannerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'websecurityscanner.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 'websecurityscanner.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 -- + // ------------------- + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|undefined, {}|undefined + ]>; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a new ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name where the scan is created, which should be a + * project resource name in the format 'projects/{projectId}'. + * @param {google.cloud.websecurityscanner.v1beta.ScanConfig} request.scanConfig + * Required. The ScanConfig to be created. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createScanConfig(request); + */ + createScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.ICreateScanConfigRequest|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.createScanConfig(request, options, callback); + } + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|undefined, {}|undefined + ]>; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an existing ScanConfig and its child resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be deleted. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteScanConfig(request); + */ + deleteScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.websecurityscanner.v1beta.IDeleteScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteScanConfig(request, options, callback); + } + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|undefined, {}|undefined + ]>; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be returned. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanConfig(request); + */ + getScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IGetScanConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanConfig(request, options, callback); + } + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|undefined, {}|undefined + ]>; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates a ScanConfig. This method support partial update of a ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.websecurityscanner.v1beta.ScanConfig} request.scanConfig + * Required. The ScanConfig to be updated. The name field must be set to identify the + * resource to be updated. The values of fields not covered by the mask + * will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The update mask applies to the resource. For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @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 [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateScanConfig(request); + */ + updateScanConfig( + request: protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig, + protos.google.cloud.websecurityscanner.v1beta.IUpdateScanConfigRequest|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({ + 'scan_config.name': request.scanConfig!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateScanConfig(request, options, callback); + } + startScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|undefined, {}|undefined + ]>; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; + startScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Start a ScanRun according to the given ScanConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanConfig to be used. The name follows the + * format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.startScanRun(request); + */ + startScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStartScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.startScanRun(request, options, callback); + } + getScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|undefined, {}|undefined + ]>; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; + getScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getScanRun(request); + */ + getScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IGetScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getScanRun(request, options, callback); + } + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|undefined, {}|undefined + ]>; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|null|undefined, + {}|null|undefined>): void; +/** + * Stops a ScanRun. The stopped ScanRun is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ScanRun to be stopped. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.stopScanRun(request); + */ + stopScanRun( + request: protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun, + protos.google.cloud.websecurityscanner.v1beta.IStopScanRunRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.stopScanRun(request, options, callback); + } + getFinding( + request: protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|undefined, {}|undefined + ]>; + getFinding( + request: protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; + getFinding( + request: protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|null|undefined, + {}|null|undefined>): void; +/** + * Gets a Finding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Finding to be returned. The name follows the + * format of + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. + * @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 [Finding]{@link google.cloud.websecurityscanner.v1beta.Finding}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getFinding(request); + */ + getFinding( + request: protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IFinding, + protos.google.cloud.websecurityscanner.v1beta.IGetFindingRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getFinding(request, options, callback); + } + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|undefined, {}|undefined + ]>; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest, + callback: Callback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): void; +/** + * List all FindingTypeStats under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @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 [ListFindingTypeStatsResponse]{@link google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.listFindingTypeStats(request); + */ + listFindingTypeStats( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse, + protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsRequest|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.listFindingTypeStats(request, options, callback); + } + + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig[], + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse + ]>; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanConfig>): void; + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanConfig>): void; +/** + * Lists ScanConfigs under a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigs( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanConfig>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanConfig>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanConfig[], + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsResponse + ]>|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.listScanConfigs(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanConfigsStream( + request?: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.createStream( + this.innerApiCalls.listScanConfigs as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a project resource name in the + * format 'projects/{projectId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanConfigs to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanConfig]{@link google.cloud.websecurityscanner.v1beta.ScanConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanConfigsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanConfigsAsync( + request?: protos.google.cloud.websecurityscanner.v1beta.IListScanConfigsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanConfigs.asyncIterate( + this.innerApiCalls['listScanConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun[], + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse + ]>; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanRun>): void; + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanRun>): void; +/** + * Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + * stop time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRuns( + request: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanRun>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IScanRun>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IScanRun[], + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListScanRunsResponse + ]>|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.listScanRuns(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScanRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listScanRunsStream( + request?: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.createStream( + this.innerApiCalls.listScanRuns as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listScanRuns`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan resource name in the + * format 'projects/{projectId}/scanConfigs/{scanConfigId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of ScanRuns to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ScanRun]{@link google.cloud.websecurityscanner.v1beta.ScanRun}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listScanRunsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listScanRunsAsync( + request?: protos.google.cloud.websecurityscanner.v1beta.IListScanRunsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listScanRuns.asyncIterate( + this.innerApiCalls['listScanRuns'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse + ]>; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl>): void; + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl>): void; +/** + * List CrawledUrls under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [CrawledUrl]{@link google.cloud.websecurityscanner.v1beta.CrawledUrl}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrls( + request: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl[], + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsResponse + ]>|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.listCrawledUrls(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [CrawledUrl]{@link google.cloud.websecurityscanner.v1beta.CrawledUrl} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCrawledUrlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCrawledUrlsStream( + request?: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.createStream( + this.innerApiCalls.listCrawledUrls as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCrawledUrls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of CrawledUrls to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [CrawledUrl]{@link google.cloud.websecurityscanner.v1beta.CrawledUrl}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCrawledUrlsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCrawledUrlsAsync( + request?: protos.google.cloud.websecurityscanner.v1beta.IListCrawledUrlsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCrawledUrls.asyncIterate( + this.innerApiCalls['listCrawledUrls'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + listFindings( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IFinding[], + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse + ]>; + listFindings( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IFinding>): void; + listFindings( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + callback: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IFinding>): void; +/** + * List Findings under a given ScanRun. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Finding]{@link google.cloud.websecurityscanner.v1beta.Finding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindings( + request: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IFinding>, + callback?: PaginationCallback< + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse|null|undefined, + protos.google.cloud.websecurityscanner.v1beta.IFinding>): + Promise<[ + protos.google.cloud.websecurityscanner.v1beta.IFinding[], + protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest|null, + protos.google.cloud.websecurityscanner.v1beta.IListFindingsResponse + ]>|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.listFindings(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Finding]{@link google.cloud.websecurityscanner.v1beta.Finding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFindingsStream( + request?: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.createStream( + this.innerApiCalls.listFindings as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, which should be a scan run resource name in the + * format + * 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. + * @param {string} request.filter + * Required. The filter expression. The expression must be in the format: + * . + * Supported field: 'finding_type'. + * Supported operator: '='. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous List request. + * If unspecified, the first page of results is returned. + * @param {number} request.pageSize + * The maximum number of Findings to return, can be limited by server. + * If not specified or not positive, the implementation will select a + * reasonable value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Finding]{@link google.cloud.websecurityscanner.v1beta.Finding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listFindingsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listFindingsAsync( + request?: protos.google.cloud.websecurityscanner.v1beta.IListFindingsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listFindings.asyncIterate( + this.innerApiCalls['listFindings'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified finding resource name string. + * + * @param {string} project + * @param {string} scan_config + * @param {string} scan_run + * @param {string} finding + * @returns {string} Resource name string. + */ + findingPath(project:string,scanConfig:string,scanRun:string,finding:string) { + return this.pathTemplates.findingPathTemplate.render({ + project: project, + scan_config: scanConfig, + scan_run: scanRun, + finding: finding, + }); + } + + /** + * Parse the project from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).project; + } + + /** + * Parse the scan_config from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_config; + } + + /** + * Parse the scan_run from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the scan_run. + */ + matchScanRunFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).scan_run; + } + + /** + * Parse the finding from Finding resource. + * + * @param {string} findingName + * A fully-qualified path representing Finding resource. + * @returns {string} A string representing the finding. + */ + matchFindingFromFindingName(findingName: string) { + return this.pathTemplates.findingPathTemplate.match(findingName).finding; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified scanConfig resource name string. + * + * @param {string} project + * @param {string} scan_config + * @returns {string} Resource name string. + */ + scanConfigPath(project:string,scanConfig:string) { + return this.pathTemplates.scanConfigPathTemplate.render({ + project: project, + scan_config: scanConfig, + }); + } + + /** + * Parse the project from ScanConfig resource. + * + * @param {string} scanConfigName + * A fully-qualified path representing ScanConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScanConfigName(scanConfigName: string) { + return this.pathTemplates.scanConfigPathTemplate.match(scanConfigName).project; + } + + /** + * Parse the scan_config from ScanConfig resource. + * + * @param {string} scanConfigName + * A fully-qualified path representing ScanConfig resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromScanConfigName(scanConfigName: string) { + return this.pathTemplates.scanConfigPathTemplate.match(scanConfigName).scan_config; + } + + /** + * Return a fully-qualified scanRun resource name string. + * + * @param {string} project + * @param {string} scan_config + * @param {string} scan_run + * @returns {string} Resource name string. + */ + scanRunPath(project:string,scanConfig:string,scanRun:string) { + return this.pathTemplates.scanRunPathTemplate.render({ + project: project, + scan_config: scanConfig, + scan_run: scanRun, + }); + } + + /** + * Parse the project from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the project. + */ + matchProjectFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).project; + } + + /** + * Parse the scan_config from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the scan_config. + */ + matchScanConfigFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).scan_config; + } + + /** + * Parse the scan_run from ScanRun resource. + * + * @param {string} scanRunName + * A fully-qualified path representing ScanRun resource. + * @returns {string} A string representing the scan_run. + */ + matchScanRunFromScanRunName(scanRunName: string) { + return this.pathTemplates.scanRunPathTemplate.match(scanRunName).scan_run; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.webSecurityScannerStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client_config.json b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client_config.json new file mode 100644 index 0000000..ecb06a1 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_client_config.json @@ -0,0 +1,91 @@ +{ + "interfaces": { + "google.cloud.websecurityscanner.v1beta.WebSecurityScanner": { + "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": { + "CreateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanConfigs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateScanConfig": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListScanRuns": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "StopScanRun": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCrawledUrls": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetFinding": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindings": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListFindingTypeStats": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_proto_list.json b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_proto_list.json new file mode 100644 index 0000000..abb1848 --- /dev/null +++ b/owl-bot-staging/v1beta/src/v1beta/web_security_scanner_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/websecurityscanner/v1beta/crawled_url.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/finding.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/finding_addon.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/finding_type_stats.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/scan_config.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/scan_config_error.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/scan_run.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/scan_run_error_trace.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/scan_run_warning_trace.proto", + "../../protos/google/cloud/websecurityscanner/v1beta/web_security_scanner.proto" +] diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..2f2db00 --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const websecurityscanner = require('@google-cloud/web-security-scanner'); + +function main() { + const webSecurityScannerClient = new websecurityscanner.WebSecurityScannerClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..67b8adc --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {WebSecurityScannerClient} from '@google-cloud/web-security-scanner'; + +// check that the client class type name can be used +function doStuffWithWebSecurityScannerClient(client: WebSecurityScannerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const webSecurityScannerClient = new WebSecurityScannerClient(); + doStuffWithWebSecurityScannerClient(webSecurityScannerClient); +} + +main(); diff --git a/owl-bot-staging/v1beta/system-test/install.ts b/owl-bot-staging/v1beta/system-test/install.ts new file mode 100644 index 0000000..1f850b5 --- /dev/null +++ b/owl-bot-staging/v1beta/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta/test/gapic_web_security_scanner_v1beta.ts b/owl-bot-staging/v1beta/test/gapic_web_security_scanner_v1beta.ts new file mode 100644 index 0000000..77de2a8 --- /dev/null +++ b/owl-bot-staging/v1beta/test/gapic_web_security_scanner_v1beta.ts @@ -0,0 +1,1985 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as websecurityscannerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.WebSecurityScannerClient', () => { + it('has servicePath', () => { + const servicePath = websecurityscannerModule.v1beta.WebSecurityScannerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = websecurityscannerModule.v1beta.WebSecurityScannerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = websecurityscannerModule.v1beta.WebSecurityScannerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.webSecurityScannerStub, undefined); + await client.initialize(); + assert(client.webSecurityScannerStub); + }); + + it('has close method', () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + 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 websecurityscannerModule.v1beta.WebSecurityScannerClient({ + 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('createScanConfig', () => { + it('invokes createScanConfig without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.createScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createScanConfig with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CreateScanConfigRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createScanConfig(request), expectedError); + assert((client.innerApiCalls.createScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('deleteScanConfig', () => { + it('invokes deleteScanConfig without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScanConfig( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteScanConfig with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.DeleteScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteScanConfig(request), expectedError); + assert((client.innerApiCalls.deleteScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanConfig', () => { + it('invokes getScanConfig without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.getScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanConfig with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanConfig(request), expectedError); + assert((client.innerApiCalls.getScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('updateScanConfig', () => { + it('invokes updateScanConfig without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateScanConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateScanConfig without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()); + client.innerApiCalls.updateScanConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScanConfig( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateScanConfig with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.UpdateScanConfigRequest()); + request.scanConfig = {}; + request.scanConfig.name = ''; + const expectedHeaderRequestParams = "scan_config.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScanConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateScanConfig(request), expectedError); + assert((client.innerApiCalls.updateScanConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('startScanRun', () => { + it('invokes startScanRun without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.startScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes startScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.startScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes startScanRun with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StartScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.startScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.startScanRun(request), expectedError); + assert((client.innerApiCalls.startScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getScanRun', () => { + it('invokes getScanRun without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.getScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.getScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getScanRun with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScanRun(request), expectedError); + assert((client.innerApiCalls.getScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('stopScanRun', () => { + it('invokes stopScanRun without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCall(expectedResponse); + const [response] = await client.stopScanRun(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes stopScanRun without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()); + client.innerApiCalls.stopScanRun = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopScanRun( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanRun|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes stopScanRun with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.StopScanRunRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.stopScanRun = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.stopScanRun(request), expectedError); + assert((client.innerApiCalls.stopScanRun as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('getFinding', () => { + it('invokes getFinding without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()); + client.innerApiCalls.getFinding = stubSimpleCall(expectedResponse); + const [response] = await client.getFinding(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getFinding without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()); + client.innerApiCalls.getFinding = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFinding( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IFinding|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getFinding with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.GetFindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getFinding = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFinding(request), expectedError); + assert((client.innerApiCalls.getFinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listFindingTypeStats', () => { + it('invokes listFindingTypeStats without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(expectedResponse); + const [response] = await client.listFindingTypeStats(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingTypeStats without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsResponse()); + client.innerApiCalls.listFindingTypeStats = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindingTypeStats( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IListFindingTypeStatsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindingTypeStats with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingTypeStatsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindingTypeStats = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindingTypeStats(request), expectedError); + assert((client.innerApiCalls.listFindingTypeStats as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('listScanConfigs', () => { + it('invokes listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listScanConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigs without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + ]; + client.innerApiCalls.listScanConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanConfigs(request), expectedError); + assert((client.innerApiCalls.listScanConfigs as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanConfigsStream without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanConfigsStream with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.ScanConfig[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.ScanConfig) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanConfigs, request)); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanConfig()), + ]; + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1beta.IScanConfig[] = []; + const iterable = client.listScanConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanConfigs with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1beta.IScanConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listScanRuns', () => { + it('invokes listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCall(expectedResponse); + const [response] = await client.listScanRuns(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRuns without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + ]; + client.innerApiCalls.listScanRuns = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScanRuns( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IScanRun[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listScanRuns = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listScanRuns(request), expectedError); + assert((client.innerApiCalls.listScanRuns as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listScanRunsStream without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + ]; + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listScanRunsStream with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listScanRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.ScanRun[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.ScanRun) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listScanRuns, request)); + assert.strictEqual( + (client.descriptors.page.listScanRuns.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ScanRun()), + ]; + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1beta.IScanRun[] = []; + const iterable = client.listScanRunsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listScanRuns with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListScanRunsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listScanRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScanRunsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1beta.IScanRun[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listScanRuns.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCrawledUrls', () => { + it('invokes listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCall(expectedResponse); + const [response] = await client.listCrawledUrls(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrls without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + ]; + client.innerApiCalls.listCrawledUrls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCrawledUrls( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCrawledUrls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCrawledUrls(request), expectedError); + assert((client.innerApiCalls.listCrawledUrls as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCrawledUrlsStream without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCrawledUrlsStream with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCrawledUrlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.CrawledUrl[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.CrawledUrl) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCrawledUrls, request)); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.CrawledUrl()), + ]; + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl[] = []; + const iterable = client.listCrawledUrlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCrawledUrls with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListCrawledUrlsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCrawledUrls.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCrawledUrlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1beta.ICrawledUrl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCrawledUrls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listFindings', () => { + it('invokes listFindings without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCall(expectedResponse); + const [response] = await client.listFindings(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindings without error using callback', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + ]; + client.innerApiCalls.listFindings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFindings( + request, + (err?: Error|null, result?: protos.google.cloud.websecurityscanner.v1beta.IFinding[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFindings with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFindings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFindings(request), expectedError); + assert((client.innerApiCalls.listFindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFindingsStream without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + ]; + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listFindingsStream with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listFindings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.websecurityscanner.v1beta.Finding[] = []; + stream.on('data', (response: protos.google.cloud.websecurityscanner.v1beta.Finding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFindings, request)); + assert.strictEqual( + (client.descriptors.page.listFindings.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings without error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.Finding()), + ]; + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.websecurityscanner.v1beta.IFinding[] = []; + const iterable = client.listFindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFindings with error', async () => { + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.websecurityscanner.v1beta.ListFindingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listFindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.websecurityscanner.v1beta.IFinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFindings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('finding', () => { + const fakePath = "/rendered/path/finding"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + scan_run: "scanRunValue", + finding: "findingValue", + }; + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.findingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.findingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('findingPath', () => { + const result = client.findingPath("projectValue", "scanConfigValue", "scanRunValue", "findingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.findingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromFindingName', () => { + const result = client.matchProjectFromFindingName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromFindingName', () => { + const result = client.matchScanConfigFromFindingName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanRunFromFindingName', () => { + const result = client.matchScanRunFromFindingName(fakePath); + assert.strictEqual(result, "scanRunValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFindingFromFindingName', () => { + const result = client.matchFindingFromFindingName(fakePath); + assert.strictEqual(result, "findingValue"); + assert((client.pathTemplates.findingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('scanConfig', () => { + const fakePath = "/rendered/path/scanConfig"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + }; + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.scanConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.scanConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('scanConfigPath', () => { + const result = client.scanConfigPath("projectValue", "scanConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.scanConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScanConfigName', () => { + const result = client.matchProjectFromScanConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.scanConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromScanConfigName', () => { + const result = client.matchScanConfigFromScanConfigName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.scanConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('scanRun', () => { + const fakePath = "/rendered/path/scanRun"; + const expectedParameters = { + project: "projectValue", + scan_config: "scanConfigValue", + scan_run: "scanRunValue", + }; + const client = new websecurityscannerModule.v1beta.WebSecurityScannerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.scanRunPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.scanRunPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('scanRunPath', () => { + const result = client.scanRunPath("projectValue", "scanConfigValue", "scanRunValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.scanRunPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromScanRunName', () => { + const result = client.matchProjectFromScanRunName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanConfigFromScanRunName', () => { + const result = client.matchScanConfigFromScanRunName(fakePath); + assert.strictEqual(result, "scanConfigValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchScanRunFromScanRunName', () => { + const result = client.matchScanRunFromScanRunName(fakePath); + assert.strictEqual(result, "scanRunValue"); + assert((client.pathTemplates.scanRunPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta/tsconfig.json b/owl-bot-staging/v1beta/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v1beta/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/v1beta/webpack.config.js b/owl-bot-staging/v1beta/webpack.config.js new file mode 100644 index 0000000..ad3467d --- /dev/null +++ b/owl-bot-staging/v1beta/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: 'WebSecurityScanner', + filename: './web-security-scanner.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', +};